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 17, 2023 08:36Kenneth MaplesKenneth MaplesScore: 7,179Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Dec 17, 2023 08:367,143101,814,28178,569,00002,387,968
2Dec 17, 2023 08:367,145107,248,21377,590,0001,007,0002,392,064
3Dec 17, 2023 08:367,155107,787,45178,701,00002,265,088
4Dec 17, 2023 08:367,167105,066,44878,837,00002,383,872
5Dec 17, 2023 08:367,168109,889,87176,849,0001,996,0002,265,088
6Dec 17, 2023 08:367,172104,863,62876,894,0001,997,0002,392,064
7Dec 17, 2023 08:367,179104,624,12576,973,0001,999,0002,527,232
8Dec 17, 2023 08:367,180104,009,71777,979,000999,0002,269,184
9Dec 17, 2023 08:367,187102,240,50578,058,0001,000,0002,392,064
10Dec 17, 2023 08:367,261146,199,20479,874,66502,248,704
11Dec 17, 2023 08:367,284151,100,92080,118,67102,252,800
12Dec 17, 2023 08:367,286142,947,85580,148,95502,244,608