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 listSep 3, 2024 18:56Yuriy LyfenkoYuriy LyfenkoScore: 3,894Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 3, 2024 18:563,82974,780,83140,118,0002,005,0002,269,184
2Sep 3, 2024 18:563,83475,737,70740,167,0002,008,0002,265,088
3Sep 3, 2024 18:563,84673,098,05541,295,0001,007,0002,260,992
4Sep 3, 2024 18:563,87668,892,10241,624,0001,015,0002,392,064
5Sep 3, 2024 18:563,88074,472,67241,666,0001,016,0002,527,232
6Sep 3, 2024 18:563,89465,046,41140,842,0001,992,0002,260,992
7Sep 3, 2024 18:563,89466,479,11340,844,0001,992,0002,400,256
8Sep 3, 2024 18:563,89472,675,86040,837,0001,992,0002,392,064
9Sep 3, 2024 18:563,89468,978,66941,834,000996,0002,387,968
10Sep 3, 2024 18:563,89466,699,98640,844,0001,992,0002,396,160
11Sep 3, 2024 18:563,91268,366,72141,031,0002,001,0002,265,088
12Sep 3, 2024 18:563,91370,001,62541,039,0002,001,0002,265,088