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 3, 2021 00:54Yuriy LyfenkoYuriy LyfenkoScore: 5,725Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 3, 2021 01:035,71388,100,66259,855,0002,992,0002,269,184
2May 3, 2021 00:555,71392,045,36061,847,000997,0002,269,184
3May 3, 2021 00:555,71391,910,40960,846,0001,994,0002,273,280
4May 3, 2021 01:035,71591,228,79560,866,0001,995,0002,281,472
5May 3, 2021 00:555,71594,318,10459,868,0002,993,0002,273,280
6May 3, 2021 01:035,71787,715,12360,892,0001,996,0002,281,472
7May 3, 2021 00:555,71884,561,11360,901,0001,996,0002,265,088
8May 3, 2021 00:555,72190,225,81059,931,0002,996,0002,281,472
9May 3, 2021 00:545,72187,102,01660,932,0001,997,0002,273,280
10May 3, 2021 00:545,72184,028,90760,932,0001,997,0002,523,136
11May 3, 2021 01:035,72189,544,82660,929,0001,997,0002,281,472
12May 3, 2021 01:035,72386,588,00761,959,000999,0002,273,280
13May 3, 2021 00:545,72386,067,74260,957,0001,998,0002,281,472
14May 3, 2021 00:545,72588,181,92860,980,0001,999,0002,281,472
15May 3, 2021 01:035,72887,400,19860,006,0003,000,0002,277,376
16May 3, 2021 00:555,72885,287,85661,011,0002,000,0002,281,472
17May 3, 2021 00:545,72985,590,68361,019,0002,000,0002,281,472
18May 3, 2021 01:035,73089,004,63560,033,0003,001,0002,277,376
19May 3, 2021 00:555,73383,740,29762,065,0001,001,0002,273,280
20May 3, 2021 00:555,73491,376,34262,068,0001,001,0002,273,280
21May 3, 2021 00:545,73586,169,18459,082,0004,005,0002,265,088
22May 3, 2021 00:545,73687,302,69062,092,0001,001,0002,281,472
23May 3, 2021 00:555,73685,405,42361,094,0002,003,0002,289,664
24May 3, 2021 01:035,73782,899,33561,102,0002,003,0002,277,376
25May 3, 2021 01:035,73886,198,47561,111,0002,003,0002,269,184
26May 3, 2021 00:545,74485,214,45261,176,0002,005,0002,273,280
27May 3, 2021 00:545,75284,850,37061,265,0002,008,0002,281,472