This challenge is based on a video in which Andrew Huang discusses unusual time signatures...
In it, he advises that you can understand time signatures by dividing them into 3's and 2's. So you count to a small number a few times, instead of counting to a large number.
Here's the pattern he builds which repeats after 19 steps:
- 5 groups of 3
- 2 groups of 2
This is how it looks:
Actually, as you'd play each beat alternatively, the accented beats move from left to right, because there's an odd number of steps. So now this pattern is:
If we reduce this to an algorithm, it can be described like this.
Step 1: where are the accents
- From your number of steps, start by taking groups of 3 from the start until there's 4 or fewer steps remaining.
E.g. for a pattern 8 steps long.
8 steps - take three, 5 steps remaining
5 steps - take 3, 2 steps remaining
Once we're down to 4 steps or fewer, there's 3 possibilities.
- 4 steps - 2 groups of 2
- 3 steps - 1 group of 3
- 2 steps - 1 group of 2
So from our above example:
Step 2: Which hand are the accents on
Let's assume that each individual step will be played on alternate hands, starting with the right.
So for 8 steps, the (underlying) pattern will go
The pattern we output will only tell use which hand the accents are on. With the above example:
That's fine, it's repeatable.
If it's an odd number, you've got the same hand for both the first and last steps, and you can't keep alternating when you repeat the pattern. Instead, the second pattern will be on the other hand. Here's the pattern on an 11 step pattern.
To clarify, if the pattern length is odd, we need to see the repeated, alternated pattern. If the length is even, we only need to see it once.
Hopefully that's clear enough:
- It's code golf, go for the shortest code.
- Your code will accept one pattern, a positive integer higher than 1.
- It will output some text describing a pattern diagram, as described above.
- Any language you like.
- Please include a link to an online interpreter.