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 16, 2021 21:26Andrey TsvetkovAndrey TsvetkovScore: 12,287Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 16, 2021 21:2612,269169,023,869132,964,0001,999,0002,506,752
2Jun 16, 2021 21:2612,272160,302,843131,993,0002,999,0002,375,680
3Jun 16, 2021 21:2612,279158,743,469133,072,0002,001,0002,310,144
4Jun 16, 2021 21:2612,282161,265,302132,095,0003,002,0002,506,752
5Jun 16, 2021 21:2612,282161,384,446133,097,0002,001,0002,514,944
6Jun 16, 2021 21:2612,284158,180,193133,121,0002,001,0002,330,624
7Jun 16, 2021 21:2612,287158,772,277133,155,0002,002,0002,314,240
8Jun 16, 2021 21:2612,310157,076,728134,412,0001,003,0002,498,560
9Jun 16, 2021 21:2612,316201,109,211135,479,47802,191,360
10Jun 16, 2021 21:2612,328199,849,177135,604,29602,183,168
11Jun 16, 2021 21:2612,335202,564,974135,680,63802,179,072
12Jun 16, 2021 21:2612,511167,831,258137,626,00002,330,624