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 listNov 10, 2021 20:24Sergey StreminSergey StreminScore: 5,265Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 10, 2021 20:245,23886,200,23857,622,00002,293,760
2Nov 10, 2021 20:255,24584,578,25857,696,00002,359,296
3Nov 10, 2021 20:245,25882,484,51656,838,000997,0002,293,760
4Nov 10, 2021 20:255,25882,507,40457,836,00002,293,760
5Nov 10, 2021 20:255,25886,919,11956,837,000997,0002,293,760
6Nov 10, 2021 20:255,25983,490,88855,857,0001,994,0002,363,392
7Nov 10, 2021 20:245,25986,463,01155,858,0001,994,0002,367,488
8Nov 10, 2021 20:245,25987,554,21955,854,0001,994,0002,355,200
9Nov 10, 2021 20:255,26090,907,60656,860,000997,0002,367,488
10Nov 10, 2021 20:255,26086,800,89355,864,0001,995,0002,293,760
11Nov 10, 2021 20:245,26483,806,27655,905,0001,996,0002,293,760
12Nov 10, 2021 20:245,26488,828,83955,906,0001,996,0002,293,760
13Nov 10, 2021 20:245,26594,472,12055,921,0001,997,0002,293,760
14Nov 10, 2021 20:255,26683,683,97156,926,000998,0002,293,760
15Nov 10, 2021 20:255,27588,890,34756,021,0002,000,0002,367,488
16Nov 10, 2021 20:255,27883,904,74756,055,0002,001,0002,367,488
17Nov 10, 2021 20:245,27878,145,28156,055,0002,001,0002,293,760
18Nov 10, 2021 20:245,28384,598,57956,105,0002,003,0002,293,760
19Nov 10, 2021 20:245,283133,797,12458,109,61902,195,456
20Nov 10, 2021 20:255,284116,521,39058,125,88202,199,552
21Nov 10, 2021 20:255,292129,193,86958,214,39702,195,456
22Nov 10, 2021 20:245,300117,018,51258,297,04102,191,360
23Nov 10, 2021 20:245,315117,514,56358,462,34902,187,264
24Nov 10, 2021 20:255,319148,851,18158,509,90002,260,992