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:31Yurkov AlekseyYurkov AlekseyScore: 6,665Success
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:316,644101,591,14971,083,0002,002,0002,277,376
2Jun 4, 2021 14:316,64795,706,45771,119,0002,003,0002,277,376
3Jun 4, 2021 14:316,64998,691,28970,130,0003,005,0002,527,232
4Jun 4, 2021 14:316,64998,416,17171,139,0002,003,0002,277,376
5Jun 4, 2021 14:316,656100,551,18271,215,0002,006,0002,277,376
6Jun 4, 2021 14:316,664100,958,71970,296,0003,012,0002,277,376
7Jun 4, 2021 14:316,665100,038,57672,306,0001,004,0002,523,136
8Jun 4, 2021 14:316,66794,532,37571,333,0002,009,0002,281,472
9Jun 4, 2021 14:316,68095,135,05672,474,0001,006,0002,273,280
10Jun 4, 2021 14:317,328142,900,40180,608,15202,265,088
11Jun 4, 2021 14:317,344166,091,15980,784,83502,273,280
12Jun 4, 2021 14:317,370140,254,53381,071,40502,265,088