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 20:43Yuriy LyfenkoYuriy LyfenkoScore: 5,845Success
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 20:435,81588,570,09660,962,0002,998,0002,387,968
2May 2, 2021 20:435,82090,279,14262,025,0002,000,0002,265,088
3May 2, 2021 20:435,82392,736,44963,057,0001,000,0002,523,136
4May 2, 2021 20:445,82887,798,99062,110,0002,003,0002,260,992
5May 2, 2021 20:445,83091,419,28663,125,0001,001,0002,396,160
6May 2, 2021 20:445,83589,874,30363,188,0001,002,0002,523,136
7May 2, 2021 20:445,83991,145,76063,221,0001,003,0002,514,944
8May 2, 2021 20:445,84289,055,84663,262,0001,004,0002,392,064
9May 2, 2021 20:445,84385,284,03262,269,0002,008,0002,396,160
10May 2, 2021 20:435,84597,263,82664,298,00002,523,136
11May 2, 2021 20:435,84787,825,77964,322,00002,396,160
12May 2, 2021 20:435,84889,870,70863,322,0001,005,0002,392,064
13May 2, 2021 20:435,84887,236,38063,324,0001,005,0002,383,872
14May 2, 2021 20:445,84987,870,37863,335,0001,005,0002,396,160
15May 2, 2021 20:445,85087,654,52363,346,0001,005,0002,392,064
16May 2, 2021 20:435,85085,594,37063,348,0001,005,0002,260,992
17May 2, 2021 20:445,86385,546,23563,483,0001,007,0002,260,992
18May 2, 2021 20:435,86991,114,06464,560,00002,396,160