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 20:40Sergey StreminSergey StreminScore: 5,188Success
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 20:405,167118,526,41656,840,53002,195,456
2Nov 10, 2021 20:405,174125,739,93856,909,17702,310,144
3Nov 10, 2021 20:405,18279,369,75155,000,0002,000,0002,359,296
4Nov 10, 2021 20:405,18286,694,29356,001,0001,000,0002,293,760
5Nov 10, 2021 20:405,18287,464,68255,005,0002,000,0002,363,392
6Nov 10, 2021 20:405,18788,164,96456,061,0001,001,0002,293,760
7Nov 10, 2021 20:405,18885,500,48056,068,0001,001,0002,293,760
8Nov 10, 2021 20:405,190122,637,93457,085,72102,203,648
9Nov 10, 2021 20:405,19680,335,01955,150,0002,005,0002,293,760
10Nov 10, 2021 20:405,19883,498,09656,175,0001,003,0002,367,488
11Nov 10, 2021 20:405,19986,162,08555,184,0002,006,0002,293,760
12Nov 10, 2021 20:405,23381,718,98556,557,0001,009,0002,367,488