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 8, 2021 20:08Sergey StreminSergey StreminScore: 14,394Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 8, 2021 20:0914,362181,936,042127,984,00029,996,0002,289,664
2May 8, 2021 20:0914,373184,565,078125,083,00033,021,0002,289,664
3May 8, 2021 20:0414,375181,219,319124,096,00034,026,0002,289,664
4May 8, 2021 20:0814,379177,296,125127,133,00031,032,0002,289,664
5May 8, 2021 20:0414,382184,929,282121,155,00037,047,0002,289,664
6May 8, 2021 20:0414,382180,960,040123,156,00035,044,0002,289,664
7May 8, 2021 20:0914,383180,362,347133,175,00025,033,0002,375,680
8May 8, 2021 20:0814,383182,136,941126,173,00032,044,0002,289,664
9May 8, 2021 20:0814,385178,204,745132,193,00026,038,0002,363,392
10May 8, 2021 20:0814,386186,768,569125,198,00033,052,0002,289,664
11May 8, 2021 20:0914,387182,944,520128,207,00030,048,0002,289,664
12May 8, 2021 20:0414,393178,712,064125,254,00033,067,0002,289,664
13May 8, 2021 20:0914,394181,039,219130,273,00028,058,0002,383,872
14May 8, 2021 20:0414,394176,711,747128,267,00030,062,0002,289,664
15May 8, 2021 20:0814,395179,132,063126,278,00032,070,0002,289,664
16May 8, 2021 20:0414,399180,548,247131,325,00027,067,0002,289,664
17May 8, 2021 20:0814,400182,916,959129,331,00029,074,0002,379,776
18May 8, 2021 20:0914,401180,790,396126,330,00032,083,0002,289,664
19May 8, 2021 20:0814,406180,465,178135,402,00023,068,0002,383,872
20May 8, 2021 20:0414,410184,491,725135,434,00023,073,0002,289,664
21May 8, 2021 20:0414,422185,354,302132,538,00026,105,0002,375,680
22May 8, 2021 20:0914,437188,238,664128,844,00029,963,0002,281,472
23May 8, 2021 20:0814,438185,251,610128,852,00029,965,0002,289,664
24May 8, 2021 20:0814,438188,447,672131,849,00026,969,0002,281,472
25May 8, 2021 20:0414,445185,815,808129,914,00028,980,0002,281,472
26May 8, 2021 20:0914,458187,827,522136,029,00023,005,0002,281,472
27May 8, 2021 20:0914,459194,497,841130,038,00029,008,0002,379,776