Statistics

Problem Statement for "RectangleError"

Problem Statement

You want to draw a rectangle on a piece of paper. Unfortunately, you are not a perfect draftsman. The lines you make, although straight, do not always have the correct lengths. The top edge has length in the inclusive range [topMin,topMax], the left edge in the inclusive range [leftMin,leftMax], and the right edge in the inclusive range [rightMin,rightMax]. Fortunately, the left, top and right edges are at right angles to each other and meet (where applicable) at their ends. The bottom edge is made by connecting the bottom end of the left edge to the bottom end of the right edge. Return the maximum length the bottom edge could be minus the minimum length the bottom edge could be.

Definition

Class:
RectangleError
Method:
bottomRange
Parameters:
double, double, double, double, double, double
Returns:
double
Method signature:
double bottomRange(double topMin, double topMax, double leftMin, double leftMax, double rightMin, double rightMax)
(be sure your method is public)

Notes

  • Your return value must have an absolute or relative error less than 1e-9.

Constraints

  • Each input will be between 5 and 100 inclusive.
  • topMin will not be greater than topMax.
  • leftMin will not be greater than leftMax.
  • rightMin will not be greater than rightMax.

Examples

  1. 50

    50

    50

    50

    50

    50

    Returns: 0.0

    A perfect square! The bottom edge will be exactly 50 units long.

  2. 5

    5

    50

    50

    5

    5

    Returns: 0.0

    A perfect trapezoid! Unfortunately, we wanted a rectangle. Nevertheless, the length of the bottom edge is uniquely determined.

  3. 5

    100

    5

    100

    5

    100

    Returns: 132.93114224133723

    Here we drew the rectangle with our eyes closed.

  4. 5

    10

    15

    20

    25

    30

    Returns: 10.95668856545447

  5. 10

    20

    30

    40

    35

    45

    Returns: 15.0

  6. 5

    100

    5

    5

    100

    100

    Returns: 42.79965428913499

  7. 5

    100

    30

    40

    20

    50

    Returns: 96.9803902718557

  8. 5

    100

    10

    20

    9.9

    20.1

    Returns: 95.5087558374891

  9. 5

    100

    10

    20

    5

    15

    Returns: 96.11874208078342

  10. 5

    100

    10

    20

    15

    25

    Returns: 96.11874208078342

  11. 5

    100

    5

    100

    35

    55

    Returns: 114.26860441876563

  12. 21.62787635394736

    88.06831362915001

    31.05485779321522

    51.81222361228292

    21.363892294006522

    92.51167463509292

    Returns: 85.76378161732354

  13. 39.06814667924844

    88.45872996916033

    99.70450503073832

    99.73793276189339

    68.91995725589214

    94.90708395195962

    Returns: 54.311742243332276

  14. 54.5610852661895

    82.71177846800322

    37.35317817545589

    41.12412424026595

    12.04270790272783

    65.90341579784553

    Returns: 33.114265166741596

  15. 89.50711919545883

    97.24180362346246

    48.499483910602024

    78.37882316443766

    77.87979669811544

    81.23365811736666

    Returns: 13.096460337337447

  16. 98.92390412193622

    99.64009229517923

    51.92608462121428

    55.41668347919952

    91.70022666939147

    97.32528861157539

    Returns: 4.127278832007363

  17. 21.91217938814982

    36.5402357378683

    35.663715638575155

    53.0907036491171

    58.41540981768621

    69.64024188588483

    Returns: 27.345964985933012

  18. 13.746896648543652

    69.13734133941556

    41.47066058519723

    42.43134669642308

    43.149211558434594

    92.05595273960496

    Returns: 71.90142432721316

  19. 60.82082540649537

    63.18731462231187

    19.96935944714563

    67.52218540169558

    86.02842256084959

    95.4383336864031

    Returns: 34.854667489342596

  20. 96.58632192270174

    98.57224192217711

    97.34913323909086

    97.48081885559068

    37.76546877725799

    78.14855731621314

    Returns: 16.77304798217952

  21. 85.25525106154966

    98.15109315499039

    61.50034250822331

    79.66459966916123

    28.328180302499472

    34.72280355887021

    Returns: 21.40421801302071

  22. 97.97862959865422

    99.11077548509827

    10.913818577284218

    43.936288657066214

    99.78253470552275

    99.81099073343205

    Returns: 20.360884649407794

  23. 43.45332176920621

    92.91374644155226

    13.499169209498438

    69.11900990626123

    84.76395860611308

    87.95930630009832

    Returns: 72.88443595695584

  24. 47.325773923815966

    87.64192431287344

    6.7508791064663525

    48.423382945037936

    61.007501062582776

    79.096585676222

    Returns: 64.67393148202757

  25. 18.080408694579354

    35.13097112587275

    98.54220457300202

    99.57693549592213

    99.23902590251592

    99.63572429948272

    Returns: 17.067577273881298

  26. 25.527033871611504

    28.140055409331406

    87.13948340062545

    89.48238059946293

    26.80590957286924

    84.72461816150255

    Returns: 43.06272866958859

  27. 18.016617942058257

    85.37601994329985

    71.20480582251675

    85.69089826098303

    32.780152835644486

    82.53892444277959

    Returns: 82.42546369120798

  28. 83.61349793849631

    86.09285351577859

    94.26039240263682

    99.10155705667489

    85.48781273381154

    93.74239295448537

    Returns: 3.5474666816288476

  29. 60.89498580887625

    87.75199997749915

    93.00565732137227

    95.70737117628596

    21.36101660620889

    78.27696268792243

    Returns: 52.36125911350115

  30. 57.612990870226035

    63.02620325133825

    74.45643818541367

    83.10853497450364

    26.54257717863065

    35.47745520503436

    Returns: 15.127545582442863

  31. 28.178484101461457

    38.35718399034421

    86.07883811754083

    98.16456165051977

    36.43394618883376

    55.81247991517766

    Returns: 31.323866952608356

  32. 47.876236364534684

    67.77950920560211

    46.1472783477457

    69.1500146056358

    58.51661511212381

    92.38619433198127

    Returns: 34.173134257972215

  33. 16.70730030508306

    60.81141779582713

    34.712529473709154

    58.86520338663487

    42.71181239324862

    60.00281105563079

    Returns: 49.15336228520315

  34. 21.129127728213533

    26.39839800868007

    19.831758810826518

    71.99857727854824

    34.70619104780323

    68.64952719100239

    Returns: 34.36906978346412

  35. 62.322595253900005

    97.35897762742295

    93.61503605548153

    94.79174803069408

    94.2603772906947

    99.8512457704335

    Returns: 35.23590430542032

  36. 95.58148277361255

    99.71181185207953

    59.973585962687785

    68.09260669156737

    44.24667499039745

    45.32980915764974

    Returns: 5.826785731388085

  37. 12.379029446157139

    66.08130511023631

    23.521628973135986

    67.48628942602573

    16.011241912487332

    52.53705540183462

    Returns: 71.38504042627194

  38. 88.51933652856616

    99.10847808033473

    19.45956512483476

    67.40993750038324

    27.61995206529715

    86.06944982881473

    Returns: 30.8932556369073

  39. 84.69567362352193

    98.3899325726484

    33.53999392692397

    73.08579780298071

    88.38660423054951

    99.88074595833031

    Returns: 32.599559577633784

  40. 96.93568126711857

    97.49852122857762

    77.74441892880645

    96.65136893512756

    89.07345108980586

    89.83621060652791

    Returns: 1.3097922557711001

  41. 80.76340465706748

    87.45956156856943

    65.4474124028693

    84.5548085083563

    77.83929613163696

    78.85525470332597

    Returns: 7.717921875259663

  42. 10.0

    20.0

    30.0

    40.0

    35.0

    45.0

    Returns: 15.0

  43. 10.0

    20.0

    30.5

    40.5

    35.0

    45.0

    Returns: 14.70323865407125

  44. 5.0

    6.0

    5.0

    8.0

    6.0

    9.0

    Returns: 2.2111025509279782

  45. 50.0

    50.0

    20.0

    30.0

    10.0

    40.0

    Returns: 3.851648071345039

  46. 5.0

    99.0

    10.0

    30.0

    14.0

    14.0

    Returns: 95.2845950283492

  47. 5.0

    5.0

    5.0

    5.0

    5.0

    5.4

    Returns: 0.015974481593780787

  48. 34.0

    34.0

    10.0

    100.0

    10.0

    50.0

    Returns: 62.20810776644555

  49. 5.0

    5.0

    7.0

    11.0

    5.0

    9.0

    Returns: 2.810249675906654

  50. 5.0

    5.5

    5.0

    5.0

    5.0

    5.0

    Returns: 0.5

  51. 5.0

    10.0

    10.0

    30.0

    15.0

    20.0

    Returns: 13.027756377319946

  52. 10.0

    10.0

    10.0

    10.0

    5.0

    15.0

    Returns: 1.180339887498949

  53. 5.501

    5.502

    6.5

    6.8

    9.3

    9.9

    Returns: 0.4253331713235111

  54. 10.0

    10.0

    10.1

    10.5

    10.1

    10.5

    Returns: 0.007996802557443061

  55. 10.0

    20.0

    10.0

    40.0

    10.0

    20.0

    Returns: 26.055512754639892

  56. 50.77

    55.77

    60.77

    65.77

    30.77

    35.77

    Returns: 9.251485086534046

  57. 5.0

    100.0

    5.0

    100.0

    5.0

    100.0

    Returns: 132.93114224133723

  58. 5.0

    100.0

    15.0

    15.0

    10.0

    30.0

    Returns: 96.11874208078342

  59. 10.0

    90.0

    10.0

    20.0

    15.0

    25.0

    Returns: 81.2414379544733

  60. 5.0

    100.0

    5.0

    100.0

    10.0

    10.0

    Returns: 129.5362404707371

  61. 10.0

    20.0

    21.92

    24.12

    6.54

    99.23

    Returns: 69.85509438977579

  62. 5.0

    100.0

    10.25

    20.75

    8.95

    15.33339

    Returns: 95.69379325459936

  63. 10.0

    10.0

    10.0

    50.0

    20.0

    30.0

    Returns: 21.622776601683793

  64. 15.5

    90.6

    10.0

    20.0

    30.0

    40.95

    Returns: 77.29473331509253

  65. 5.0

    100.0

    5.0

    100.0

    50.0

    55.0

    Returns: 106.80339887498948

  66. 5.5

    6.0

    5.5

    6.0

    5.5

    6.0

    Returns: 0.5207972893961479

  67. 10.0

    20.0

    40.0

    50.0

    35.0

    55.0

    Returns: 15.0

  68. 5.0

    5.0

    5.0

    25.0

    10.0

    10.0

    Returns: 10.811388300841896

  69. 20.0

    30.0

    10.0

    20.0

    5.0

    30.0

    Returns: 16.055512754639892

  70. 5.0

    10.0

    6.0

    7.0

    5.0

    10.0

    Returns: 5.7703296142690075

  71. 10.0

    10.0

    8.0

    9.0

    7.0

    10.0

    Returns: 0.19803902718556898

  72. 21.0

    21.0

    21.0

    24.0

    22.0

    23.0

    Returns: 0.09502310972898798

  73. 10.0

    20.0

    5.1

    5.2

    5.3

    5.4

    Returns: 10.00174988595111

  74. 5.0

    5.0

    5.0

    5.009

    5.008

    6.0

    Returns: 0.09901951359278449

  75. 5.0

    100.0

    5.0

    100.0

    7.0

    10.0

    Returns: 131.56134152826706

  76. 10.0

    10.0

    20.0

    30.0

    10.0

    40.0

    Returns: 12.360679774997898

  77. 10.0

    10.0

    20.0

    40.0

    30.0

    50.0

    Returns: 21.622776601683793

  78. 5.0

    5.0

    6.0

    6.25

    6.1

    6.2

    Returns: 0.003998401278721531

  79. 5.0

    10.0

    5.0

    15.0

    7.0

    12.0

    Returns: 7.806248474865697

  80. 5.6346

    10.3992

    5.2452

    9.931

    63.9399

    99.9999

    Returns: 41.02161528449964

  81. 10.0

    10.0

    15.0

    25.0

    10.0

    20.0

    Returns: 8.027756377319946


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: