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 19:02Yuriy LyfenkoYuriy LyfenkoScore: 4,074Success
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 19:024,04865,846,72243,517,0001,012,0002,396,160
2May 22, 2021 19:024,05169,252,58143,547,0001,012,0002,265,088
3May 22, 2021 19:024,05672,060,55444,617,00002,265,088
4May 22, 2021 19:024,05776,052,96844,627,00002,265,088
5May 22, 2021 19:024,06072,960,34044,664,00002,506,752
6May 22, 2021 19:024,06271,155,37744,677,00002,265,088
7May 22, 2021 19:024,07471,144,20943,819,000995,0002,387,968
8May 22, 2021 19:024,07769,704,22842,850,0001,993,0002,506,752
9May 22, 2021 19:024,08570,866,98142,941,0001,997,0002,383,872
10May 22, 2021 19:024,207102,832,45446,279,52902,232,320
11May 22, 2021 19:024,229118,898,67946,517,45702,236,416
12May 22, 2021 19:024,229110,364,86546,515,65702,236,416