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 listApr 19, 2024 00:41Joad NacerJoad NacerScore: 7,864Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 19, 2024 00:414,766106,657,13952,421,32202,269,184
2Apr 19, 2024 00:414,772119,451,56952,489,70902,269,184
3Apr 19, 2024 00:414,788126,293,35452,667,56602,269,184
4Apr 19, 2024 00:417,834112,230,28484,171,0002,004,0002,289,664
5Apr 19, 2024 00:417,836113,273,94184,196,0002,004,0002,289,664
6Apr 19, 2024 00:417,861112,338,96886,467,00002,289,664
7Apr 19, 2024 00:417,864109,423,35185,501,0001,005,0002,289,664
8Apr 19, 2024 00:417,918109,735,18085,093,0002,002,0002,289,664
9Apr 19, 2024 00:417,941110,585,04687,356,00002,289,664
10Apr 19, 2024 00:417,964112,018,62786,602,0001,007,0002,289,664
11Apr 19, 2024 00:417,969113,015,22186,648,0001,007,0002,531,328
12Apr 19, 2024 00:417,971109,510,91786,673,0001,007,0002,289,664