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 22:32Joad NacerJoad NacerScore: 7,716Success
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 22:325,085121,519,33755,934,51602,269,184
2Apr 18, 2024 22:305,086131,441,83655,947,98602,260,992
3Apr 18, 2024 22:305,088113,056,18055,969,34402,269,184
4Apr 18, 2024 22:325,096119,048,76056,058,42202,265,088
5Apr 18, 2024 22:305,100112,199,06456,104,41702,260,992
6Apr 18, 2024 22:325,108112,089,13756,193,01702,265,088
7Apr 18, 2024 22:327,710116,414,78682,814,0001,995,0002,289,664
8Apr 18, 2024 22:327,713115,665,29683,844,000998,0002,289,664
9Apr 18, 2024 22:307,714109,385,82482,861,0001,996,0002,281,472
10Apr 18, 2024 22:327,716108,110,78282,877,0001,997,0002,273,280
11Apr 18, 2024 22:307,716109,415,04882,884,0001,997,0002,289,664
12Apr 18, 2024 22:307,716109,036,36082,875,0001,997,0002,289,664
13Apr 18, 2024 22:327,716105,827,36982,875,0001,997,0002,527,232
14Apr 18, 2024 22:307,717108,831,41182,886,0001,997,0002,289,664
15Apr 18, 2024 22:307,721108,964,13183,934,000999,0002,289,664
16Apr 18, 2024 22:307,722113,498,54483,944,000999,0002,289,664
17Apr 18, 2024 22:307,727107,076,14682,993,0001,999,0002,289,664
18Apr 18, 2024 22:327,727106,339,38582,993,0001,999,0002,289,664
19Apr 18, 2024 22:327,728117,732,98783,007,0002,000,0002,289,664
20Apr 18, 2024 22:327,728109,498,12183,003,0002,000,0002,289,664
21Apr 18, 2024 22:327,733114,892,37985,060,00002,289,664
22Apr 18, 2024 22:307,735109,637,76083,079,0002,001,0002,289,664
23Apr 18, 2024 22:307,736108,918,85584,091,0001,001,0002,273,280
24Apr 18, 2024 22:327,738106,238,40983,118,0002,002,0002,367,488