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 2, 2021 19:02Yurkov AlekseyYurkov AlekseyScore: 6,758Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 19:036,74195,392,73872,148,0002,004,0002,277,376
2May 2, 2021 19:036,741101,953,58373,148,0001,002,0002,531,328
3May 2, 2021 19:026,743102,155,49771,167,0003,007,0002,277,376
4May 2, 2021 19:036,74699,408,44071,203,0003,008,0002,277,376
5May 2, 2021 19:036,746103,194,59671,202,0003,008,0002,523,136
6May 2, 2021 19:036,74895,719,44172,224,0002,006,0002,273,280
7May 2, 2021 19:036,75197,414,21972,252,0002,007,0002,277,376
8May 2, 2021 19:026,75396,507,07573,285,0001,003,0002,273,280
9May 2, 2021 19:026,756101,483,09372,310,0002,008,0002,277,376
10May 2, 2021 19:026,75899,474,29773,334,0001,004,0002,277,376
11May 2, 2021 19:026,76096,239,10373,354,0001,004,0002,273,280
12May 2, 2021 19:036,761100,754,19272,360,0002,010,0002,277,376
13May 2, 2021 19:026,76697,749,26773,419,0001,005,0002,523,136
14May 2, 2021 19:026,76899,442,94773,439,0001,006,0002,277,376
15May 2, 2021 19:026,76998,683,50173,456,0001,006,0002,277,376
16May 2, 2021 19:036,77296,419,69474,494,00002,277,376
17May 2, 2021 19:036,77698,682,25972,519,0002,014,0002,277,376
18May 2, 2021 19:026,80199,033,44971,821,0002,992,0002,277,376