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 8, 2021 20:43Sergey StreminSergey StreminScore: 15,109Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 8, 2021 20:4315,054194,474,878135,487,00030,108,0002,289,664
2May 8, 2021 20:4315,074192,790,348135,850,00029,966,0002,289,664
3May 8, 2021 20:4315,090184,193,096132,996,00032,999,0002,289,664
4May 8, 2021 20:4315,094189,081,676133,026,00033,006,0002,371,584
5May 8, 2021 20:4315,109185,220,732139,169,00027,032,0002,277,376
6May 8, 2021 20:4315,117189,546,470134,229,00032,054,0002,281,472
7May 8, 2021 20:4315,120187,303,895137,267,00029,056,0002,478,080
8May 8, 2021 20:4315,140190,507,866138,447,00028,090,0002,289,664
9May 8, 2021 20:4315,487196,811,185137,285,00033,068,0002,375,680