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 listNov 10, 2024 19:38Alexander KosachevAlexander KosachevScore: 480,303Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Nov 10, 2024 19:38478,8875,297,657,2415,180,811,00086,946,0002,416,640
2Nov 10, 2024 19:38479,1175,299,150,3745,161,343,000108,943,0002,420,736
3Nov 10, 2024 19:38479,6265,301,865,2145,176,960,00098,922,0002,351,104
4Nov 10, 2024 19:38480,3025,316,199,1975,186,393,00096,932,0002,293,760
5Nov 10, 2024 19:38480,3035,313,862,5135,166,412,000116,918,0002,416,640
6Nov 10, 2024 19:38480,6065,315,588,6165,186,730,00099,936,0002,334,720
7Nov 10, 2024 19:38480,8065,322,032,4335,192,921,00095,943,0002,363,392
8Nov 10, 2024 19:38481,1745,321,940,8125,193,976,00098,942,0002,334,720
9Nov 10, 2024 19:38483,6995,348,518,3455,223,746,00096,939,0002,523,136