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:38Sergey StreminSergey StreminScore: 6,280Success
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:386,26097,749,85866,865,0001,995,0002,293,760
2Nov 10, 2021 19:386,26195,060,25667,858,0001,012,0002,293,760
3Nov 10, 2021 19:386,26198,614,82466,880,0001,996,0002,363,392
4Nov 10, 2021 19:386,26397,872,14468,894,00002,351,104
5Nov 10, 2021 19:386,269101,802,92766,960,0001,998,0002,293,760
6Nov 10, 2021 19:386,276100,645,99867,036,0002,001,0002,359,296
7Nov 10, 2021 19:386,28098,286,48867,076,0002,002,0002,293,760
8Nov 10, 2021 19:386,28492,913,87268,125,0001,001,0002,359,296
9Nov 10, 2021 19:386,298138,260,00469,281,39702,199,552
10Nov 10, 2021 19:386,299132,808,05369,290,57302,195,456
11Nov 10, 2021 19:386,30092,821,86767,296,0002,008,0002,293,760
12Nov 10, 2021 19:386,308126,752,69569,389,10502,310,144