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:57Sergey StreminSergey StreminScore: 13,665Success
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:5713,633176,003,080122,971,00026,993,0002,371,584
2May 8, 2021 20:5713,648177,211,832122,107,00028,024,0002,289,664
3May 8, 2021 20:5713,657177,092,711122,182,00028,041,0002,375,680
4May 8, 2021 20:5713,657178,126,139123,184,00027,040,0002,289,664
5May 8, 2021 20:5713,665175,545,693117,246,00033,069,0002,281,472
6May 8, 2021 20:5713,666170,699,200119,257,00031,067,0002,289,664
7May 8, 2021 20:5713,678177,424,633120,363,00030,090,0002,289,664
8May 8, 2021 20:5713,696178,424,780120,523,00030,130,0002,289,664
9May 8, 2021 20:5713,710181,845,189118,854,00031,960,0002,289,664