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 22:51Yuriy LyfenkoYuriy LyfenkoScore: 6,170Success
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 22:516,13491,552,33066,462,0001,007,0002,334,720
2May 22, 2021 22:406,13788,322,51865,487,0002,015,0002,383,872
3May 22, 2021 22:406,14894,718,49465,606,0002,018,0002,535,424
4May 22, 2021 22:516,14892,623,33065,614,0002,018,0002,531,328
5May 22, 2021 22:516,15891,811,19665,715,0002,022,0002,531,328
6May 22, 2021 22:406,16594,394,18565,826,0001,994,0002,535,424
7May 22, 2021 22:516,166133,350,45967,824,26902,187,264
8May 22, 2021 22:406,16893,740,66764,852,0002,993,0002,535,424
9May 22, 2021 22:406,16898,191,35865,855,0001,995,0002,527,232
10May 22, 2021 22:516,16993,781,28565,866,0001,995,0002,531,328
11May 22, 2021 22:406,16997,307,06166,859,000997,0002,334,720
12May 22, 2021 22:406,16997,248,28265,863,0001,995,0002,531,328
13May 22, 2021 22:516,17092,787,30665,870,0001,996,0002,334,720
14May 22, 2021 22:516,17093,037,04465,870,0001,996,0002,334,720
15May 22, 2021 22:516,17094,922,95265,877,0001,996,0002,531,328
16May 22, 2021 22:406,17094,469,95265,870,0001,996,0002,531,328
17May 22, 2021 22:516,17192,791,84365,884,0001,996,0002,334,720
18May 22, 2021 22:516,180127,248,94967,974,73802,195,456
19May 22, 2021 22:406,18397,501,49465,016,0003,000,0002,334,720
20May 22, 2021 22:516,18398,138,42465,017,0003,000,0002,523,136
21May 22, 2021 22:516,189129,764,95968,081,18202,191,360
22May 22, 2021 22:406,194135,564,72568,130,76402,195,456
23May 22, 2021 22:406,195130,117,97068,140,59702,195,456
24May 22, 2021 22:406,195128,041,57768,144,14902,199,552