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 20:48Yuriy LyfenkoYuriy LyfenkoScore: 8,245Success
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 20:488,194158,761,61690,138,24002,199,552
2May 19, 2021 20:488,198153,224,34190,175,81802,199,552
3May 19, 2021 20:568,201164,165,50690,215,05502,195,456
4May 19, 2021 20:488,211139,735,04690,318,55102,195,456
5May 19, 2021 20:568,212141,327,44090,329,91402,191,360
6May 19, 2021 20:568,225150,974,75990,472,27802,191,360
7May 19, 2021 20:488,231113,986,84688,532,0002,012,0002,531,328
8May 19, 2021 20:568,236122,975,56190,598,00002,330,624
9May 19, 2021 20:568,238113,349,57588,603,0002,013,0002,531,328
10May 19, 2021 20:488,241115,500,72889,639,0001,007,0002,531,328
11May 19, 2021 20:568,242113,982,58490,667,00002,523,136
12May 19, 2021 20:568,245121,279,83389,690,0001,007,0002,330,624
13May 19, 2021 20:488,245120,955,02988,683,0002,015,0002,527,232
14May 19, 2021 20:568,245118,137,60988,682,0002,015,0002,330,624
15May 19, 2021 20:488,246116,990,60389,698,0001,007,0002,523,136
16May 19, 2021 20:488,256117,263,96687,820,0002,993,0002,531,328
17May 19, 2021 20:488,258122,587,70188,842,0001,996,0002,523,136
18May 19, 2021 20:488,258121,033,69987,847,0002,994,0002,334,720
19May 19, 2021 20:568,258117,753,51888,846,0001,996,0002,527,232
20May 19, 2021 20:568,258114,414,29588,843,0001,996,0002,326,528
21May 19, 2021 20:488,259117,267,63989,852,000998,0002,531,328
22May 19, 2021 20:568,261116,492,27687,875,0002,995,0002,527,232
23May 19, 2021 20:568,263119,423,49688,894,0001,997,0002,527,232
24May 19, 2021 20:488,278118,462,02388,052,0003,001,0002,531,328