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 16, 2021 21:34Andrey TsvetkovAndrey TsvetkovScore: 12,296Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 16, 2021 21:3412,254162,061,072133,796,000998,0002,330,624
2Jun 16, 2021 21:3412,260161,106,145131,861,0002,996,0002,330,624
3Jun 16, 2021 21:3412,262195,506,582134,877,11402,191,360
4Jun 16, 2021 21:3412,279159,165,404132,068,0003,001,0002,326,528
5Jun 16, 2021 21:3412,287157,621,740133,158,0002,002,0002,330,624
6Jun 16, 2021 21:3412,294157,939,000133,229,0002,003,0002,502,656
7Jun 16, 2021 21:3412,296158,590,957133,250,0002,003,0002,314,240
8Jun 16, 2021 21:3412,300157,305,255132,294,0003,006,0002,519,040
9Jun 16, 2021 21:3412,312158,766,443133,429,0002,006,0002,310,144
10Jun 16, 2021 21:3412,315159,047,900133,459,0002,006,0002,314,240
11Jun 16, 2021 21:3412,326199,076,080135,590,41402,187,264
12Jun 16, 2021 21:3412,330199,863,289135,625,07902,183,168