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 23, 2024 17:48Joad NacerJoad NacerScore: 7,529Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 23, 2024 17:485,137136,366,61656,507,97102,265,088
2Apr 23, 2024 17:485,143116,883,29556,571,75902,269,184
3Apr 23, 2024 17:485,150122,614,25956,653,63202,265,088
4Apr 23, 2024 17:487,513110,196,40881,637,0001,007,0002,269,184
5Apr 23, 2024 17:487,518110,369,80882,695,00002,289,664
6Apr 23, 2024 17:487,526106,533,00380,793,0001,994,0002,289,664
7Apr 23, 2024 17:487,529109,700,93980,821,0001,995,0002,289,664
8Apr 23, 2024 17:487,529109,084,05380,823,0001,995,0002,289,664
9Apr 23, 2024 17:487,529113,149,06980,826,0001,995,0002,289,664
10Apr 23, 2024 17:487,530112,244,64680,834,0001,995,0002,383,872
11Apr 23, 2024 17:487,556111,481,20381,116,0002,002,0002,289,664
12Apr 23, 2024 17:487,558107,388,45581,132,0002,003,0002,289,664