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 listSep 19, 2021 12:17Ilya AniskovetsIlya AniskovetsScore: 14,132Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 19, 2021 12:1713,916220,653,553153,076,55102,220,032
2Sep 19, 2021 12:1713,930211,102,473153,233,04602,228,224
3Sep 19, 2021 12:1714,011207,037,657154,121,27502,228,224
4Sep 19, 2021 12:1714,104175,507,094153,145,0002,001,0002,281,472
5Sep 19, 2021 12:1714,114178,099,980153,247,0002,003,0002,293,760
6Sep 19, 2021 12:1714,126181,326,602154,380,0001,002,0002,293,760
7Sep 19, 2021 12:1714,132178,382,572154,445,0001,002,0002,502,656
8Sep 19, 2021 12:1714,145185,237,747154,592,0001,003,0002,293,760
9Sep 19, 2021 12:1714,156179,820,091154,717,000998,0002,285,568
10Sep 19, 2021 12:1714,203183,658,744154,232,0002,003,0002,510,848
11Sep 19, 2021 12:1714,205179,277,632154,253,0002,003,0002,326,528
12Sep 19, 2021 12:1714,278184,388,999156,062,0001,000,0002,293,760