CombinatoricsDifficulty 5.0AIME, harderFind the answerUnited States
Problem:
A cao [sic] has 6 legs, 3 on each side. A walking pattern for the cao is defined as an ordered sequence of raising and lowering each of the legs exactly once (altogether 12 actions), starting and ending with all legs on the ground. The pattern is safe if at any point, he has at least 3 legs on the ground and not all three legs are on the same side. Estimate N, the number of safe patterns.
An estimate of E>0 earns ⌊20min(N/E,E/N)4⌋ points.
Solution
Solution:
# 1 = on ground, 0 = raised, 2 = back on ground cache = {} def pangzi(legs): if legs == (2,2,2,2,2,2): return 1 elif legs.count(0) > 3: return 0 elif legs[0] + legs[1] + legs[2] == 0: return 0 elif legs[3] + legs[4] + legs[5] == 0: return 0 elif cache.has_key(legs): return cache[legs] cache[legs] = 0 for i in xrange(6): # raise a leg if legs* == 1: new = list(legs) new* = 0 cache[legs] += pangzi(tuple(new)) elif legs* == 0: # lower a leg new = list(legs) new* = 2 cache[legs] += pangzi(tuple(new)) return cache[legs] print pangzi((1,1,1,1,1,1))
Want a route through all this instead of an archive? The track
puts 2,000 problems in a working order, from AMC 10 level to the IMO shortlist.
Source: MathNet,
licensed CC-BY-4.0.
Statement reproduced verbatim; metadata (topic, difficulty) added by this project.