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 listJun 20, 2021 18:20Sergey StreminSergey StreminScore: 6,063Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 20, 2021 18:206,000120,854,95066,005,11002,207,744
2Jun 20, 2021 18:206,019127,281,73066,204,41802,199,552
3Jun 20, 2021 18:206,020120,660,98766,221,69802,207,744
4Jun 20, 2021 18:206,04689,192,38765,495,0001,007,0002,289,664
5Jun 20, 2021 18:206,04791,999,39166,515,00002,383,872
6Jun 20, 2021 18:206,05989,515,81365,645,0001,009,0002,289,664
7Jun 20, 2021 18:206,06393,174,06965,687,0001,010,0002,289,664
8Jun 20, 2021 18:206,06493,149,18866,708,00002,367,488
9Jun 20, 2021 18:206,06692,396,29964,731,0001,991,0002,289,664
10Jun 20, 2021 18:206,07792,709,62565,853,000997,0002,289,664
11Jun 20, 2021 18:206,07992,270,37566,874,00002,289,664
12Jun 20, 2021 18:206,08797,318,51864,956,0001,998,0002,363,392