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 2, 2021 16:57Yurkov AlekseyYurkov AlekseyScore: 7,288Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 16:567,272104,758,68476,994,0002,999,0002,281,472
2May 2, 2021 16:577,273104,953,45077,000,0003,000,0002,277,376
3May 2, 2021 16:567,274105,137,50278,016,0002,000,0002,531,328
4May 2, 2021 16:567,278103,646,17978,057,0002,001,0002,273,280
5May 2, 2021 16:577,27899,020,80279,058,0001,000,0002,269,184
6May 2, 2021 16:567,279105,951,08778,073,0002,001,0002,277,376
7May 2, 2021 16:577,281102,587,24979,093,0001,001,0002,269,184
8May 2, 2021 16:567,281103,869,09978,087,0002,002,0002,265,088
9May 2, 2021 16:577,281102,762,57279,085,0001,001,0002,265,088
10May 2, 2021 16:577,283101,094,88977,112,0003,004,0002,277,376
11May 2, 2021 16:577,284107,446,75578,126,0002,003,0002,277,376
12May 2, 2021 16:577,286103,129,97278,141,0002,003,0002,523,136
13May 2, 2021 16:567,287102,443,57479,151,0001,001,0002,392,064
14May 2, 2021 16:577,288102,942,71978,164,0002,004,0002,277,376
15May 2, 2021 16:577,288101,630,84178,162,0002,004,0002,269,184
16May 2, 2021 16:567,289104,693,76677,177,0003,006,0002,273,280
17May 2, 2021 16:577,292108,750,06778,210,0002,005,0002,277,376
18May 2, 2021 16:577,294106,225,53179,236,0001,002,0002,277,376
19May 2, 2021 16:577,294101,928,68179,235,0001,002,0002,269,184
20May 2, 2021 16:577,294104,864,32379,230,0001,002,0002,531,328
21May 2, 2021 16:577,295102,605,85579,245,0001,003,0002,519,040
22May 2, 2021 16:577,298104,934,48678,276,0002,007,0002,277,376
23May 2, 2021 16:567,298104,275,24678,273,0002,007,0002,281,472
24May 2, 2021 16:577,299107,730,04278,282,0002,007,0002,277,376
25May 2, 2021 16:577,299103,398,02578,286,0002,007,0002,523,136
26May 2, 2021 16:577,301103,490,18778,304,0002,007,0002,277,376
27May 2, 2021 16:567,303107,765,70679,328,0001,004,0002,277,376