Parse JSON Sergey Svistunov

Compute the total amount of non-canceled external USD transactions from a stream of JSON records as fast as possible.

Input: 1 000 000 JSON records on STDIN, one per line. Each record has the following structure:

{
    "user_id": 0,
    "currency": "USD",
    "transactions": [
        {
            "amount": 0,
            "to_user_id": 0,
            "canceled": false
        }
    ]
}
Field Constraints
user_id Integer, max 10 000
currency One of "GBP", "USD", "RUB", "JPY", "CHF"
transactions Array, max 10 elements
amount Integer, max 1000
canceled Boolean; may be omitted when false

Field order is not guaranteed within any object.

Output: The total amount of all transactions where:

  • record.currency == "USD"
  • transaction.to_user_id != record.user_id (external)
  • transaction.canceled is false or absent
Back to listJun 20, 2021 14:48Andrey TsvetkovAndrey TsvetkovScore: 12,089Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 20, 2021 14:4812,035161,369,315129,372,0003,008,0002,510,848
2Jun 20, 2021 14:4812,055159,040,026130,592,0002,009,0002,502,656
3Jun 20, 2021 14:4812,061158,954,909130,660,0002,010,0002,510,848
4Jun 20, 2021 14:4812,076158,059,833129,842,0002,996,0002,330,624
5Jun 20, 2021 14:4812,084157,969,344130,926,0001,998,0002,506,752
6Jun 20, 2021 14:4812,086160,236,996129,948,0002,998,0002,330,624
7Jun 20, 2021 14:4812,089160,383,190129,976,0002,999,0002,498,560
8Jun 20, 2021 14:4812,096185,408,677133,052,78202,187,264
9Jun 20, 2021 14:4812,101161,460,465131,112,0002,001,0002,514,944
10Jun 20, 2021 14:4812,103156,140,756131,131,0002,002,0002,326,528
11Jun 20, 2021 14:4812,110197,609,278133,214,12102,187,264
12Jun 20, 2021 14:4812,118190,630,993133,301,22302,179,072