Python Forum
Settle the tourists into their rooms
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Settle the tourists into their rooms
#8
The way I would approach it -
The first two rooms are at the extremes.
Divide the difference by the number of remaining rooms needed + 1 (which is the number of needed intervals).
Choose rooms closest to those points.

Using your example -
First 2 are 3 and 28.
Difference between = 25. 25/3 = 8.33
3+8.33 = 11.33
3+8.33+8.33 = 19.66
Closest to 11.33 is 12
Closest to 19.66 is 21

Alternative is a repetitive process - do as above to get the 12, then get the distance 12 to 28 (16), divide now by 2 (8), add (12+8 = 20), get closest room (21).
Reply


Messages In This Thread
InterstingTask - by Katenn - Sep-30-2020, 10:01 PM
RE: InterstingTask - by Gribouillis - Oct-01-2020, 11:47 AM
RE: InterstingTask - by Katenn - Oct-01-2020, 12:03 PM
RE: InterstingTask - by perfringo - Oct-01-2020, 12:11 PM
RE: InterstingTask - by Gribouillis - Oct-01-2020, 02:04 PM
RE: Settle the tourists into their rooms - by jefsummers - Oct-05-2020, 03:36 PM
Settle the tourists into their rooms - by Katenn - Oct-04-2020, 07:55 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020