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, 2024 17:40Joad NacerJoad NacerScore: 4,996Success
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, 2024 17:384,978131,049,21854,753,91202,273,280
2Apr 20, 2024 17:404,983140,757,54254,812,37502,260,992
3Apr 20, 2024 17:384,98381,644,04952,824,0001,993,0002,289,664
4Apr 20, 2024 17:384,984115,824,71254,819,06702,277,376
5Apr 20, 2024 17:404,98480,871,92153,827,000996,0002,383,872
6Apr 20, 2024 17:404,98481,818,01652,835,0001,993,0002,289,664
7Apr 20, 2024 17:384,98878,572,53852,876,0001,995,0002,527,232
8Apr 20, 2024 17:404,99082,051,43552,891,0001,995,0002,289,664
9Apr 20, 2024 17:384,99076,510,15052,893,0001,995,0002,269,184
10Apr 20, 2024 17:384,991130,268,88054,905,02702,269,184
11Apr 20, 2024 17:404,991122,007,11854,904,30502,265,088
12Apr 20, 2024 17:404,99483,321,40252,934,0001,997,0002,289,664
13Apr 20, 2024 17:384,99681,254,74753,959,000999,0002,523,136
14Apr 20, 2024 17:384,99683,204,72152,954,0001,998,0002,289,664
15Apr 20, 2024 17:404,99778,848,02552,966,0001,998,0002,289,664
16Apr 20, 2024 17:404,99778,499,34953,964,000999,0002,289,664
17Apr 20, 2024 17:404,998116,824,08354,977,36702,277,376
18Apr 20, 2024 17:385,00078,565,69553,003,0002,000,0002,289,664
19Apr 20, 2024 17:385,00182,222,13453,013,0002,000,0002,371,584
20Apr 20, 2024 17:405,00377,742,97953,034,0002,001,0002,289,664
21Apr 20, 2024 17:405,00678,968,89653,060,0002,002,0002,387,968
22Apr 20, 2024 17:385,00676,727,61253,059,0002,002,0002,289,664
23Apr 20, 2024 17:385,00981,744,94453,101,0002,003,0002,531,328
24Apr 20, 2024 17:405,01877,961,19253,189,0002,007,0002,289,664