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:41Andrey TsvetkovAndrey TsvetkovScore: 12,387Success
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:4112,352162,847,723134,876,000999,0002,510,848
2Jun 16, 2021 21:4112,365166,104,085134,017,0002,000,0002,322,432
3Jun 16, 2021 21:4112,370162,419,339135,075,0001,000,0002,510,848
4Jun 16, 2021 21:4112,379191,273,019136,171,46102,187,264
5Jun 16, 2021 21:4112,379159,045,540133,169,0003,003,0002,514,944
6Jun 16, 2021 21:4112,384162,219,782134,225,0002,003,0002,514,944
7Jun 16, 2021 21:4112,387197,726,565136,251,53802,183,168
8Jun 16, 2021 21:4112,389202,196,517136,281,87102,179,072
9Jun 16, 2021 21:4112,393160,238,915135,321,0001,002,0002,322,432
10Jun 16, 2021 21:4112,395161,146,080135,347,0001,002,0002,514,944
11Jun 16, 2021 21:4112,403165,713,445136,429,00002,502,656
12Jun 16, 2021 21:4112,409157,773,541135,498,0001,003,0002,326,528