Files
freeCodeCamp/curriculum/challenges/english/10-coding-interview-prep/project-euler/problem-398-cutting-rope.english.md
mrugesh 22afc2a0ca feat(learn): python certification projects (#38216)
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
Co-authored-by: Kristofer Koishigawa <scissorsneedfoodtoo@gmail.com>
Co-authored-by: Beau Carnes <beaucarnes@gmail.com>
2020-05-27 13:19:08 +05:30

1.2 KiB

id, challengeType, isHidden, title, forumTopicId
id challengeType isHidden title forumTopicId
5900f4fa1000cf542c51000d 5 false Problem 398: Cutting rope 302063

Description

Inside a rope of length n, n-1 points are placed with distance 1 from each other and from the endpoints. Among these points, we choose m-1 points at random and cut the rope at these points to create m segments.

Let E(n, m) be the expected length of the second-shortest segment. For example, E(3, 2) = 2 and E(8, 3) = 16/7. Note that if multiple segments have the same shortest length the length of the second-shortest segment is defined as the same as the shortest length.

Find E(107, 100). Give your answer rounded to 5 decimal places behind the decimal point.

Instructions

Tests

tests:
  - text: <code>euler398()</code> should return 2010.59096.
    testString: assert.strictEqual(euler398(), 2010.59096);

Challenge Seed

function euler398() {
  // Good luck!
  return true;
}

euler398();

Solution

// solution required