a problem to solve

mensanator at aol.com mensanator at aol.com
Fri Mar 24 21:27:18 EST 2006


John Salerno wrote:
> mensanator at aol.com wrote:
>
> > You have 4 panels, each with 20 lamps (label them 19 to 0):
> >
> > panel A 00000000000000000000
> > panel B 00000000000000000000
> > panel C 00000000000000000000
> > panel D 00000000000000000000
>
> I'm sorry for being so dense, but I don't understand this. There are
> four panels, yes. Each panel has eight switches, and each switch has 20
> lights. What do you mean when you say that each panel has 20 lamps?

Oh, I see where the confusion is. EACH switch has 20 lamps.

But, since ONLY 1 switch can be on, each panel shows
exactly one pattern of lamps, correct? So we only consider
panel A to have 20 lamps, the 20 that are selected by the switch.

For the purposes of solving the puzzle, we simply want to know
what the pattern is when switch 0 is selected, what the pattern is
when switch 1 is selected, etc. for each of the four panels.

>
> > By the way, I have a program that solves the problem.
> > You said you wanted to do it yourself, so if you need more
> > help, I can walk you through how to solve it.
>
> I already know the solution (I had to cheat to get past this part of the
> game, it was just too frustrating). I was always more interested in the
> actual process of figuring it out via writing a program. You can tell me
> your solution if you want and I can check it.

I also posted it in the other reply, but here it is again:

a[7] b[2] c[5] d[3]

Remember, count from 0, switch 7 is the last switch.

We can manually verify

>>> print gmpy.digits(a[7],2)
11101101111011110101
>>> print gmpy.digits(b[2],2)
11011110011101011111
>>> print gmpy.digits(c[5],2)
10110111101110111110
>>> print gmpy.digits(d[3],2)
1111011110111101011

11101101111011110101
11011110011101011111
10110111101110111110
01111011110111101011

Note that in each column, there is exactly one 0,
which means there is exaclty 3 1's in that column,
therefore, a[7] b[2] c[5] d[3] is a solution.

> This will at least confirm
> that you understand the problem fully and that I'm just being moronic
> when it comes to understanding your explanations. :)

You're not moronic. I have 30 years experience with boolean
algebra and digital logic. I understand what's trivial to me is not
trivial to everyone. But I don't know how much you know and how
much you want to work out yourself. You certainly CAN solve
the problem by the tedious method you initially described. But since
you specifically asked about use bitwise operators, I used that
in my solution.

I didn't want to spoil it for you, but say the word and I'll post my
program code.




More information about the Python-list mailing list