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 listMay 22, 2021 17:20Yuriy LyfenkoYuriy LyfenkoScore: 6,280Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 22, 2021 17:206,26091,097,52466,863,0001,995,0002,330,624
2May 22, 2021 17:206,26598,157,24866,919,0001,997,0002,334,720
3May 22, 2021 17:206,266100,430,04666,933,0001,998,0002,531,328
4May 22, 2021 17:206,26792,805,95565,938,0002,997,0002,527,232
5May 22, 2021 17:206,273103,080,85567,004,0002,000,0002,326,528
6May 22, 2021 17:206,27893,522,73766,056,0003,002,0002,531,328
7May 22, 2021 17:206,28093,773,59767,076,0002,002,0002,523,136
8May 22, 2021 17:206,28497,103,93866,124,0003,005,0002,334,720
9May 22, 2021 17:206,28593,934,67566,127,0003,005,0002,334,720
10May 22, 2021 17:206,296124,837,43969,251,96402,183,168
11May 22, 2021 17:206,304127,469,82869,348,68402,187,264
12May 22, 2021 17:206,311135,888,51369,417,65402,195,456