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 22:32Eugene ZhydzetskiEugene ZhydzetskiScore: 17,275Success
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:3217,234219,792,508189,576,00002,334,720
2Aug 5, 2022 22:3117,249248,952,599189,734,73002,199,552
3Aug 5, 2022 22:3217,254221,075,070189,795,00002,334,720
4Aug 5, 2022 22:3217,254213,907,406186,799,0002,996,0002,334,720
5Aug 5, 2022 22:3117,254219,055,879188,795,000998,0002,531,328
6Aug 5, 2022 22:3117,255214,008,882187,803,0001,997,0002,535,424
7Aug 5, 2022 22:3117,262217,369,776186,881,0002,998,0002,387,968
8Aug 5, 2022 22:3217,266216,276,498188,928,000999,0002,334,720
9Aug 5, 2022 22:3217,267253,086,203189,942,07502,207,744
10Aug 5, 2022 22:3117,268216,982,289187,953,0001,999,0002,375,680
11Aug 5, 2022 22:3117,268218,068,458187,950,0001,999,0002,334,720
12Aug 5, 2022 22:3217,272218,790,561187,994,0001,999,0002,334,720
13Aug 5, 2022 22:3217,275219,140,894187,022,0003,000,0002,334,720
14Aug 5, 2022 22:3217,275223,892,997188,028,0002,000,0002,535,424
15Aug 5, 2022 22:3117,278256,317,863190,053,09002,207,744
16Aug 5, 2022 22:3117,278256,230,626190,063,30702,207,744
17Aug 5, 2022 22:3217,279260,331,779190,069,07202,211,840
18Aug 5, 2022 22:3217,281224,475,262188,086,0002,000,0002,334,720
19Aug 5, 2022 22:3117,287206,112,161189,153,0001,000,0002,334,720
20Aug 5, 2022 22:3217,289210,465,019188,179,0002,001,0002,334,720
21Aug 5, 2022 22:3117,291214,161,329189,200,0001,001,0002,334,720
22Aug 5, 2022 22:3217,292245,702,236190,211,07502,203,648
23Aug 5, 2022 22:3117,297211,781,610188,267,0002,002,0002,531,328
24Aug 5, 2022 22:3117,302215,930,591188,321,0002,003,0002,334,720