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:33Yurkov AlekseyYurkov AlekseyScore: 6,664Success
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:336,64794,925,20371,118,0002,003,0002,351,104
2Jun 4, 2021 14:336,65095,708,56770,141,0003,006,0002,277,376
3Jun 4, 2021 14:336,650106,161,54171,151,0002,004,0002,531,328
4Jun 4, 2021 14:336,65296,388,31371,165,0002,004,0002,527,232
5Jun 4, 2021 14:336,65794,175,37070,218,0003,009,0002,269,184
6Jun 4, 2021 14:336,66495,130,23771,296,0002,008,0002,269,184
7Jun 4, 2021 14:336,66494,731,72471,300,0002,008,0002,355,200
8Jun 4, 2021 14:336,67097,818,98871,363,0002,010,0002,273,280
9Jun 4, 2021 14:336,67196,130,24271,375,0002,010,0002,269,184
10Jun 4, 2021 14:337,328142,142,77180,611,90802,265,088
11Jun 4, 2021 14:337,341144,533,38780,749,90402,256,896
12Jun 4, 2021 14:337,377135,248,94781,147,42102,269,184