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:55Yuriy LyfenkoYuriy LyfenkoScore: 5,839Success
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:515,82291,194,47463,045,0001,000,0002,387,968
2May 2, 2021 20:515,82290,728,09863,043,0001,000,0002,396,160
3May 2, 2021 20:515,82397,738,92762,047,0002,001,0002,392,064
4May 2, 2021 20:555,83092,700,79162,127,0002,004,0002,387,968
5May 2, 2021 20:515,83189,846,40063,137,0001,002,0002,379,776
6May 2, 2021 20:515,83288,589,70962,151,0002,004,0002,260,992
7May 2, 2021 20:555,83590,340,37361,180,0003,008,0002,396,160
8May 2, 2021 20:555,83689,174,47462,187,0002,006,0002,383,872
9May 2, 2021 20:515,83688,172,62862,192,0002,006,0002,396,160
10May 2, 2021 20:555,83988,007,80263,229,0001,003,0002,396,160
11May 2, 2021 20:555,83988,584,45961,219,0003,010,0002,260,992
12May 2, 2021 20:515,83992,322,62062,217,0002,007,0002,396,160
13May 2, 2021 20:555,84086,368,71662,228,0002,007,0002,523,136
14May 2, 2021 20:515,84290,351,58762,259,0002,008,0002,392,064
15May 2, 2021 20:555,84686,779,81162,299,0002,009,0002,265,088
16May 2, 2021 20:555,84891,918,89763,321,0001,005,0002,387,968
17May 2, 2021 20:555,85687,269,12263,412,0001,006,0002,392,064
18May 2, 2021 20:515,86392,067,52863,488,0001,007,0002,392,064