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 listSep 27, 2021 20:10Ilya AniskovetsIlya AniskovetsScore: 11,642Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Sep 27, 2021 20:1011,600156,043,504127,599,00002,289,664
2Sep 27, 2021 20:1011,608156,258,299127,691,00002,289,664
3Sep 27, 2021 20:1011,627155,704,499126,902,000999,0002,281,472
4Sep 27, 2021 20:1011,633151,258,511125,968,0001,999,0002,289,664
5Sep 27, 2021 20:1011,640151,300,048126,042,0002,000,0002,269,184
6Sep 27, 2021 20:1011,641151,076,154127,055,0001,000,0002,289,664
7Sep 27, 2021 20:1011,642151,376,345126,059,0002,000,0002,273,280
8Sep 27, 2021 20:1011,645155,447,552127,099,0001,000,0002,289,664
9Sep 27, 2021 20:1011,647152,220,906126,117,0002,001,0002,289,664
10Sep 27, 2021 20:1012,234187,298,048134,578,47502,269,184
11Sep 27, 2021 20:1012,250193,029,457134,752,96002,252,800
12Sep 27, 2021 20:1012,256215,470,833134,811,90602,260,992