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 17, 2021 09:20Andrey TsvetkovAndrey TsvetkovScore: 13,840Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 17, 2021 09:2013,820177,311,933149,016,0003,000,0002,506,752
2Jun 17, 2021 09:2013,824216,928,435152,063,53602,301,952
3Jun 17, 2021 09:2013,831170,431,212150,141,0002,001,0002,322,432
4Jun 17, 2021 09:2013,833221,497,050152,158,15702,301,952
5Jun 17, 2021 09:2013,833173,745,949150,162,0002,002,0002,326,528
6Jun 17, 2021 09:2013,834180,523,840150,177,0002,002,0002,326,528
7Jun 17, 2021 09:2013,840175,141,989149,234,0003,004,0002,322,432
8Jun 17, 2021 09:2013,841174,623,407150,247,0002,003,0002,506,752
9Jun 17, 2021 09:2013,843181,134,401150,274,0002,003,0002,326,528
10Jun 17, 2021 09:2013,850175,730,871151,345,0001,002,0002,322,432
11Jun 17, 2021 09:2013,853217,906,994152,377,54102,174,976
12Jun 17, 2021 09:2013,857173,167,987150,427,0002,005,0002,506,752