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 listJun 20, 2021 18:50Sergey StreminSergey StreminScore: 5,876Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 20, 2021 18:505,85090,539,83264,349,00002,490,368
2Jun 20, 2021 18:505,85887,597,05863,429,0001,006,0002,367,488
3Jun 20, 2021 18:505,86287,434,31263,472,0001,007,0002,375,680
4Jun 20, 2021 18:505,86386,664,35764,491,00002,289,664
5Jun 20, 2021 18:505,86386,932,11163,487,0001,007,0002,289,664
6Jun 20, 2021 18:505,86691,657,77663,518,0001,008,0002,371,584
7Jun 20, 2021 18:505,86891,821,94464,550,00002,289,664
8Jun 20, 2021 18:505,86987,199,38263,547,0001,008,0002,289,664
9Jun 20, 2021 18:505,87192,037,56964,579,00002,371,584
10Jun 20, 2021 18:505,87291,445,09463,584,0001,009,0002,367,488
11Jun 20, 2021 18:505,87291,461,56264,596,00002,363,392
12Jun 20, 2021 18:505,87388,025,50263,590,0001,009,0002,371,584
13Jun 20, 2021 18:505,87692,258,93764,641,00002,289,664
14Jun 20, 2021 18:505,88196,643,14263,678,0001,010,0002,289,664
15Jun 20, 2021 18:505,89288,092,19462,820,0001,994,0002,453,504
16Jun 20, 2021 18:505,89591,783,11562,847,0001,995,0002,289,664
17Jun 20, 2021 18:505,89696,385,66363,861,000997,0002,469,888
18Jun 20, 2021 18:505,89792,914,65663,868,000997,0002,371,584
19Jun 20, 2021 18:505,901145,686,97764,915,17602,203,648
20Jun 20, 2021 18:505,903145,662,45064,935,57102,199,552
21Jun 20, 2021 18:505,905132,623,39564,957,89902,207,744
22Jun 20, 2021 18:505,911123,025,29665,015,60702,207,744
23Jun 20, 2021 18:505,912141,180,52765,032,27502,195,456
24Jun 20, 2021 18:505,921134,302,16465,134,84002,195,456