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 listDec 28, 2023 04:47Kenneth MaplesKenneth MaplesScore: 7,665Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 28, 2023 04:477,292137,080,25480,207,64102,236,416
2Dec 28, 2023 04:477,298148,409,69880,278,79802,240,512
3Dec 28, 2023 04:477,341163,198,05680,751,16002,228,224
4Dec 28, 2023 04:477,640107,635,23583,045,0001,000,0002,387,968
5Dec 28, 2023 04:477,653114,686,00682,183,0002,004,0002,269,184
6Dec 28, 2023 04:477,658109,837,58282,228,0002,005,0002,269,184
7Dec 28, 2023 04:477,665108,950,90582,305,0002,007,0002,387,968
8Dec 28, 2023 04:477,666106,373,29884,330,00002,387,968
9Dec 28, 2023 04:477,669105,661,41183,355,0001,004,0002,269,184
10Dec 28, 2023 04:477,669112,848,13284,360,00002,379,776
11Dec 28, 2023 04:477,678113,095,59882,446,0002,010,0002,383,872
12Dec 28, 2023 04:477,719110,506,41083,912,000998,0002,269,184