7 kyu

Hanging the curtains

222 of 344Ellude

Description:

Intro:

Imagine that you are given a task to hang a curtain of known length (length) on a window using curtain hooks. It is required of you that the spacing (distance) between each hook is uniform throughout the whole curtain and is lower than or equal to provided distance (max_hook_dist). However you are NOT allowed to use any measuring device or method. How should you do it? How many curtain hooks would you need?

Shorthand:

Given the length of the curtain length and a maximum uniform distance between curtain hooks max_hook_dist write a function that returns the number of curtain hooks required in order to hang a curtain in a described way.

Definitions:

length - The length of the curtain. Always positive.

max_hook_dist - Maximum uniform distance between curtain hooks [1,100] (assume that curtain hooks have no thickness and can be fixed anywhere throughout the curtain). Can be higher than the length of the curtain.

Measuring device/method - Any measuring method or type of a meter (ruler, fingers, etc.) which could be used to measure the distance between the hooks is not allowed. Use maths instead.

P.S. I hope this kata will change the number of curtain hooks you use when hanging your own curtains :)

Puzzles
Mathematics
Algorithms
Logic

Similar Kata:

Stats:

CreatedAug 13, 2019
PublishedAug 14, 2019
Warriors Trained1450
Total Skips44
Total Code Submissions1701
Total Times Completed344
Python Completions222
JavaScript Completions123
Haskell Completions21
COBOL Completions3
Total Stars12
% of votes with a positive feedback rating78% of 109
Total "Very Satisfied" Votes77
Total "Somewhat Satisfied" Votes16
Total "Not Satisfied" Votes16
Total Rank Assessments14
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Ellude Avatar
  • JohanWiltink Avatar
  • Fbasham Avatar
  • user8436785 Avatar
  • akar-0 Avatar
Ad