algorithm - Winner of a given game -
alice , bob playing game. have been given n (<50) numbers lie between 1-1000. in 1 turn can either of following
1.decrement number 1.
2.erase 2 numbers , write sum.
number when reached 0 automatically erased. player loses if cannot make of 2 moves. given alice plays first how can tell win game if both play optimally?
can question done if 1 not know game theory algorithms?
i haven't fleshed out full solution, i'm pretty sure can solution without game theory algorithms, reasoning. here useful bits hope on way:
suppose numbers @ start of game x1, x2, x3, ..., xn. note move 1 ever changes total sum of n
numbers. therefore, know in beginning how many times alice , bob make move 1 in total.
however, number of times make move 2 not constant. analyze how many times occur, note move 2 , erasure of 0 terms things decrease how many numbers written. thus, 2 of them occur total of n
times between them, , @ least 1 0 must erased (when last decrement done).
since number of times move 2 done not constant, while number of times move 1 done is constant, driving force behind win can control parity of number of times either of them make move 2. on note:
- assuming know parity of sum of numbers, okay continuing make move 1, , needs have move 2 happen in order win?
- how parity of
n
related above? (note how dynamic changes when makes move 2)
any time 1 of numbers 1, can bet lot of thought go whether or not decrement (and erase 0), or choose 1 of 2 numbers replaced sum. decision directly related above points.
finally, if move "must happen", difference between "making move asap" , "stalling until last possible moment make move"?
Comments
Post a Comment