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 22:06Andrey TsvetkovAndrey TsvetkovScore: 12,240Success
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 22:0612,205195,403,088134,249,76902,179,072
2Jun 16, 2021 22:0612,218157,623,540131,389,0003,008,0002,379,776
3Jun 16, 2021 22:0612,220159,233,743134,415,00002,498,560
4Jun 16, 2021 22:0612,226190,845,082134,484,37902,183,168
5Jun 16, 2021 22:0612,226156,968,268133,488,0001,003,0002,322,432
6Jun 16, 2021 22:0612,234161,290,863134,573,00002,514,944
7Jun 16, 2021 22:0612,240162,131,745132,636,0002,009,0002,519,040
8Jun 16, 2021 22:0612,243161,956,964134,675,00002,326,528
9Jun 16, 2021 22:0612,248157,480,707131,733,0002,993,0002,330,624
10Jun 16, 2021 22:0612,251195,726,056134,757,94902,179,072
11Jun 16, 2021 22:0612,277161,366,958134,048,0001,000,0002,502,656
12Jun 16, 2021 22:0612,286157,326,446132,145,0003,003,0002,322,432