19
1
If you have a small child in your house, you may have come across foam bath letters. These can be moistened and stuck to flat surfaces such as tiles and the side of the bath to make words and messages.
The range of words and messages is somewhat limited if you only have one set though, since you only get 36 characters: uppercase letters A-Z, and digits 0-9: ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
. However, you can be cunning and abuse some of the letters and digits to form extra copies of other letters:
3: E
1: I
7: L (when rotated)
M: W (when rotated)
0: O
2: S (when flipped)
5: S
W: M (when rotated)
2: Z
5: Z (when flipped)
O: 0
6: 9 (when rotated)
L: 7 (when rotated)
9: 6 (when rotated)
Note that these are not all bi-directional, since it tends to be easier to read a digit as part of a word than a letter as part of a number.
Each set also comes in a range of colours, where each letter is coloured in sequence. For example, if your set has 3 colours, Red, Yellow and Blue, your set would be like:
- Red:
ADGJMPSVY147
- Yellow:
BEHKNQTWZ258
- Blue:
CFILORUX0369
Your task, therefore, is to take three parameters (in any suitable way) indicating a word or phrase, the number of colours to be used, and the number of sets you have, then to output a representation of the word or phrase, in a set of suitable colours, making use of substitutions if required. If it is not possible to make the word or phrase given the number of sets, instead output "Nope", in the appropriate colours.
Examples
In all of these, the first parameter is the word or phrase, the second is the number of colours, and the third is the number of sets available.
["bath", 3, 1]
["programming", 3, 2]
["puzzles", 3, 1]
["code golf", 5, 1]
["willow tree", 1, 1]
["impossible phrase", 8, 1]
- there is only 1 P in a set, and no valid substitutions
Notes
- You can default to 1 set if this helps (e.g. a default parameter value of 1), but you must support multiple sets if requested. The number of sets you have will always be a positive non-zero integer.
- If you have multiple sets, they are all coloured in the same way: if A is red in the first set, it will be red in the second set too. The colours are applied per set, not to all sets in a given invocation
- You must support 1 to 36 colours - 1 means all characters are the same colour, 36 means they are all distinct. There will only be integer numbers of colours.
- You can use any colours, as long as they are visually distinct - if you are outputting to terminal, you can use a combination of foreground and background as a "colour", although you must not use the same colour for foreground and background
- Your output must use the characters that you actually use, not the characters from the input. For example, if you had ["willow", 1, 1] as input, you could output
WIL7OM
with 7 and M rotated 180 degrees - You should use the correct letters first, then substitute:
MI7LOW
is incorrect for ["willow", 1, 1] - You can use any substitution for a given character:
SO5
andSO2
with a flipped 2 are both valid for "SOS" - Multiple invocations of your code for the same input do not have to produce identical output
- Output should be in uppercase, but input can be in any mix of upper and lower case
- It should be obvious, but a space does not have a colour
Rules
- This is code golf, but with semi-graphical output (I'm not sure if you can do flipped text in a terminal, but am interested to see if Pyth has a built in for it)
- Standard loopholes apply
- There are no bonuses for functions, but please vote up interesting answers
- Include some screenshots of your output in your answers
Related Challenges
- My Daughter's Alphabet - a partial inverse of this challenge, looking at finding a minimal set of letters to write a range of sentences
- Does a letter fit inside the other? - about a different type of foam letters, but with a similar alternative to letters theme
1What if it's not possible to output "NOPE" given the sets? – Rɪᴋᴇʀ – 2017-12-18T17:43:57.533
@Riker A set contains the 36 given characters. When would it be impossible to output
NOPE
? – mypetlion – 2017-12-18T18:10:48.590@mypetlion when there's no sets... – Rɪᴋᴇʀ – 2017-12-18T18:24:59.723
@Riker Read "The number of sets you have will always be a positive non-zero integer." – mypetlion – 2017-12-18T19:49:19.337
1Foam bath letters are a good introduction to leet speak... – Arnauld – 2017-12-18T21:24:12.940