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 listAug 5, 2022 21:39Eugene ZhydzetskiEugene ZhydzetskiScore: 17,345Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Aug 5, 2022 21:3517,288253,434,703190,166,49702,211,840
2Aug 5, 2022 21:3917,296247,617,372190,254,09002,203,648
3Aug 5, 2022 21:3517,298246,174,464190,276,90202,211,840
4Aug 5, 2022 21:3917,313211,134,765188,443,0002,004,0002,281,472
5Aug 5, 2022 21:3517,316250,614,576190,475,14102,203,648
6Aug 5, 2022 21:3917,316250,016,845190,471,35502,220,032
7Aug 5, 2022 21:3517,324223,672,523189,562,0001,002,0002,334,720
8Aug 5, 2022 21:3517,325226,121,327189,568,0001,003,0002,334,720
9Aug 5, 2022 21:3917,330254,091,913190,634,27302,215,936
10Aug 5, 2022 21:3517,332214,693,726190,653,00002,535,424
11Aug 5, 2022 21:3517,344221,681,324188,788,0001,997,0002,535,424
12Aug 5, 2022 21:3917,344217,984,241188,789,0001,997,0002,334,720
13Aug 5, 2022 21:3917,345218,077,732188,801,0001,997,0002,334,720
14Aug 5, 2022 21:3517,346219,962,887188,812,0001,998,0002,334,720
15Aug 5, 2022 21:3517,347225,786,272188,822,0001,998,0002,535,424
16Aug 5, 2022 21:3517,347221,771,935189,814,000999,0002,543,616
17Aug 5, 2022 21:3517,348216,528,079189,827,000999,0002,531,328
18Aug 5, 2022 21:3917,349220,515,309188,846,0001,998,0002,334,720
19Aug 5, 2022 21:3517,350220,147,303189,850,000999,0002,334,720
20Aug 5, 2022 21:3917,350216,723,712188,850,0001,998,0002,334,720
21Aug 5, 2022 21:3917,352219,584,692188,879,0001,998,0002,334,720
22Aug 5, 2022 21:3917,353213,385,358187,881,0002,998,0002,531,328
23Aug 5, 2022 21:3917,353220,242,275188,880,0001,998,0002,527,232
24Aug 5, 2022 21:3917,367217,409,509191,034,00002,334,720