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 listJun 4, 2021 14:55Yurkov AlekseyYurkov AlekseyScore: 6,640Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 4, 2021 14:556,62397,791,06771,856,000998,0002,277,376
2Jun 4, 2021 14:556,63198,000,76070,939,0001,998,0002,527,232
3Jun 4, 2021 14:556,632103,116,87668,956,0003,997,0002,277,376
4Jun 4, 2021 14:556,63594,241,31470,981,0001,999,0002,277,376
5Jun 4, 2021 14:556,638101,308,06670,021,0003,000,0002,277,376
6Jun 4, 2021 14:556,64096,876,68171,036,0002,001,0002,277,376
7Jun 4, 2021 14:556,64093,138,47972,044,0001,000,0002,527,232
8Jun 4, 2021 14:556,649100,475,29070,139,0003,005,0002,277,376
9Jun 4, 2021 14:556,65895,954,77872,239,0001,003,0002,277,376
10Jun 4, 2021 14:557,425142,401,79381,671,89702,256,896
11Jun 4, 2021 14:557,430139,559,01881,725,58102,260,992
12Jun 4, 2021 14:557,482143,600,01782,299,99602,252,800