Free lunch problem

Here is another problem that I found interesting:

  • understand the problem:
if you are part of a group that choose who treat to lunch by sitting in a circle and reciting the natural numbers in a counter-clock wise direction starting with the one sitting at the northern extreme of the circle. friends who utter even numbers are eliminated from the counting (and won't get the free lunch either). the counting continues until all but one person is remaining and this person gets the free lunch. so if there are n friends, where would you choose to sit to get the free lunch?

  • devise a plan:
draw the outcome for a bunch of n values until you notice a pattern.
  • carry out the plan:
here is some values of n that I considered:




observations:
- of course, friends with even numbers get eliminated each round
i.e half of the people get eliminated each round
- when n is odd f1 never gets free lunch since the last number said would be odd = n and f1 would have to say an even number = n+1.
- when n is even, f1 sometimes get free lunch which makes sense since if n is even then half the people get eliminated n/2 can be either even or odd. which takes us back to the starting point (recursion???)

so we can conclude:
 - if dividing n/2 each round will always result in an even number then we should sit at position 1
i.e if n can be written as (2^x)
- if n = (2^x) + y then we should sit at the yth odd number from 1 
so if n = 6 = (2^2) + 2 then we need to sit at the 2nd odd number away from 1 -> 5
i.e. 1+2(y)

here is a python program that would do this for us:

just for fun, I ran this function for n in [1, 50]:
1 -> 1

11 -> 7

21 -> 11

31 -> 31

41 -> 19

2 -> 1

12 -> 9

22 -> 13

32 -> 1

42 -> 21

3 -> 3

13 -> 11

23 -> 15

33 -> 3

43 -> 23

4 -> 1

14 -> 13

24 -> 17

34 -> 5

44 -> 25

5 -> 3

15 -> 15

25 -> 19

35 -> 7

45 -> 27

6 -> 5

16 -> 1

26 -> 21

36 -> 9

46 -> 29

7 -> 7

17 -> 3

27 -> 23

37 -> 11

47 -> 31

8 -> 1

18 -> 5

28 -> 25

38 -> 13

48 -> 33

9 -> 3

19 -> 7

29 -> 27

39 -> 15

49 -> 35

10 -> 5

20 -> 9

30 -> 29

40 -> 17
50 -> 37

No comments:

Post a Comment