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:29Yuriy LyfenkoYuriy LyfenkoScore: 8,278Success
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:308,241727,570,55190,651,01802,244,608
2May 19, 2021 20:308,2441,401,219,15390,684,96802,252,800
3May 19, 2021 20:298,2462,848,177,41290,701,49302,244,608
4May 19, 2021 20:298,2471,816,906,70790,720,31102,252,800
5May 19, 2021 20:298,2481,175,615,37090,732,66202,248,704
6May 19, 2021 20:308,253238,774,90889,764,0001,020,0002,494,464
7May 19, 2021 20:308,2581,033,212,29590,840,50002,248,704
8May 19, 2021 20:308,2601,507,773,06587,868,0002,995,0002,326,528
9May 19, 2021 20:308,2732,315,942,93389,000,0002,000,0002,326,528
10May 19, 2021 20:298,2734,406,048,12588,983,0002,022,0002,326,528
11May 19, 2021 20:308,2761,965,370,98089,037,0002,000,0002,326,528
12May 19, 2021 20:308,2763,517,773,73189,014,0002,023,0002,326,528
13May 19, 2021 20:308,2785,037,229,99589,056,0002,001,0002,326,528
14May 19, 2021 20:298,2791,530,408,86389,063,0002,001,0002,322,432
15May 19, 2021 20:298,2794,651,094,62189,065,0002,001,0002,322,432
16May 19, 2021 20:298,2793,610,189,84389,050,0002,023,0002,322,432
17May 19, 2021 20:298,2822,158,189,69790,106,0001,001,0002,322,432
18May 19, 2021 20:298,2821,263,246,25289,102,0002,002,0002,326,528
19May 19, 2021 20:308,283246,528,22289,089,0002,024,0002,330,624
20May 19, 2021 20:308,2831,586,215,61689,115,0002,002,0002,326,528
21May 19, 2021 20:308,289342,441,42789,175,0002,003,0002,330,624
22May 19, 2021 20:298,2891,656,623,99589,174,0002,003,0002,330,624
23May 19, 2021 20:298,2912,264,864,61389,202,0002,004,0002,322,432
24May 19, 2021 20:298,2981,931,183,19488,268,0003,009,0002,322,432