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 19:16Yuriy LyfenkoYuriy LyfenkoScore: 3,993Success
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 19:163,94766,251,10943,414,00002,387,968
2May 22, 2021 19:163,983117,481,81743,811,82202,232,320
3May 22, 2021 19:163,98574,161,01241,842,0001,992,0002,527,232
4May 22, 2021 19:163,98771,973,70442,842,0001,020,0002,387,968
5May 22, 2021 19:163,98874,192,90841,871,0001,993,0002,265,088
6May 22, 2021 19:163,99068,236,27741,900,0001,995,0002,519,040
7May 22, 2021 19:163,99372,065,47542,921,000998,0002,265,088
8May 22, 2021 19:163,99669,140,35742,962,000999,0002,383,872
9May 22, 2021 19:164,003112,619,99044,036,49102,232,320
10May 22, 2021 19:164,00374,281,73142,035,0002,001,0002,379,776
11May 22, 2021 19:164,00471,209,68643,048,0001,001,0002,527,232
12May 22, 2021 19:164,038112,405,13544,418,38902,236,416