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:05Joad NacerJoad NacerScore: 7,561Success
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:054,817121,856,50652,987,57802,265,088
2May 8, 2024 00:054,819126,736,53653,013,16202,277,376
3May 8, 2024 00:054,832116,814,25353,156,78302,269,184
4May 8, 2024 00:057,518108,441,57382,697,00002,269,184
5May 8, 2024 00:057,553105,763,74181,081,0002,002,0002,273,280
6May 8, 2024 00:057,557108,725,01382,121,0001,001,0002,289,664
7May 8, 2024 00:057,561107,293,50882,167,0001,002,0002,289,664
8May 8, 2024 00:057,565110,719,81781,215,0002,005,0002,289,664
9May 8, 2024 00:057,571109,103,43082,277,0001,003,0002,289,664
10May 8, 2024 00:057,573113,790,30881,296,0002,007,0002,289,664
11May 8, 2024 00:057,586106,289,94782,440,0001,005,0002,265,088
12May 8, 2024 00:057,622109,652,29682,840,000998,0002,289,664