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 18:17Yuriy LyfenkoYuriy LyfenkoScore: 4,463Success
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 18:174,396106,327,81648,357,57202,236,416
2May 22, 2021 18:124,432110,365,73048,754,39702,232,320
3May 22, 2021 18:124,435110,004,67348,783,32902,232,320
4May 22, 2021 18:174,441114,253,03048,845,94502,240,512
5May 22, 2021 18:174,441103,320,86148,851,01202,236,416
6May 22, 2021 18:124,44279,644,51146,865,0001,994,0002,387,968
7May 22, 2021 18:174,44975,340,81646,944,0001,997,0002,392,064
8May 22, 2021 18:124,450113,011,71048,954,48102,236,416
9May 22, 2021 18:124,45175,714,99147,963,000999,0002,265,088
10May 22, 2021 18:124,45580,037,31848,000,0001,000,0002,527,232
11May 22, 2021 18:174,46185,323,49147,066,0002,002,0002,265,088
12May 22, 2021 18:124,46181,317,75847,070,0002,002,0002,265,088
13May 22, 2021 18:174,46375,152,95847,090,0002,003,0002,265,088
14May 22, 2021 18:124,46476,674,89947,102,0002,004,0002,387,968
15May 22, 2021 18:124,46978,821,51447,155,0002,006,0002,265,088
16May 22, 2021 18:174,47479,366,59147,209,0002,008,0002,269,184
17May 22, 2021 18:174,48673,336,80848,340,0001,007,0002,392,064
18May 22, 2021 18:174,48876,195,55049,372,00002,265,088
19May 22, 2021 18:124,49575,924,55848,434,0001,009,0002,396,160
20May 22, 2021 18:124,49573,597,70049,446,00002,265,088
21May 22, 2021 18:174,50275,929,91548,508,0001,010,0002,265,088
22May 22, 2021 18:124,50675,327,38148,553,0001,011,0002,527,232
23May 22, 2021 18:174,50983,124,79748,591,0001,012,0002,387,968
24May 22, 2021 18:174,53378,099,17047,874,0001,994,0002,523,136