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 listJul 28, 2024 21:50Andrey LikhachevAndrey LikhachevScore: 9,361Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jul 28, 2024 21:239,296125,151,378101,255,0001,002,0002,371,584
2Jul 28, 2024 21:509,304124,204,665102,340,00002,285,568
3Jul 28, 2024 21:239,307123,079,962101,377,0001,003,0002,367,488
4Jul 28, 2024 21:509,307124,548,308102,377,00002,289,664
5Jul 28, 2024 21:509,312131,189,968101,429,0001,004,0002,363,392
6Jul 28, 2024 21:239,322131,601,006101,542,0001,005,0002,371,584
7Jul 28, 2024 21:239,323127,662,412101,552,0001,005,0002,289,664
8Jul 28, 2024 21:239,325125,797,506101,571,0001,005,0002,371,584
9Jul 28, 2024 21:509,327125,151,282102,597,00002,289,664
10Jul 28, 2024 21:239,328126,095,355101,600,0001,005,0002,363,392
11Jul 28, 2024 21:509,337132,649,226101,698,0001,006,0002,289,664
12Jul 28, 2024 21:509,353129,462,915100,890,0001,997,0002,289,664
13Jul 28, 2024 21:509,361128,611,754100,975,0001,999,0002,371,584
14Jul 28, 2024 21:239,361131,590,036101,968,000999,0002,371,584
15Jul 28, 2024 21:509,364133,527,783101,002,0002,000,0002,289,664
16Jul 28, 2024 21:509,370126,671,198101,067,0002,001,0002,285,568
17Jul 28, 2024 21:239,381134,961,097101,185,0002,003,0002,371,584
18Jul 28, 2024 21:239,388131,437,558102,270,0001,002,0002,371,584
19Jul 28, 2024 21:239,417165,241,485103,584,10402,207,744
20Jul 28, 2024 21:239,435172,105,915103,779,94602,203,648
21Jul 28, 2024 21:509,437169,853,741103,807,87402,338,816
22Jul 28, 2024 21:509,457161,981,395104,030,65302,199,552
23Jul 28, 2024 21:509,460160,561,879104,055,12702,199,552
24Jul 28, 2024 21:239,470168,787,673104,171,02802,203,648