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 2, 2021 16:22Yurkov AlekseyYurkov AlekseyScore: 9,284Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 16:219,264125,205,43499,908,0001,998,0002,523,136
2May 2, 2021 16:229,267125,867,28499,944,0001,998,0002,531,328
3May 2, 2021 16:239,273132,087,989100,000,0002,000,0002,277,376
4May 2, 2021 16:239,276128,709,578100,036,0002,000,0002,277,376
5May 2, 2021 16:239,282128,937,37899,098,0003,002,0002,277,376
6May 2, 2021 16:239,282122,885,891100,096,0002,001,0002,531,328
7May 2, 2021 16:229,283125,563,504101,114,0001,001,0002,277,376
8May 2, 2021 16:239,283127,713,31499,105,0003,003,0002,265,088
9May 2, 2021 16:219,283128,489,184101,117,0001,001,0002,273,280
10May 2, 2021 16:219,283124,593,176100,114,0002,002,0002,277,376
11May 2, 2021 16:219,283125,182,205100,109,0002,002,0002,519,040
12May 2, 2021 16:219,283129,259,655100,108,0002,002,0002,527,232
13May 2, 2021 16:239,284124,429,766102,120,00002,273,280
14May 2, 2021 16:229,284124,929,271101,120,0001,001,0002,277,376
15May 2, 2021 16:219,285126,025,393100,138,0002,002,0002,277,376
16May 2, 2021 16:229,285125,841,533100,128,0002,002,0002,277,376
17May 2, 2021 16:219,289140,218,322101,181,0001,001,0002,523,136
18May 2, 2021 16:239,290122,988,023100,182,0002,003,0002,387,968
19May 2, 2021 16:229,292125,512,293100,209,0002,004,0002,383,872
20May 2, 2021 16:229,295122,579,534100,246,0002,004,0002,383,872
21May 2, 2021 16:229,295129,209,568100,238,0002,004,0002,277,376
22May 2, 2021 16:219,295126,057,231100,244,0002,004,0002,527,232
23May 2, 2021 16:239,301124,887,695100,302,0002,006,0002,269,184
24May 2, 2021 16:229,303130,262,232101,326,0001,003,0002,277,376
25May 2, 2021 16:219,311123,472,336100,410,0002,008,0002,527,232
26May 2, 2021 16:229,318123,932,488101,498,0001,004,0002,277,376
27May 2, 2021 16:239,319128,382,505101,505,0001,005,0002,273,280