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 15:18Yurkov AlekseyYurkov AlekseyScore: 9,221Success
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 15:179,191127,225,50999,098,0002,001,0002,277,376
2May 2, 2021 15:169,203122,530,82199,225,0002,004,0002,277,376
3May 2, 2021 15:169,209127,039,028100,296,0001,002,0002,277,376
4May 2, 2021 15:179,209128,691,79899,294,0002,005,0002,531,328
5May 2, 2021 15:169,212123,014,16599,322,0002,006,0002,277,376
6May 2, 2021 15:189,212127,733,03899,330,0002,006,0002,265,088
7May 2, 2021 15:179,213128,986,64599,341,0002,006,0002,277,376
8May 2, 2021 15:169,214124,866,42899,352,0002,007,0002,277,376
9May 2, 2021 15:169,214123,934,425100,352,0001,003,0002,269,184
10May 2, 2021 15:169,215128,958,421100,363,0001,003,0002,277,376
11May 2, 2021 15:179,216131,555,271100,373,0001,003,0002,277,376
12May 2, 2021 15:189,219124,562,06799,400,0002,008,0002,277,376
13May 2, 2021 15:179,220134,586,10699,410,0002,008,0002,277,376
14May 2, 2021 15:179,221128,652,58799,418,0002,008,0002,269,184
15May 2, 2021 15:169,222123,534,550100,436,0001,004,0002,277,376
16May 2, 2021 15:189,223125,478,328100,452,0001,004,0002,527,232
17May 2, 2021 15:189,223130,016,735100,446,0001,004,0002,523,136
18May 2, 2021 15:169,225127,775,02299,467,0002,009,0002,527,232
19May 2, 2021 15:179,227124,036,461101,495,00002,281,472
20May 2, 2021 15:189,229124,180,305100,519,0001,005,0002,363,392
21May 2, 2021 15:189,232123,842,330100,548,0001,005,0002,531,328
22May 2, 2021 15:189,238125,278,810100,609,0001,006,0002,375,680
23May 2, 2021 15:189,239128,235,075100,628,0001,006,0002,277,376
24May 2, 2021 15:169,241126,889,734100,641,0001,006,0002,273,280
25May 2, 2021 15:189,257134,488,509100,831,000998,0002,277,376
26May 2, 2021 15:179,260132,906,92199,859,0001,997,0002,273,280
27May 2, 2021 15:179,271131,420,38998,986,0002,999,0002,277,376