# Hard

1. Jun 4, 2004

### decibel

Hard!!!!!

i cant seem to be able to beat this guy...and to tell u thr truth, i feel like going in my computer screen and punching him in the face, lets see if any of u can get this , cause i certainly cant

http://www.ebaumsworld.com/pearl.shtml

2. Jun 4, 2004

### AKG

There are a couple ways of beating him. You can figure it out on your own if you use some brute force, listing out a bunch of the possibilities at a given stage, and some logic, eliminating some of the many possibilities. Start from the final desired state, and work your way backwards. After going down the "tree" 4 or 5 levels, you'll have a lot of different possibilities to work with, but by then you should be able to see what works and what doesn't. That was my way, there's a nicer, neater, more general way to solve this, and here it goes:

Write the number of pearls in each line in binary, so starting with 3, 4, 5, 6, you have:
0011
0100
0101
0110

Now, add each column up, one column at a time, modulo 2. In other words, at the bottom of each column, write a 1 if there are an odd number of 1s in the column above, and a 0 if there are an even number, like so:

0011
0100
0101
0110
-----
0100

Now, whenever it's your turn, your goal is to always have that "sum" (like 0100 in this case) to be all zeroes. If you remove 4 pearls from the row of 4, 5, or 6, you'll get:

0011
0000
0101
0110

OR

0011
0100
0001
0110

OR

0011
0100
0101
0010

However! This only takes you so far. Once the number of pearls gets small, this approach breaks down. Imagine you've left it with 2 rows, each containing 1:

0000
0000
0001
0001
----
0000

Looks good, right? Wrong. Obviously, that guy will just take 1, leaving you with 1 and you lose.

3. Jun 4, 2004

### TALewis

I hate playing games like that, especially with a computer, because there's probably some algorithm that makes winning trivial for those who know (or who are programmed with) the trick.

4. Jun 4, 2004

### AKG

Yup, once you figure it out, winning is trivial. However, there is some fun in figuring out the algorithm/heuristics that make the winning trivial.

5. Jun 4, 2004

### decibel

i've learnd about binary a few years ago in computer class..but i dont remember it...gotta look thru my notes :D