Problem A: Snapper Chain Solution (Google Code Jam Qualification Round 2010) | LeetCode
Read the question here from GCJ Qualification Round 2010:
» Problem A: Snapper Chain
Once you understand how the snapper works, it is easy. This problem can be solved in various ways, but the main observations are:
Let k be the number of times you snap your finger, n be the light's position, and assume 0 = OFF and 1 = ON.
The configuration of the first five snappers (with the first snapper on the far left side) as k increases are:
00000 k = 0
10000 k = 1
01000 k = 2
11000 k = 3
00100 k = 4
10100 k = 5
01100 k = 6
11100 k = 7
00010 k = 8
Read full article from Problem A: Snapper Chain Solution (Google Code Jam Qualification Round 2010) | LeetCode
No comments:
Post a Comment