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 listNov 10, 2021 19:40Sergey StreminSergey StreminScore: 5,196Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 10, 2021 19:405,161119,791,95756,770,49602,187,264
2Nov 10, 2021 19:405,186115,714,48457,041,02102,191,360
3Nov 10, 2021 19:405,18684,792,89355,050,0002,001,0002,461,696
4Nov 10, 2021 19:405,18979,322,32255,081,0002,002,0002,367,488
5Nov 10, 2021 19:405,19383,019,34955,117,0002,004,0002,363,392
6Nov 10, 2021 19:405,19478,161,23055,131,0002,004,0002,293,760
7Nov 10, 2021 19:405,19677,942,77856,153,0001,002,0002,367,488
8Nov 10, 2021 19:405,19783,098,53055,158,0002,005,0002,351,104
9Nov 10, 2021 19:405,19782,572,33955,161,0002,005,0002,293,760
10Nov 10, 2021 19:405,21180,883,76456,312,0001,005,0002,457,600
11Nov 10, 2021 19:405,22678,532,76756,477,0001,008,0002,363,392
12Nov 10, 2021 19:405,263113,722,64357,890,87202,203,648