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:07Sergey StreminSergey StreminScore: 14,229Success
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:0714,186179,041,368126,036,00030,008,0002,383,872
2May 8, 2021 20:0714,195177,359,644126,119,00030,028,0002,289,664
3May 8, 2021 20:0714,217177,488,964127,317,00029,072,0002,367,488
4May 8, 2021 20:0714,222179,519,625127,359,00029,081,0002,289,664
5May 8, 2021 20:0714,229182,509,611129,428,00027,089,0002,289,664
6May 8, 2021 20:0714,231177,397,266132,457,00024,083,0002,375,680
7May 8, 2021 20:0714,234186,448,683125,458,00031,113,0002,379,776
8May 8, 2021 20:0714,254193,125,270129,834,00026,965,0002,289,664
9May 8, 2021 20:0714,255186,737,304129,841,00026,967,0002,289,664