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 4, 2021 12:56Yuriy LyfenkoYuriy LyfenkoScore: 5,683Success
Source Code

Source code access is restricted. Log in to request access.

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 4, 2021 12:555,64784,392,64161,115,0001,001,0002,281,472
2May 4, 2021 13:005,65383,729,53660,180,0002,006,0002,281,472
3May 4, 2021 12:555,66085,458,39761,252,0001,004,0002,273,280
4May 4, 2021 13:005,66187,235,78161,263,0001,004,0002,269,184
5May 4, 2021 13:005,66383,323,68859,275,0003,014,0002,277,376
6May 4, 2021 12:555,66387,938,29661,289,0001,004,0002,265,088
7May 4, 2021 12:555,66892,513,39161,346,0001,005,0002,277,376
8May 4, 2021 12:555,67389,011,86361,398,0001,006,0002,281,472
9May 4, 2021 13:005,67491,482,84960,397,0002,013,0002,269,184
10May 4, 2021 13:005,67784,944,73562,442,00002,281,472
11May 4, 2021 13:005,67984,666,58561,461,0001,007,0002,273,280
12May 4, 2021 13:005,68087,265,21261,478,0001,007,0002,273,280
13May 4, 2021 13:005,68285,158,59961,493,0001,008,0002,277,376
14May 4, 2021 13:005,68384,768,49561,506,0001,008,0002,277,376
15May 4, 2021 12:555,68397,765,27560,498,0002,016,0002,523,136
16May 4, 2021 12:555,68688,346,39661,540,0001,008,0002,273,280
17May 4, 2021 12:555,68887,206,48261,564,0001,009,0002,269,184
18May 4, 2021 12:555,69089,350,80461,586,0001,009,0002,359,296
19May 4, 2021 12:565,78288,450,05163,606,00002,289,664
20May 4, 2021 12:565,78890,070,76562,655,0001,010,0002,375,680
21May 4, 2021 12:565,80288,424,77062,827,000997,0002,281,472
22May 4, 2021 12:565,80494,925,96061,847,0001,995,0002,277,376
23May 4, 2021 12:565,80591,459,98961,856,0001,995,0002,273,280
24May 4, 2021 12:565,81689,054,10862,973,000999,0002,281,472
25May 4, 2021 12:565,81889,295,41661,001,0003,000,0002,359,296
26May 4, 2021 12:565,82987,826,94662,114,0002,003,0002,273,280
27May 4, 2021 12:565,83388,883,33262,163,0002,005,0002,347,008