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 24, 2021 19:29Yuriy LyfenkoYuriy LyfenkoScore: 3,862Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 24, 2021 19:293,81071,270,44939,919,0001,995,0002,527,232
2May 24, 2021 19:293,82572,099,45140,069,0002,003,0002,527,232
3May 24, 2021 19:293,83974,406,28140,220,0002,011,0002,265,088
4May 24, 2021 19:293,84064,497,32041,231,0001,005,0002,506,752
5May 24, 2021 19:293,85771,694,19541,420,0001,010,0002,392,064
6May 24, 2021 19:293,85863,001,27042,434,00002,392,064
7May 24, 2021 19:293,86262,862,41841,470,0001,011,0002,506,752
8May 24, 2021 19:293,86465,117,43442,508,00002,506,752
9May 24, 2021 19:293,87269,538,98742,596,00002,400,256
10May 24, 2021 19:294,05887,872,31544,641,64302,232,320
11May 24, 2021 19:294,06891,892,58244,743,96302,236,416
12May 24, 2021 19:294,100116,489,01445,102,54902,236,416