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 listApr 18, 2024 23:43Joad NacerJoad NacerScore: 7,513Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 18, 2024 23:434,982116,921,55454,801,48602,265,088
2Apr 18, 2024 23:184,984119,992,43254,825,57002,273,280
3Apr 18, 2024 23:184,985135,206,15654,830,60302,273,280
4Apr 18, 2024 23:434,985122,045,00554,835,38202,269,184
5Apr 18, 2024 23:435,000108,537,71154,998,93002,260,992
6Apr 18, 2024 23:185,003126,655,36855,031,53902,265,088
7Apr 18, 2024 23:187,506112,224,03781,565,0001,006,0002,289,664
8Apr 18, 2024 23:187,506108,933,81081,561,0001,006,0002,273,280
9Apr 18, 2024 23:187,508108,350,56881,581,0001,007,0002,289,664
10Apr 18, 2024 23:437,509112,483,23181,588,0001,007,0002,273,280
11Apr 18, 2024 23:187,511112,625,12981,618,0001,007,0002,269,184
12Apr 18, 2024 23:437,512107,248,74081,625,0001,007,0002,531,328
13Apr 18, 2024 23:187,513109,404,93681,634,0001,007,0002,273,280
14Apr 18, 2024 23:187,514111,113,80982,659,00002,289,664
15Apr 18, 2024 23:437,514106,776,83881,645,0001,007,0002,289,664
16Apr 18, 2024 23:187,515108,940,34182,665,00002,273,280
17Apr 18, 2024 23:437,516112,491,38982,676,00002,289,664
18Apr 18, 2024 23:437,517111,853,30582,688,00002,281,472
19Apr 18, 2024 23:437,517108,628,97781,678,0001,008,0002,527,232
20Apr 18, 2024 23:437,530111,595,40181,835,000997,0002,289,664
21Apr 18, 2024 23:187,531108,729,44880,841,0001,996,0002,289,664
22Apr 18, 2024 23:437,533107,899,49980,863,0001,996,0002,289,664
23Apr 18, 2024 23:437,539111,564,17280,933,0001,998,0002,289,664
24Apr 18, 2024 23:187,747110,237,83384,213,0001,002,0002,289,664