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 18, 2024 22:17Joad NacerJoad NacerScore: 7,801Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 18, 2024 22:175,140115,714,94756,544,57802,273,280
2Apr 18, 2024 22:175,150113,834,15256,653,73402,265,088
3Apr 18, 2024 22:175,156122,354,46956,713,69002,273,280
4Apr 18, 2024 22:177,786112,044,51784,637,0001,007,0002,289,664
5Apr 18, 2024 22:177,786114,138,89484,639,0001,007,0002,289,664
6Apr 18, 2024 22:177,800113,783,34483,805,0001,995,0002,289,664
7Apr 18, 2024 22:177,801108,727,21984,816,000997,0002,527,232
8Apr 18, 2024 22:177,802117,152,03185,823,00002,269,184
9Apr 18, 2024 22:177,803109,886,21683,838,0001,996,0002,289,664
10Apr 18, 2024 22:177,803111,860,91784,838,000998,0002,289,664
11Apr 18, 2024 22:177,811111,247,41983,923,0001,998,0002,527,232
12Apr 18, 2024 22:177,815113,274,04882,964,0002,998,0002,289,664