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 12, 2021 22:54Yuriy LyfenkoYuriy LyfenkoScore: 8,300Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 12, 2021 22:558,278116,061,20189,056,0002,001,0002,531,328
2May 12, 2021 22:538,286112,730,96790,149,0001,001,0002,330,624
3May 12, 2021 22:558,289112,989,98990,175,0001,001,0002,531,328
4May 12, 2021 22:558,289113,990,70890,180,0001,002,0002,531,328
5May 12, 2021 22:548,289117,034,78389,173,0002,003,0002,330,624
6May 12, 2021 22:538,296111,512,63789,253,0002,005,0002,531,328
7May 12, 2021 22:548,296120,095,71689,254,0002,005,0002,527,232
8May 12, 2021 22:538,296115,403,72590,251,0001,002,0002,535,424
9May 12, 2021 22:538,298115,292,44289,274,0002,006,0002,330,624
10May 12, 2021 22:538,298113,817,05688,265,0003,009,0002,334,720
11May 12, 2021 22:548,298114,026,95890,275,0001,003,0002,334,720
12May 12, 2021 22:558,299117,487,34089,279,0002,006,0002,334,720
13May 12, 2021 22:538,299113,089,26990,288,0001,003,0002,527,232
14May 12, 2021 22:548,300109,477,97991,300,00002,330,624
15May 12, 2021 22:538,301115,909,42289,309,0002,006,0002,527,232
16May 12, 2021 22:548,302114,299,50190,323,0001,003,0002,523,136
17May 12, 2021 22:558,302115,910,85189,316,0002,007,0002,330,624
18May 12, 2021 22:548,303111,175,80890,329,0001,003,0002,334,720
19May 12, 2021 22:558,303111,924,39888,326,0003,011,0002,527,232
20May 12, 2021 22:548,305117,933,78990,355,0001,003,0002,334,720
21May 12, 2021 22:558,305115,786,43789,344,0002,007,0002,330,624
22May 12, 2021 22:548,311116,450,46990,413,0001,004,0002,523,136
23May 12, 2021 22:538,311117,209,21990,421,0001,004,0002,531,328
24May 12, 2021 22:548,320112,817,73790,514,0001,005,0002,330,624
25May 12, 2021 22:538,321116,598,18989,518,0002,011,0002,318,336
26May 12, 2021 22:558,322115,433,83889,534,0002,012,0002,531,328
27May 12, 2021 22:558,350125,557,27490,852,000998,0002,330,624