- understand the problem:
- 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