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 listApr 20, 2024 14:07Joad NacerJoad NacerError
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1Apr 20, 2024 14:1200000Error: No answer to stdout. Died or killed?
2Apr 20, 2024 14:074,768122,539,95352,442,71402,273,280
3Apr 20, 2024 14:074,775114,187,96952,524,18502,260,992
4Apr 20, 2024 14:074,776117,228,25252,536,35502,260,992
5Apr 20, 2024 14:077,459106,192,14281,053,0001,000,0002,289,664
6Apr 20, 2024 14:077,556106,177,62782,120,0001,001,0002,289,664
7Apr 20, 2024 14:077,557106,746,56582,125,0001,001,0002,519,040
8Apr 20, 2024 14:077,558105,978,74281,134,0002,003,0002,277,376
9Apr 20, 2024 14:077,565113,628,32481,206,0002,005,0002,289,664
10Apr 20, 2024 14:077,575105,027,61681,314,0002,007,0002,289,664
11Apr 20, 2024 14:077,580104,632,12283,375,00002,269,184
12Apr 20, 2024 14:077,581108,176,99383,388,00002,519,040
13Apr 20, 2024 14:077,590111,085,16983,493,00002,289,664