2
\$\begingroup\$

Siteswap is a notation for juggling patterns.

The other siteswap puzzle is great and it explains siteswap in greater detail than here. This puzzle is meant to be a bit simpler! Numberphile recently interviewed Colin Wright which helped develop the notation. The part at ~16min will be useful for this challenge. Another resource which may be useful for wrapping your hear around siteswap if you have not used it before: In your head

Below is the diagram(courtesy of wikipedia) for valid throws with 3 balls and a max height of a throw of 5. A valid siteswap ends at the same position as it started.

siteswap diagram 3 balls max height 5

A valid siteswap for the case we are interested in is defined as follows: In the diagram above choose a starting node and then follow the arrows and write down the number attached to the arrow. If you end up on the same node as you started then the number you have written down is a valid siteswap, otherwise it is not valid.

Challenge

Take a number as input and output a truthy value if it is a valid siteswap for juggling with 3 balls with a max height of 5, otherwise output a falsy value. (No multiplex throws are allowed)

Examples

Input             Output
------------------------
3                  True
3333333333         True
3342               True
441                True
5                  False
225225220          False
332                False
\$\endgroup\$
6
  • 3
    \$\begingroup\$ I've voted to close this as unclear; challenges should provide all the required information rather than linking to other challenges and sites. As it stands, nothing in the challenge defines a valid siteswap nor can a definition be easily inferred from the test cases. In the future, please consider Sandboxing your challenges. \$\endgroup\$ – Shaggy Oct 12 '17 at 12:05
  • \$\begingroup\$ Possible duplicate? Certainly related. \$\endgroup\$ – Engineer Toast Oct 12 '17 at 12:12
  • \$\begingroup\$ @shaggy I hope my edit clarifies it; now the links serve more as additional background rather than primary explanation \$\endgroup\$ – Adam Oct 12 '17 at 12:20
  • 1
    \$\begingroup\$ I think it is pretty clear now (the first 2 paragraph is background information, the next 2 paragraph and the image describe the challenge). Given that we need to compress the graph, this challenge is somewhat like a kolmogorov-complexity one. \$\endgroup\$ – user202729 Oct 12 '17 at 12:56
  • \$\begingroup\$ Can we take the siteswap as a list of numbers instead of a single number? \$\endgroup\$ – 0 ' Oct 12 '17 at 20:24
2
\$\begingroup\$

Python 2, 204 195 188 174 149 144 bytes

lambda s:any(i==reduce(lambda C,c:int('40WW75W5AA47WW07W4WW54A0WWAA70A5WAA123896W'.replace('W','A'*3)[C::11][int(c)],16),s,i)for i in range(10))

Try it online!

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.