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 18:48Yuriy LyfenkoYuriy LyfenkoScore: 4,485Success
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 18:484,40669,403,23047,460,0001,009,0002,265,088
2May 22, 2021 18:484,44278,507,72947,863,000997,0002,523,136
3May 22, 2021 18:484,44677,428,30347,912,000998,0002,527,232
4May 22, 2021 18:484,45875,379,59348,040,0001,000,0002,392,064
5May 22, 2021 18:484,46875,352,03247,142,0002,006,0002,527,232
6May 22, 2021 18:484,48171,608,17048,281,0001,005,0002,387,968
7May 22, 2021 18:484,48578,635,96447,322,0002,013,0002,260,992
8May 22, 2021 18:484,53179,553,86348,848,000996,0002,387,968
9May 22, 2021 18:484,56674,877,14748,213,0002,008,0002,387,968
10May 22, 2021 18:484,705122,658,81051,758,91502,240,512
11May 22, 2021 18:484,710126,300,08951,813,46702,240,512
12May 22, 2021 18:484,739108,079,34052,127,83802,228,224