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 4, 2021 12:59Yuriy LyfenkoYuriy LyfenkoScore: 5,803Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 4, 2021 12:585,64584,968,32661,091,0001,001,0002,277,376
2May 4, 2021 12:585,65382,620,33160,174,0002,005,0002,527,232
3May 4, 2021 12:585,65483,674,42060,193,0002,006,0002,277,376
4May 4, 2021 12:585,66584,169,82061,306,0001,005,0002,281,472
5May 4, 2021 12:585,66687,186,53560,311,0002,010,0002,269,184
6May 4, 2021 12:585,67284,127,50161,383,0001,006,0002,273,280
7May 4, 2021 12:585,67586,488,76761,424,0001,006,0002,273,280
8May 4, 2021 12:585,67891,014,03661,448,0001,007,0002,269,184
9May 4, 2021 12:585,70192,987,56261,696,0001,011,0002,281,472
10May 4, 2021 12:595,77985,828,09962,556,0001,008,0002,277,376
11May 4, 2021 12:575,77988,018,09462,557,0001,008,0002,281,472
12May 4, 2021 12:575,80092,866,43662,808,000996,0002,269,184
13May 4, 2021 12:575,80288,940,01861,827,0001,994,0002,281,472
14May 4, 2021 12:595,80389,385,21159,841,0003,989,0002,281,472
15May 4, 2021 12:575,80394,042,23362,834,000997,0002,281,472
16May 4, 2021 12:595,80488,816,63962,847,000997,0002,277,376
17May 4, 2021 12:595,80496,890,89261,845,0001,995,0002,273,280
18May 4, 2021 12:575,80492,241,39862,849,000997,0002,277,376
19May 4, 2021 12:575,80586,641,32661,864,0001,995,0002,277,376
20May 4, 2021 12:595,80688,299,53061,874,0001,995,0002,273,280
21May 4, 2021 12:595,80887,044,80860,893,0002,994,0002,281,472
22May 4, 2021 12:575,80986,047,19361,904,0001,996,0002,273,280
23May 4, 2021 12:595,81191,165,39860,929,0002,996,0002,375,680
24May 4, 2021 12:575,81186,044,52161,927,0001,997,0002,523,136
25May 4, 2021 12:595,81888,139,66461,994,0001,999,0002,281,472
26May 4, 2021 12:595,82289,090,61962,037,0002,001,0002,281,472
27May 4, 2021 12:575,82986,922,39861,111,0003,005,0002,273,280