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 22:21Yuriy LyfenkoYuriy LyfenkoScore: 6,395Success
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 22:216,37893,005,87267,152,0003,006,0002,531,328
2May 22, 2021 22:216,37991,239,09068,162,0002,004,0002,535,424
3May 22, 2021 22:216,38892,481,79868,262,0002,007,0002,527,232
4May 22, 2021 22:216,38990,329,99368,268,0002,007,0002,531,328
5May 22, 2021 22:216,39097,355,33268,287,0002,008,0002,531,328
6May 22, 2021 22:216,39393,441,75667,312,0003,013,0002,334,720
7May 22, 2021 22:216,39592,596,35669,345,0001,005,0002,330,624
8May 22, 2021 22:216,39692,635,78667,337,0003,015,0002,527,232
9May 22, 2021 22:216,40498,963,36369,441,0001,006,0002,531,328
10May 22, 2021 22:216,409134,232,43170,495,72602,187,264
11May 22, 2021 22:216,425131,775,66470,669,60602,195,456
12May 22, 2021 22:216,426132,901,21870,689,15702,199,552