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, 2024 00:19Joad NacerJoad NacerScore: 7,553Success
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, 2024 00:194,866129,831,01753,523,64402,256,896
2May 8, 2024 00:194,876131,253,80453,639,74802,265,088
3May 8, 2024 00:194,878107,534,26553,662,69502,269,184
4May 8, 2024 00:197,539105,620,78680,933,0001,998,0002,273,280
5May 8, 2024 00:197,542106,029,69281,968,000999,0002,523,136
6May 8, 2024 00:197,548106,654,41682,031,0001,000,0002,531,328
7May 8, 2024 00:197,553104,551,32981,079,0002,001,0002,289,664
8May 8, 2024 00:197,555107,848,63382,100,0001,001,0002,289,664
9May 8, 2024 00:197,556106,759,47281,113,0002,002,0002,289,664
10May 8, 2024 00:197,557107,927,19481,120,0002,002,0002,265,088
11May 8, 2024 00:197,560110,719,19781,154,0002,003,0002,289,664
12May 8, 2024 00:197,571112,322,95281,274,0002,006,0002,269,184