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 11, 2021 06:58Sergey StreminSergey StreminScore: 9,407Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 11, 2021 06:589,377127,352,53264,089,00039,054,0002,375,680
2May 11, 2021 06:589,388129,004,56070,181,00033,085,0002,281,472
3May 11, 2021 06:589,398128,036,63575,274,00028,102,0002,375,680
4May 11, 2021 06:589,401124,349,65275,296,00028,110,0002,371,584
5May 11, 2021 06:589,407124,290,98986,397,00017,078,0002,371,584
6May 11, 2021 06:589,415128,375,61656,309,00047,259,0002,379,776
7May 11, 2021 06:589,416131,711,08060,336,00043,240,0002,281,472
8May 11, 2021 06:589,422129,811,36675,470,00028,175,0002,289,664
9May 11, 2021 06:589,436134,358,38570,859,00032,934,0002,379,776