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 listJun 20, 2021 14:40Andrey TsvetkovAndrey TsvetkovScore: 12,106Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 20, 2021 14:4012,089156,720,836130,985,0001,999,0002,510,848
2Jun 20, 2021 14:4012,091157,269,565130,004,0003,000,0002,326,528
3Jun 20, 2021 14:4012,095159,826,989131,047,0002,000,0002,510,848
4Jun 20, 2021 14:4012,100156,855,718131,098,0002,001,0002,326,528
5Jun 20, 2021 14:4012,102158,829,616131,117,0002,001,0002,322,432
6Jun 20, 2021 14:4012,104155,575,110133,140,00002,510,848
7Jun 20, 2021 14:4012,106197,457,297133,164,32602,174,976
8Jun 20, 2021 14:4012,112190,761,415133,228,80602,174,976
9Jun 20, 2021 14:4012,121160,307,514130,328,0003,007,0002,322,432
10Jun 20, 2021 14:4012,122189,872,922133,338,63302,183,168
11Jun 20, 2021 14:4012,129155,726,625133,423,00002,506,752
12Jun 20, 2021 14:4012,145157,519,542131,583,0002,008,0002,506,752