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 listJan 2, 2024 18:36Yurkov AlekseyYurkov AlekseyScore: 6,477Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jan 2, 2024 18:366,46593,823,95769,116,0002,003,0002,289,664
2Jan 2, 2024 18:366,46697,446,97269,124,0002,003,0002,289,664
3Jan 2, 2024 18:366,46792,314,62869,130,0002,003,0002,289,664
4Jan 2, 2024 18:366,46995,116,68769,152,0002,004,0002,281,472
5Jan 2, 2024 18:366,47293,976,63369,191,0002,005,0002,289,664
6Jan 2, 2024 18:366,47492,880,61070,216,0001,003,0002,273,280
7Jan 2, 2024 18:366,47795,190,44069,239,0002,006,0002,273,280
8Jan 2, 2024 18:366,47892,819,55269,256,0002,007,0002,289,664
9Jan 2, 2024 18:366,48595,593,93769,321,0002,009,0002,289,664
10Jan 2, 2024 18:367,386144,891,79481,248,81102,269,184
11Jan 2, 2024 18:367,392150,455,33481,310,06102,260,992
12Jan 2, 2024 18:367,393147,703,30581,318,82202,273,280