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:45Kenneth MaplesKenneth MaplesScore: 7,667Success
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:457,334143,097,54380,677,30802,244,608
2Dec 28, 2023 04:457,362138,192,11280,982,22102,244,608
3Dec 28, 2023 04:457,383145,180,69681,216,58402,244,608
4Dec 28, 2023 04:457,654111,098,87083,193,0001,002,0002,396,160
5Dec 28, 2023 04:457,657116,165,22182,221,0002,005,0002,269,184
6Dec 28, 2023 04:457,664108,235,18583,298,0001,003,0002,379,776
7Dec 28, 2023 04:457,667107,112,11584,337,00002,387,968
8Dec 28, 2023 04:457,669107,841,70584,363,00002,383,872
9Dec 28, 2023 04:457,675116,870,52184,423,00002,392,064
10Dec 28, 2023 04:457,691116,014,31884,596,00002,269,184
11Dec 28, 2023 04:457,713110,993,26982,846,0001,996,0002,392,064
12Dec 28, 2023 04:457,737107,718,54684,108,0001,001,0002,531,328