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 2, 2021 16:18Andrey TsvetkovAndrey TsvetkovScore: 12,165Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 2, 2021 16:1812,080158,896,07496,912,00035,967,0002,334,720
2May 2, 2021 16:1912,100156,193,39999,076,00034,026,0002,379,776
3May 2, 2021 16:1812,125163,568,480100,281,00033,093,0002,514,944
4May 2, 2021 16:1912,128157,159,97098,297,00035,106,0002,334,720
5May 2, 2021 16:1812,128155,594,453108,334,00025,077,0002,519,040
6May 2, 2021 16:1912,138159,768,08599,384,00034,131,0002,334,720
7May 2, 2021 16:1912,142167,368,110104,437,00029,121,0002,334,720
8May 2, 2021 16:1912,144163,413,532105,460,00028,122,0002,519,040
9May 2, 2021 16:1812,151159,527,685107,531,00026,129,0002,523,136
10May 2, 2021 16:1912,165161,308,322102,861,00030,958,0002,334,720
11May 2, 2021 16:1812,165161,906,285104,854,00028,959,0002,334,720
12May 2, 2021 16:1812,166159,197,456105,864,00027,964,0002,334,720
13May 2, 2021 16:1912,167160,878,867105,874,00027,966,0002,338,816
14May 2, 2021 16:1812,167163,642,195100,874,00032,958,0002,334,720
15May 2, 2021 16:1912,168161,068,238103,882,00029,966,0002,510,848
16May 2, 2021 16:1812,174156,672,566104,934,00028,982,0002,514,944
17May 2, 2021 16:1812,180161,835,628100,985,00032,995,0002,334,720
18May 2, 2021 16:1912,228152,698,13398,371,00036,136,0002,334,720