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 18:50Sergey StreminSergey StreminScore: 5,649Success
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 18:505,64089,121,32460,043,0002,001,0002,367,488
2Nov 10, 2021 18:505,64391,512,10860,071,0002,002,0002,453,504
3Nov 10, 2021 18:505,64683,487,21261,101,0001,001,0002,293,760
4Nov 10, 2021 18:505,64788,313,82960,114,0002,003,0002,359,296
5Nov 10, 2021 18:505,64886,928,17260,122,0002,004,0002,363,392
6Nov 10, 2021 18:505,649115,972,40862,143,98802,314,240
7Nov 10, 2021 18:505,64987,767,99160,131,0002,004,0002,445,312
8Nov 10, 2021 18:505,65085,984,85560,147,0002,004,0002,293,760
9Nov 10, 2021 18:505,65185,017,70960,153,0002,005,0002,367,488
10Nov 10, 2021 18:505,65989,061,33260,243,0002,008,0002,359,296
11Nov 10, 2021 18:505,660123,939,11262,258,94802,187,264
12Nov 10, 2021 18:505,663124,215,34862,293,35702,183,168