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:09Andrey TsvetkovAndrey TsvetkovScore: 17,081Success
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:0916,863212,859,093108,285,00077,203,0002,351,104
2May 2, 2021 16:0917,006213,820,332110,040,00077,028,0002,314,240
3May 2, 2021 16:0917,044213,620,401108,280,00079,205,0002,490,368
4May 2, 2021 16:0917,061220,139,563108,809,00078,861,0002,355,200
5May 2, 2021 16:0917,081212,544,257106,936,00080,951,0002,371,584
6May 2, 2021 16:0917,090209,213,213107,994,00079,995,0002,306,048
7May 2, 2021 16:0917,099216,044,292109,054,00079,039,0002,498,560
8May 2, 2021 16:0917,245219,796,785106,829,00082,867,0002,289,664
9May 2, 2021 16:0917,264215,076,229108,946,00080,960,0002,375,680