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 8, 2021 20:09Yuriy LyfenkoYuriy LyfenkoScore: 5,575Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 8, 2021 20:085,55585,312,40160,101,0001,001,0002,387,968
2May 8, 2021 20:095,55788,728,91759,120,0002,004,0002,396,160
3May 8, 2021 20:095,55886,022,18459,138,0002,004,0002,383,872
4May 8, 2021 20:085,56684,627,21561,222,00002,523,136
5May 8, 2021 20:085,56783,333,99260,237,0001,003,0002,387,968
6May 8, 2021 20:085,56792,102,42859,233,0002,007,0002,523,136
7May 8, 2021 20:085,57083,315,96558,260,0003,013,0002,396,160
8May 8, 2021 20:085,57289,954,06760,284,0001,004,0002,260,992
9May 8, 2021 20:085,57490,105,20659,307,0002,010,0002,396,160
10May 8, 2021 20:085,57582,143,03960,324,0001,005,0002,392,064
11May 8, 2021 20:095,57784,834,95660,346,0001,005,0002,523,136
12May 8, 2021 20:095,57782,784,93360,346,0001,005,0002,523,136
13May 8, 2021 20:095,57789,052,07360,340,0001,005,0002,523,136
14May 8, 2021 20:095,57888,175,45459,349,0002,011,0002,523,136
15May 8, 2021 20:095,58084,254,41660,379,0001,006,0002,523,136
16May 8, 2021 20:085,58184,164,59960,381,0001,006,0002,387,968
17May 8, 2021 20:095,58884,088,22359,451,0002,015,0002,523,136
18May 8, 2021 20:095,59184,421,27760,492,0001,008,0002,482,176