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 1, 2021 13:09Andrey TsvetkovAndrey TsvetkovScore: 12,439Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 1, 2021 13:2912,386163,846,568107,194,00029,052,0002,334,720
2May 1, 2021 13:1212,391159,469,625105,235,00031,069,0002,334,720
3May 1, 2021 13:2912,397160,910,153105,287,00031,084,0002,334,720
4May 1, 2021 13:2912,401159,149,883105,316,00031,093,0002,334,720
5May 1, 2021 13:0912,408159,793,831108,390,00028,101,0002,314,240
6May 1, 2021 13:1212,410158,309,285109,411,00027,101,0002,334,720
7May 1, 2021 13:1212,411161,522,387105,406,00031,119,0002,334,720
8May 1, 2021 13:1212,411156,452,735110,424,00026,100,0002,310,144
9May 1, 2021 13:1212,418165,001,247113,497,00023,101,0002,314,240
10May 1, 2021 13:0912,420164,766,441105,480,00031,141,0002,314,240
11May 1, 2021 13:2912,432167,356,956104,813,00031,943,0002,334,720
12May 1, 2021 13:1212,436161,565,950101,846,00034,947,0002,310,144
13May 1, 2021 13:2912,439162,699,821109,867,00026,967,0002,322,432
14May 1, 2021 13:2912,439164,864,848105,871,00030,962,0002,334,720
15May 1, 2021 13:1212,439161,245,693103,871,00032,959,0002,318,336
16May 1, 2021 13:2912,440165,821,99797,883,00038,953,0002,334,720
17May 1, 2021 13:2912,443166,301,365100,908,00035,967,0002,334,720
18May 1, 2021 13:0912,443162,088,175103,902,00032,969,0002,334,720
19May 1, 2021 13:0912,449162,548,345102,955,00033,985,0002,334,720
20May 1, 2021 13:1212,451163,844,742108,968,00027,991,0002,334,720
21May 1, 2021 13:2912,454164,458,999111,999,00024,999,0002,322,432
22May 1, 2021 13:0912,454161,081,219107,993,00028,998,0002,453,504
23May 1, 2021 13:0912,465159,361,489106,088,00031,025,0002,318,336
24May 1, 2021 13:0912,467157,059,242107,106,00030,029,0002,449,408
25May 1, 2021 13:0912,483160,103,571106,240,00031,070,0002,334,720
26May 1, 2021 13:0912,501161,092,191106,397,00031,116,0002,334,720
27May 1, 2021 13:1212,582161,283,966113,333,00025,073,0002,334,720