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 listMay 8, 2021 06:37Yuriy LyfenkoYuriy LyfenkoScore: 11,379Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 8, 2021 06:3711,353150,209,614122,883,0001,998,0002,330,624
2May 8, 2021 06:3611,367156,731,748124,036,0001,000,0002,330,624
3May 8, 2021 06:1511,368151,109,354123,048,0002,000,0002,535,424
4May 8, 2021 06:1511,369157,803,284123,060,0002,000,0002,535,424
5May 8, 2021 06:3711,370149,959,640123,074,0002,001,0002,330,624
6May 8, 2021 06:3611,371154,620,030123,076,0002,001,0002,334,720
7May 8, 2021 06:3711,372153,882,631124,092,0001,000,0002,330,624
8May 8, 2021 06:1511,372151,009,109124,092,0001,000,0002,535,424
9May 8, 2021 06:3711,375148,651,005122,127,0003,003,0002,342,912
10May 8, 2021 06:3611,375155,223,370123,121,0002,001,0002,334,720
11May 8, 2021 06:3711,376149,416,803123,134,0002,002,0002,531,328
12May 8, 2021 06:1511,376148,200,605122,138,0003,003,0002,531,328
13May 8, 2021 06:1511,376149,832,689121,135,0004,004,0002,334,720
14May 8, 2021 06:1511,376148,962,820122,128,0003,003,0002,531,328
15May 8, 2021 06:3711,376146,623,149122,131,0003,003,0002,330,624
16May 8, 2021 06:3611,377153,393,995122,147,0003,003,0002,334,720
17May 8, 2021 06:3711,378146,114,610123,158,0002,002,0002,334,720
18May 8, 2021 06:1511,378148,478,059122,160,0003,003,0002,330,624
19May 8, 2021 06:3711,379149,237,444122,166,0003,004,0002,330,624
20May 8, 2021 06:3711,381150,265,492124,185,0001,001,0002,330,624
21May 8, 2021 06:3611,381148,377,080123,187,0002,003,0002,330,624
22May 8, 2021 06:3611,383149,651,707123,214,0002,003,0002,527,232
23May 8, 2021 06:3711,385148,908,664122,226,0003,005,0002,334,720
24May 8, 2021 06:3611,387152,428,809124,256,0001,002,0002,334,720
25May 8, 2021 06:3711,387149,954,721124,252,0001,002,0002,334,720
26May 8, 2021 06:3711,387153,109,506122,246,0003,006,0002,527,232
27May 8, 2021 06:1511,387147,616,974123,256,0002,004,0002,334,720
28May 8, 2021 06:3711,391146,130,343122,294,0003,007,0002,535,424
29May 8, 2021 06:3711,392152,080,826123,307,0002,004,0002,531,328
30May 8, 2021 06:3711,393154,234,357122,313,0003,007,0002,531,328
31May 8, 2021 06:1511,394151,083,867121,323,0004,010,0002,531,328
32May 8, 2021 06:3611,395147,167,925123,340,0002,005,0002,330,624
33May 8, 2021 06:3611,401154,956,301123,400,0002,006,0002,334,720
34May 8, 2021 06:3711,402147,920,711121,406,0004,013,0002,535,424
35May 8, 2021 06:3711,404149,206,943125,445,00002,330,624
36May 8, 2021 06:3711,413152,538,779123,531,0002,008,0002,531,328