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 16, 2021 18:50Yuriy LyfenkoYuriy LyfenkoScore: 5,606Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 16, 2021 18:505,5833,136,025,51661,414,00002,260,992
2May 16, 2021 18:505,5885,081,196,76260,465,0001,007,0002,523,136
3May 16, 2021 18:505,5902,098,396,14060,481,0001,008,0002,265,088
4May 16, 2021 18:505,5931,980,293,13057,553,0003,969,0002,523,136
5May 16, 2021 18:505,5944,456,297,37060,544,000992,0002,523,136
6May 16, 2021 18:505,5981,874,289,28360,584,000993,0002,269,184
7May 16, 2021 18:505,5994,795,061,08560,593,000993,0002,265,088
8May 16, 2021 18:505,6002,858,161,28260,606,000993,0002,523,136
9May 16, 2021 18:505,601561,142,45960,620,000993,0002,269,184
10May 16, 2021 18:505,6031,288,967,38560,634,000994,0002,523,136
11May 16, 2021 18:505,603543,896,74859,615,0002,020,0002,383,872
12May 16, 2021 18:505,6041,001,694,80759,656,0001,988,0002,265,088
13May 16, 2021 18:505,605950,099,11261,650,00002,265,088
14May 16, 2021 18:505,606622,667,45760,671,000994,0002,269,184
15May 16, 2021 18:505,60799,398,97660,679,000994,0002,527,232
16May 16, 2021 18:505,6074,195,475,51159,685,0001,989,0002,265,088
17May 16, 2021 18:505,6102,525,330,82659,725,0001,990,0002,265,088
18May 16, 2021 18:505,6121,285,413,70659,744,0001,991,0002,523,136
19May 16, 2021 18:505,6205,029,404,27959,828,0001,994,0002,265,088
20May 16, 2021 18:505,621233,781,11358,841,0002,991,0002,265,088
21May 16, 2021 18:505,6221,798,519,24359,850,0001,995,0002,265,088
22May 16, 2021 18:505,6244,123,860,75360,872,000997,0002,392,064
23May 16, 2021 18:505,6264,053,656,59960,890,000998,0002,523,136
24May 16, 2021 18:505,6284,581,426,80661,904,00002,523,136
25May 16, 2021 18:505,630971,865,09959,966,0001,966,0002,396,160
26May 16, 2021 18:505,6353,913,081,92959,036,0002,951,0002,265,088
27May 16, 2021 18:505,6392,170,828,67361,033,0001,000,0002,383,872