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 listMay 22, 2021 21:56Yuriy LyfenkoYuriy LyfenkoScore: 4,508Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 22, 2021 21:564,47771,910,64148,242,0001,005,0002,265,088
2May 22, 2021 21:564,48478,565,65548,314,0001,006,0002,383,872
3May 22, 2021 21:564,48670,762,92949,346,00002,392,064
4May 22, 2021 21:564,49981,278,26647,507,0001,979,0002,265,088
5May 22, 2021 21:564,50371,543,79248,519,0001,010,0002,396,160
6May 22, 2021 21:564,50474,011,02049,549,00002,392,064
7May 22, 2021 21:564,50880,184,69049,593,00002,392,064
8May 22, 2021 21:564,51275,461,72849,628,00002,527,232
9May 22, 2021 21:564,53077,589,55049,827,00002,400,256
10May 22, 2021 21:564,609117,946,60250,698,18202,228,224
11May 22, 2021 21:564,617121,107,41050,782,76702,244,608
12May 22, 2021 21:564,643113,318,08851,070,16902,244,608