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 4, 2021 14:38Yurkov AlekseyYurkov AlekseyScore: 6,687Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 4, 2021 14:386,67894,802,87072,447,0001,006,0002,269,184
2Jun 4, 2021 14:386,67892,520,21572,448,0001,006,0002,277,376
3Jun 4, 2021 14:386,678101,338,48972,456,0001,006,0002,277,376
4Jun 4, 2021 14:386,68094,355,31672,472,0001,006,0002,527,232
5Jun 4, 2021 14:386,68097,978,43772,476,0001,006,0002,531,328
6Jun 4, 2021 14:386,68194,619,81172,487,0001,006,0002,277,376
7Jun 4, 2021 14:386,68799,503,14973,559,00002,277,376
8Jun 4, 2021 14:386,68899,998,56171,554,0002,015,0002,273,280
9Jun 4, 2021 14:386,71499,815,19571,860,0001,996,0002,277,376
10Jun 4, 2021 14:387,399136,451,98081,390,53002,265,088
11Jun 4, 2021 14:387,405143,177,92881,455,39102,265,088
12Jun 4, 2021 14:387,421147,030,12181,630,75302,269,184