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 5, 2021 09:08Yurkov AlekseyYurkov AlekseyScore: 6,853Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 5, 2021 09:106,82897,801,35273,109,0002,002,0002,277,376
2May 5, 2021 09:086,82999,396,88873,111,0002,003,0002,523,136
3May 5, 2021 09:106,83198,255,19774,140,0001,001,0002,265,088
4May 5, 2021 09:106,83298,367,97073,146,0002,004,0002,523,136
5May 5, 2021 09:086,84297,993,35973,253,0002,006,0002,269,184
6May 5, 2021 09:106,84697,011,11174,302,0001,004,0002,277,376
7May 5, 2021 09:086,84698,185,19973,299,0002,008,0002,371,584
8May 5, 2021 09:106,85199,501,77474,355,0001,004,0002,281,472
9May 5, 2021 09:106,85296,491,39874,368,0001,004,0002,277,376
10May 5, 2021 09:106,85396,745,96574,378,0001,005,0002,277,376
11May 5, 2021 09:106,855101,640,28373,391,0002,010,0002,277,376
12May 5, 2021 09:086,85799,324,66272,409,0003,017,0002,531,328
13May 5, 2021 09:086,86099,381,07674,458,0001,006,0002,281,472
14May 5, 2021 09:086,86198,254,35173,461,0002,012,0002,273,280
15May 5, 2021 09:086,86596,927,38374,508,0001,006,0002,277,376
16May 5, 2021 09:086,867102,151,90573,549,0001,987,0002,523,136
17May 5, 2021 09:086,872102,138,57575,588,00002,531,328
18May 5, 2021 09:106,873108,230,68675,603,00002,265,088