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:50Sergey StreminSergey StreminScore: 14,942Success
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:5014,910188,299,031138,012,00026,002,0002,359,296
2May 8, 2021 20:5014,915186,956,203136,058,00028,012,0002,367,488
3May 8, 2021 20:5014,933190,916,474138,225,00026,042,0002,289,664
4May 8, 2021 20:5014,939185,919,730133,263,00031,061,0002,289,664
5May 8, 2021 20:5014,942195,439,722134,294,00030,065,0002,289,664
6May 8, 2021 20:5014,945189,029,670137,326,00027,064,0002,367,488
7May 8, 2021 20:5014,958191,579,102137,446,00027,087,0002,359,296
8May 8, 2021 20:5014,983200,233,304133,851,00030,965,0002,289,664
9May 8, 2021 20:5015,257192,692,780136,859,00030,968,0002,371,584