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 20, 2021 06:04Yuriy LyfenkoYuriy LyfenkoScore: 5,582Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 20, 2021 06:045,55889,359,61458,133,0003,006,0002,396,160
2May 22, 2021 14:585,56288,294,81059,172,0002,005,0002,387,968
3May 20, 2021 06:045,56685,613,43059,222,0002,007,0002,260,992
4May 22, 2021 14:585,56689,606,29459,224,0002,007,0002,392,064
5May 22, 2021 14:585,56785,729,64460,237,0001,003,0002,392,064
6May 22, 2021 14:585,56890,282,90960,247,0001,004,0002,523,136
7May 22, 2021 14:585,57382,532,65961,302,00002,519,040
8May 20, 2021 06:045,57382,640,13460,294,0001,004,0002,392,064
9May 20, 2021 06:045,57488,893,32360,308,0001,005,0002,523,136
10May 22, 2021 14:585,57684,919,16361,340,00002,392,064
11May 22, 2021 14:585,57886,359,69559,343,0002,011,0002,523,136
12May 22, 2021 14:585,57888,009,38760,351,0001,005,0002,523,136
13May 20, 2021 06:045,58285,826,50861,398,00002,510,848
14May 20, 2021 06:045,58686,908,50160,434,0001,007,0002,523,136
15May 20, 2021 06:045,58993,565,28860,468,0001,007,0002,465,792
16May 20, 2021 06:045,59382,379,73961,526,00002,523,136
17May 20, 2021 06:045,59585,022,66261,541,00002,523,136
18May 22, 2021 14:585,60385,510,57161,636,00002,523,136
19May 20, 2021 06:045,879146,296,44964,664,76502,240,512
20May 20, 2021 06:045,885117,439,62664,733,77602,240,512
21May 22, 2021 14:585,893134,871,90864,817,71302,248,704
22May 22, 2021 14:585,897134,036,26464,870,45602,236,416
23May 20, 2021 06:045,903122,163,55964,938,38702,244,608
24May 22, 2021 14:585,914124,655,11665,056,22702,236,416