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 23:03Eugene ZhydzetskiEugene ZhydzetskiScore: 15,332Success
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 22:2115,305192,957,326166,346,0002,004,0002,531,328
2Aug 5, 2022 22:2115,307190,632,622166,372,0002,004,0002,535,424
3Aug 5, 2022 23:0315,314190,251,368168,454,00002,531,328
4Aug 5, 2022 23:0315,314190,942,982166,448,0002,005,0002,535,424
5Aug 5, 2022 22:2115,319189,632,972168,508,00002,535,424
6Aug 5, 2022 23:0315,322191,173,422168,537,00002,531,328
7Aug 5, 2022 22:2115,323192,652,415167,555,0001,003,0002,404,352
8Aug 5, 2022 23:0315,324197,089,460167,557,0001,003,0002,334,720
9Aug 5, 2022 22:2115,324193,373,531168,559,00002,334,720
10Aug 5, 2022 23:0315,325197,177,555167,569,0001,003,0002,535,424
11Aug 5, 2022 22:2115,325233,426,261168,571,30702,215,936
12Aug 5, 2022 22:2115,332193,857,130168,654,00002,543,616
13Aug 5, 2022 23:0315,332231,457,989168,656,98802,203,648
14Aug 5, 2022 22:2115,343195,204,879166,774,0001,997,0002,334,720
15Aug 5, 2022 22:2115,344195,817,626166,792,0001,997,0002,334,720
16Aug 5, 2022 22:2115,345192,517,226166,798,0001,997,0002,359,296
17Aug 5, 2022 23:0315,346195,140,228168,811,00002,334,720
18Aug 5, 2022 23:0315,346199,804,945167,804,000998,0002,334,720
19Aug 5, 2022 23:0315,346221,978,148168,803,90702,203,648
20Aug 5, 2022 22:2115,346228,983,547168,803,61602,203,648
21Aug 5, 2022 23:0315,347194,034,001166,816,0001,997,0002,392,064
22Aug 5, 2022 23:0315,349226,885,168168,842,12202,207,744
23Aug 5, 2022 22:2115,352222,959,389168,869,73202,224,128
24Aug 5, 2022 23:0315,359195,233,928166,948,0001,999,0002,334,720