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 19:09Yuriy LyfenkoYuriy LyfenkoScore: 5,617Success
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 19:095,587605,079,47059,476,0001,982,0002,523,136
2May 19, 2021 19:095,6023,825,100,28959,639,0001,987,0002,260,992
3May 19, 2021 19:095,6081,337,823,18360,689,000994,0002,265,088
4May 19, 2021 19:095,6114,063,882,01659,701,0002,023,0002,260,992
5May 19, 2021 19:095,6124,189,716,65660,734,000995,0002,523,136
6May 19, 2021 19:095,6172,424,051,60361,784,00002,527,232
7May 19, 2021 19:095,6171,267,579,83760,790,000996,0002,527,232
8May 19, 2021 19:095,6192,414,968,87760,815,000996,0002,265,088
9May 19, 2021 19:095,6201,616,159,69360,824,000997,0002,265,088
10May 19, 2021 19:095,887886,659,11364,754,35102,244,608
11May 19, 2021 19:095,8901,256,972,60764,787,86702,248,704
12May 19, 2021 19:095,893155,824,94064,823,98802,252,800