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 20, 2025 08:51Aniruddha DebAniruddha DebScore: 5,677Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 20, 2025 08:495,65181,883,08060,154,0002,005,0002,269,184
2Apr 20, 2025 08:545,65487,586,30960,191,0002,006,0002,433,024
3Apr 20, 2025 08:545,65892,673,26561,237,0001,003,0002,433,024
4Apr 20, 2025 08:495,66081,995,55962,261,00002,437,120
5Apr 20, 2025 08:545,66283,924,08161,278,0001,004,0002,428,928
6Apr 20, 2025 08:525,66287,173,98561,281,0001,004,0002,269,184
7Apr 20, 2025 08:495,66488,182,19462,304,00002,531,328
8Apr 20, 2025 08:495,66681,034,14661,320,0001,005,0002,428,928
9Apr 20, 2025 08:515,66885,231,25962,350,00002,269,184
10Apr 20, 2025 08:525,67086,358,88862,366,00002,424,832
11Apr 20, 2025 08:525,67087,619,19561,364,0001,005,0002,433,024
12Apr 20, 2025 08:545,67483,234,02961,410,0001,006,0002,269,184
13Apr 20, 2025 08:495,67590,200,25462,425,00002,531,328
14Apr 20, 2025 08:525,67584,350,24962,428,00002,433,024
15Apr 20, 2025 08:495,67690,382,70162,438,00002,437,120
16Apr 20, 2025 08:545,67794,428,86462,446,00002,531,328
17Apr 20, 2025 08:495,67785,435,41661,438,0001,007,0002,531,328
18Apr 20, 2025 08:495,67883,150,88362,454,00002,531,328
19Apr 20, 2025 08:525,67984,455,96661,458,0001,007,0002,531,328
20Apr 20, 2025 08:525,68085,412,69162,484,00002,269,184
21Apr 20, 2025 08:495,68185,864,59662,486,00002,437,120
22Apr 20, 2025 08:515,68285,340,64161,499,0001,008,0002,531,328
23Apr 20, 2025 08:525,68289,044,42862,503,00002,437,120
24Apr 20, 2025 08:525,68383,557,33062,511,00002,428,928
25Apr 20, 2025 08:545,68383,708,36662,512,00002,531,328
26Apr 20, 2025 08:525,68685,942,31461,534,0001,008,0002,269,184
27Apr 20, 2025 08:525,68985,567,44162,578,00002,531,328
28Apr 20, 2025 08:545,69090,095,51661,578,0001,009,0002,424,832
29Apr 20, 2025 08:525,69086,591,46261,582,0001,009,0002,510,848
30Apr 20, 2025 08:545,69388,786,41562,625,00002,437,120
31Apr 20, 2025 08:545,69385,437,32462,626,00002,428,928
32Apr 20, 2025 08:515,71586,018,75761,863,000997,0002,269,184
33Apr 20, 2025 08:525,73484,617,90662,074,0001,001,0002,531,328