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 22, 2021 17:44Yuriy LyfenkoYuriy LyfenkoScore: 6,245Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 22, 2021 17:446,19894,307,06465,173,0003,008,0002,334,720
2May 22, 2021 17:256,20091,636,03566,199,0002,006,0002,334,720
3May 22, 2021 17:256,20187,172,79266,210,0002,006,0002,334,720
4May 22, 2021 22:366,21592,757,96366,360,0002,010,0002,527,232
5May 22, 2021 17:446,22191,704,78366,422,0002,012,0002,334,720
6May 22, 2021 17:256,22192,878,43566,422,0002,012,0002,531,328
7May 22, 2021 17:446,225129,401,00568,474,87702,199,552
8May 22, 2021 22:366,22590,954,66367,464,0001,006,0002,334,720
9May 22, 2021 17:446,22691,035,12467,477,0001,007,0002,334,720
10May 22, 2021 22:366,22688,659,98767,478,0001,007,0002,523,136
11May 22, 2021 17:256,22789,935,42966,487,0002,014,0002,531,328
12May 22, 2021 17:446,23692,345,34467,585,0001,008,0002,338,816
13May 22, 2021 17:256,23798,194,73067,598,0001,008,0002,535,424
14May 22, 2021 17:256,24199,210,10267,643,0001,009,0002,334,720
15May 22, 2021 22:366,24398,002,98567,666,0001,009,0002,531,328
16May 22, 2021 22:366,24396,408,66966,659,0002,019,0002,531,328
17May 22, 2021 22:366,243131,313,07068,676,20002,191,360
18May 22, 2021 17:446,24493,885,06467,677,0001,010,0002,531,328
19May 22, 2021 17:446,245100,069,77166,679,0002,020,0002,334,720
20May 22, 2021 17:446,24594,942,26267,687,0001,010,0002,334,720
21May 22, 2021 17:256,24693,364,38366,688,0002,020,0002,334,720
22May 22, 2021 17:256,247137,702,78068,718,76602,187,264
23May 22, 2021 17:256,249123,924,79468,743,66002,191,360
24May 22, 2021 22:366,252126,402,52268,766,51702,195,456
25May 22, 2021 22:366,25595,511,09966,806,0001,994,0002,334,720
26May 22, 2021 22:366,25694,570,63766,823,0001,994,0002,334,720
27May 22, 2021 17:256,25797,270,06565,830,0002,992,0002,355,200
28May 22, 2021 22:366,25895,384,72165,846,0002,993,0002,531,328
29May 22, 2021 17:446,25994,951,67366,856,0001,995,0002,531,328
30May 22, 2021 17:256,26098,912,61767,867,000998,0002,523,136
31May 22, 2021 22:366,26195,819,57566,873,0001,996,0002,334,720
32May 22, 2021 17:446,26294,858,59868,879,00002,334,720
33May 22, 2021 17:446,262125,247,90068,883,39202,195,456
34May 22, 2021 17:446,264133,981,26968,904,67602,199,552
35May 22, 2021 17:256,269127,967,82068,961,88602,179,072
36May 22, 2021 22:366,270122,370,38968,974,31702,183,168