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:21Ilya AniskovetsIlya AniskovetsScore: 8,558Success
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:218,552118,941,28693,075,0001,000,0002,289,664
2Sep 27, 2021 20:218,553119,306,42593,088,0001,000,0002,289,664
3Sep 27, 2021 20:218,554121,103,40592,088,0002,001,0002,289,664
4Sep 27, 2021 20:218,554121,421,08793,091,0001,000,0002,273,280
5Sep 27, 2021 20:218,555117,784,30392,099,0002,002,0002,281,472
6Sep 27, 2021 20:218,555115,413,08093,108,0001,001,0002,289,664
7Sep 27, 2021 20:218,558119,753,92193,135,0001,001,0002,289,664
8Sep 27, 2021 20:218,567116,066,59292,235,0002,005,0002,277,376
9Sep 27, 2021 20:218,575119,646,84992,318,0002,006,0002,277,376
10Sep 27, 2021 20:219,155161,913,914100,707,57202,265,088
11Sep 27, 2021 20:219,164164,648,123100,806,78802,260,992
12Sep 27, 2021 20:219,180160,587,372100,985,01902,265,088