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 20, 2021 18:49Sergey StreminSergey StreminScore: 8,005Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Jun 20, 2021 18:497,988117,612,82086,871,000998,0002,289,664
2Jun 20, 2021 18:497,991149,708,65287,896,07002,195,456
3Jun 20, 2021 18:497,994118,817,02086,930,000999,0002,371,584
4Jun 20, 2021 18:497,995120,562,91286,951,000999,0002,289,664
5Jun 20, 2021 18:498,001114,150,12986,011,0002,000,0002,289,664
6Jun 20, 2021 18:498,004115,144,05787,045,0001,000,0002,289,664
7Jun 20, 2021 18:498,005160,549,59988,050,70302,207,744
8Jun 20, 2021 18:498,008158,199,07088,085,79202,195,456
9Jun 20, 2021 18:498,009115,668,77587,094,0001,001,0002,367,488
10Jun 20, 2021 18:498,010114,969,86386,106,0002,002,0002,289,664
11Jun 20, 2021 18:498,024114,128,00886,259,0002,006,0002,371,584
12Jun 20, 2021 18:498,025111,734,19886,269,0002,006,0002,289,664