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 18:48Yuriy LyfenkoYuriy LyfenkoScore: 5,849Success
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 18:505,82484,252,04160,063,0004,004,0002,281,472
2May 2, 2021 18:485,82691,367,67362,084,0002,002,0002,527,232
3May 2, 2021 18:505,82687,056,18262,083,0002,002,0002,281,472
4May 2, 2021 18:525,82892,978,22362,102,0002,003,0002,269,184
5May 2, 2021 18:485,82890,528,62362,102,0002,003,0002,281,472
6May 2, 2021 18:485,82987,509,91562,121,0002,003,0002,277,376
7May 2, 2021 18:485,83490,175,80162,169,0002,005,0002,281,472
8May 2, 2021 18:505,83588,251,36262,185,0002,005,0002,281,472
9May 2, 2021 18:495,83590,942,25462,181,0002,005,0002,281,472
10May 2, 2021 18:505,83785,670,43262,200,0002,006,0002,281,472
11May 2, 2021 18:495,83785,930,41262,200,0002,006,0002,273,280
12May 2, 2021 18:495,84090,116,49362,237,0002,007,0002,273,280
13May 2, 2021 18:495,84185,771,82461,239,0003,011,0002,273,280
14May 2, 2021 18:495,84492,492,97462,271,0002,008,0002,371,584
15May 2, 2021 18:525,84589,737,20162,281,0002,009,0002,400,256
16May 2, 2021 18:525,84591,946,94162,284,0002,009,0002,281,472
17May 2, 2021 18:525,84690,858,90262,296,0002,009,0002,281,472
18May 2, 2021 18:525,84685,791,20963,299,0001,004,0002,281,472
19May 2, 2021 18:505,84988,818,54661,322,0003,015,0002,527,232
20May 2, 2021 18:525,84994,188,91162,333,0002,010,0002,281,472
21May 2, 2021 18:505,85585,440,75464,402,00002,273,280
22May 2, 2021 18:495,85591,737,55963,395,0001,006,0002,523,136
23May 2, 2021 18:505,85689,292,24364,414,00002,269,184
24May 2, 2021 18:525,85790,108,34162,414,0002,013,0002,277,376
25May 2, 2021 18:505,85985,520,16963,445,0001,007,0002,281,472
26May 2, 2021 18:525,86188,330,24863,469,0001,007,0002,281,472
27May 2, 2021 18:485,86288,415,26363,480,0001,007,0002,273,280
28May 2, 2021 18:485,86388,723,42663,481,0001,007,0002,281,472
29May 2, 2021 18:495,86389,142,92063,490,0001,007,0002,269,184
30May 2, 2021 18:485,86485,172,43864,508,00002,265,088
31May 2, 2021 18:495,86687,246,38763,513,0001,008,0002,277,376
32May 2, 2021 18:505,86789,562,06863,529,0001,008,0002,269,184
33May 2, 2021 18:525,86886,674,08962,535,0002,017,0002,269,184
34May 2, 2021 18:495,87094,577,36663,559,0001,008,0002,273,280
35May 2, 2021 18:485,87199,942,29063,567,0001,009,0002,269,184
36May 2, 2021 18:485,88394,624,62363,702,0001,011,0002,289,664