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 11, 2021 14:37Sergey StreminSergey StreminScore: 8,759Success
Source Code

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

Challenge History

No challenges yet.

Run Statistics
#DateScoreWall TimeCPU UserCPU SystemMemoryError
1May 11, 2021 14:368,718126,362,16069,929,00025,973,0002,289,664
2May 11, 2021 14:378,729115,409,02166,014,00030,006,0002,363,392
3May 11, 2021 14:368,732119,679,79266,038,00030,017,0002,289,664
4May 11, 2021 14:368,733124,982,08564,042,00032,021,0002,289,664
5May 11, 2021 14:378,734123,942,34660,048,00036,029,0002,375,680
6May 11, 2021 14:378,739118,385,06863,086,00033,045,0002,379,776
7May 11, 2021 14:378,740121,164,37569,102,00027,040,0002,379,776
8May 11, 2021 14:378,740122,979,07364,091,00032,045,0002,289,664
9May 11, 2021 14:378,741123,659,19564,101,00032,050,0002,379,776
10May 11, 2021 14:378,742121,661,78963,108,00033,056,0002,383,872
11May 11, 2021 14:378,743120,836,69462,115,00034,063,0002,379,776
12May 11, 2021 14:368,747122,406,39366,147,00030,067,0002,289,664
13May 11, 2021 14:368,755117,241,46366,208,00030,094,0002,375,680
14May 11, 2021 14:378,759120,472,82867,241,00029,104,0002,289,664
15May 11, 2021 14:378,760120,833,91968,257,00028,105,0002,289,664
16May 11, 2021 14:368,769119,666,66665,310,00031,147,0002,289,664
17May 11, 2021 14:378,770120,759,04068,335,00028,138,0002,289,664
18May 11, 2021 14:378,773117,652,80064,334,00032,167,0002,289,664
19May 11, 2021 14:368,773119,812,66867,351,00029,152,0002,289,664
20May 11, 2021 14:378,774117,498,37765,352,00031,167,0002,375,680
21May 11, 2021 14:378,774122,470,51263,335,00033,175,0002,375,680
22May 11, 2021 14:378,784127,187,78767,438,00029,189,0002,289,664
23May 11, 2021 14:378,786125,617,32465,441,00031,210,0002,289,664
24May 11, 2021 14:368,786124,822,11466,442,00030,201,0002,375,680
25May 11, 2021 14:378,790122,773,78466,471,00030,214,0002,371,584
26May 11, 2021 14:368,799125,649,89063,860,00032,928,0002,281,472
27May 11, 2021 14:378,802131,648,18368,876,00027,949,0002,289,664