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 16:54Yuriy LyfenkoYuriy LyfenkoScore: 8,537Success
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 16:548,530119,256,24790,833,0002,994,0002,334,720
2May 22, 2021 16:548,531120,184,38191,849,0001,996,0002,334,720
3May 22, 2021 16:548,531124,486,67191,849,0001,996,0002,527,232
4May 22, 2021 16:548,533117,435,13690,863,0002,995,0002,531,328
5May 22, 2021 16:548,534123,026,72491,882,0001,997,0002,334,720
6May 22, 2021 16:548,537116,499,55890,911,0002,997,0002,334,720
7May 22, 2021 16:548,537120,145,18390,913,0002,997,0002,334,720
8May 22, 2021 16:548,540155,718,00193,937,94802,203,648
9May 22, 2021 16:548,541147,164,27493,954,54302,174,976
10May 22, 2021 16:548,548118,184,71391,026,0003,000,0002,314,240
11May 22, 2021 16:548,552157,456,55194,070,25602,179,072
12May 22, 2021 16:548,555119,881,31992,103,0002,002,0002,334,720