-1 byte grazie a EriktheOutgolfer (usare 7ŒR
per sostituire -7r7
)
_Ṃị“ b#”
=”B+\Çż
×3⁵+€ịØAḣ7¤ḊḊÇ€Z
7ŒRµṠÑżAW€żÇj€”-UK€Y
Un programma completo che stampa l'output desiderato (usando #
, b
).
Provalo online!
Come?
_Ṃị“ b#” - Link 1, getSharpsFlatsOrSpaces: list of integers
Ṃ - minimum (of the input list)
_ - subtract (from the input list) -- for our purposes this resets whatever our
- 1st value is to 0, since our inputs are always monotonically increasing
“ b#” - literal list of characters = [' ', 'b', '#']
ị - index into (1-based and modular)
=”B+\Çż - Link 2, addSharpsFlatsOrSpaces: list of characters e.g."CFBEADGCFBEADGC"
”B - literal character 'B'
= - equals? (vectorises) [0,0,1,0,0,0,0,0,0,1,0,0,0,0,0]
\ - cumulative reduce with:
+ - addition [0,0,1,1,1,1,1,1,1,2,2,2,2,2,2]
Ç - call the last link (1) as a monad "## bbbbbb"
ż - zip (with input) ["#C","#F"," B"," E",...," F","bB","bE","bA","bD","bG","bC"]
×3⁵+€ịØAḣ7¤ḊḊÇ€Z - link 3, getNoteLetters: list of integers e.g. [-7,-6,...,6,7]
×3 - multiply by three [-21,-18,-15,-12,-9,-6,-3,0,3,6,9,12,15,18,21]
⁵ - literal ten 10
+€ - add for €ach (in [1,10]) [[-20,...,22],[-19,...,23],...,[-11,...31]]
¤ - nilad followed by link(s) as a nilad:
ØA - yield uppercase alphabet "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
ḣ7 - head to index seven "ABCDEFG"
ị - index into ["ADGCFBEADGCFBEA","BEADGCFBEADGCFB","CFBEADGCFBEADGC",...]
Ḋ - dequeue ["BEADGCFBEADGCFB","CFBEADGCFBEADGC","DGCFBEADGCFBEAD",...]
Ḋ - dequeue ["CFBEADGCFBEADGC","DGCFBEADGCFBEAD","EADGCFBEADGCFBE",...]
Ç€ - call the last link(2) as a monad for €ach
- [[["#C","#F"," B"," E",...," F","bB","bE","bA","bD","bG","bC"],...]
Z - transpose [["#C","#D",...,"#C"],["#F",..." B",...,"#F"],...]
7ŒRµṠÑżAW€żÇj€”-UK€Y - Main link: no arguments
7ŒR - absolute range of seven [-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7]
µ - start a new monadic chain (call that r)
Ṡ - sign (of r) [-1,-1,-1,-1,-1,-1,-1,0,1,1,1,1,1,1,1]
Ñ - call the next link (1) as a monad "####### bbbbbbb"
A - absolute value (of r) [7,6,5,4,3,2,1,0,1,2,3,4,5,6,7]
ż - zip [[7,'#'],[6,'#'],...,[0,' '],...,[7,'b']]
W€ - wrap €ach [[[7,'#']],[[6,'#']],...,[[0,' ']],...,[[7,'b']]]
Ç - call the last link (3) as a monad (with r) see link 3 example
ż - zip [[[['#',7]],["#C","#D",...,"#C"]],
[[['#',6]],["#F",...," B",..."#F"]], ...]
”- - literal character '-'
j€ - join for €ach [[['#',7],'-',"#C","#D",..."#C"],
[['#',6],'-',"#F",...," B",..."#F"],...]
U - upend (reverse each) [[[7,'#'],'-',"C#","D#",..."C#"],
[[6,'#'],'-',"F#",...,"B ",..."F#"],...]
K€ - join €ach with spaces [[7+"# - C# D# ... C#"],
[6+"# - F# ... B ... F#"], ...]
Y - join with newlines
- implicit print to STDOUT