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 1, 2021 14:16Andrey TsvetkovAndrey TsvetkovScore: 11,966Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 1, 2021 14:1611,928153,284,56097,155,00034,054,0002,383,872
2May 1, 2021 14:1611,935160,667,779101,224,00030,066,0002,334,720
3May 1, 2021 14:1611,958157,411,317108,448,00023,095,0002,449,408
4May 1, 2021 14:1611,960166,149,076108,464,00023,099,0002,318,336
5May 1, 2021 14:1611,966153,890,569103,496,00028,134,0002,314,240
6May 1, 2021 14:1611,969155,768,98898,496,00033,167,0002,502,656
7May 1, 2021 14:1611,984158,333,27792,878,00038,949,0002,330,624
8May 1, 2021 14:1612,012155,511,862106,103,00026,025,0002,334,720
9May 1, 2021 14:1612,447162,914,700100,941,00035,979,0002,445,312