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 19, 2021 20:28Yuriy LyfenkoYuriy LyfenkoScore: 8,278Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 19, 2021 20:288,2412,796,872,74990,646,66902,248,704
2May 19, 2021 20:288,2483,869,205,57090,723,25302,248,704
3May 19, 2021 20:288,2501,895,599,54490,747,15702,252,800
4May 19, 2021 20:288,2743,056,044,19290,014,0001,000,0002,326,528
5May 19, 2021 20:288,2773,325,275,12389,028,0002,023,0002,322,432
6May 19, 2021 20:288,278337,945,60888,021,0003,035,0002,490,368
7May 19, 2021 20:288,2782,866,422,55689,056,0002,001,0002,326,528
8May 19, 2021 20:288,2804,124,353,40789,081,0002,001,0002,326,528
9May 19, 2021 20:288,282329,823,16589,103,0002,002,0002,494,464
10May 19, 2021 20:288,2872,987,644,35291,161,00002,322,432
11May 19, 2021 20:288,2924,777,903,23189,213,0002,004,0002,322,432
12May 19, 2021 20:288,317990,282,17390,478,0001,005,0002,326,528