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 14, 2021 18:43Andrey TsvetkovAndrey TsvetkovScore: 9,077Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 14, 2021 18:439,038124,212,17798,415,0001,004,0002,334,720
2Jun 14, 2021 18:439,046121,019,15397,500,0002,010,0002,334,720
3Jun 14, 2021 18:439,051121,810,01498,551,0001,005,0002,326,528
4Jun 14, 2021 18:439,056125,603,76697,608,0002,012,0002,510,848
5Jun 14, 2021 18:439,072161,616,51799,791,13502,301,952
6Jun 14, 2021 18:439,074125,510,63097,815,0001,996,0002,523,136
7Jun 14, 2021 18:439,077127,201,67896,851,0002,995,0002,334,720
8Jun 14, 2021 18:439,077127,044,05898,854,000998,0002,330,624
9Jun 14, 2021 18:439,081127,401,58197,894,0001,997,0002,523,136
10Jun 14, 2021 18:439,086162,153,43099,946,83602,179,072
11Jun 14, 2021 18:439,107152,623,272100,179,39102,179,072
12Jun 14, 2021 18:439,864129,348,944107,503,0001,004,0002,523,136