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:29Ilya AniskovetsIlya AniskovetsScore: 11,701Success
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:2911,681154,047,432127,485,0001,003,0002,289,664
2Sep 27, 2021 20:2911,688155,322,122127,565,0001,004,0002,289,664
3Sep 27, 2021 20:2911,688154,279,630127,568,0001,004,0002,289,664
4Sep 27, 2021 20:2911,691167,491,491128,604,00002,289,664
5Sep 27, 2021 20:2911,695156,699,145127,641,0001,005,0002,289,664
6Sep 27, 2021 20:2911,697152,564,423127,664,0001,005,0002,289,664
7Sep 27, 2021 20:2911,701158,342,669126,713,0001,995,0002,289,664
8Sep 27, 2021 20:2911,709154,280,726127,802,000998,0002,269,184
9Sep 27, 2021 20:2911,710168,046,639126,810,0001,997,0002,281,472
10Sep 27, 2021 20:2911,734179,796,365129,078,34902,269,184
11Sep 27, 2021 20:2911,740188,216,998129,139,23902,260,992
12Sep 27, 2021 20:2911,750189,973,506129,249,06402,269,184