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 listMay 22, 2021 22:29Yuriy LyfenkoYuriy LyfenkoScore: 6,314Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 22, 2021 22:296,28789,947,73367,156,0002,004,0002,334,720
2May 22, 2021 22:296,28892,441,72367,162,0002,004,0002,523,136
3May 22, 2021 22:296,30089,589,70766,283,0003,012,0002,334,720
4May 22, 2021 22:296,30396,090,09166,314,0003,014,0002,334,720
5May 22, 2021 22:296,31191,242,93766,399,0003,018,0002,318,336
6May 22, 2021 22:296,31192,366,45267,409,0002,012,0002,334,720
7May 22, 2021 22:296,314122,330,79469,457,32902,183,168
8May 22, 2021 22:296,31794,663,71868,477,0001,007,0002,334,720
9May 22, 2021 22:296,31993,958,31368,498,0001,007,0002,527,232
10May 22, 2021 22:296,32090,308,63668,508,0001,007,0002,334,720
11May 22, 2021 22:296,335133,426,12269,684,97902,191,360
12May 22, 2021 22:296,345134,122,14069,791,01502,183,168