The shortest code by character count to output a part of a piano keyboard starting from input note in a given length.
Input will be composed of a note ([ACDFG]#|[A-G]
) to start printing the keyboard from and a positive number representing length of keys to print including the first note.
The first key should be printed in full - if it has a left sharp key, it will be cut, same for when the start key is sharp, the left key will be cut as well.
A Sharp key is not counted, only white keys.
Input
C 14
Output
| ### ### | ### ### ### | ### ### | ### ### ### |
| ### ### | ### ### ### | ### ### | ### ### ### |
| ### ### | ### ### ### | ### ### | ### ### ### |
| ### ### | ### ### ### | ### ### | ### ### ### |
| ### ### | ### ### ### | ### ### | ### ### ### |
| | | | | | | | | | | | | | |
| | | | | | | | | | | | | | |
| | | | | | | | | | | | | | |
|____|____|____|____|____|____|____|____|____|____|____|____|____|____|
Input
D# 1
Output
### |
### |
### |
### |
### |
| |
| |
| |
_|____|
Input
A 7
Output
## ### | ### ### | ### ##
## ### | ### ### | ### ##
## ### | ### ### | ### ##
## ### | ### ### | ### ##
## ### | ### ### | ### ##
| | | | | | | |
| | | | | | | |
| | | | | | | |
|____|____|____|____|____|____|____|
Code count includes input/output (i.e full program).
Fits in one line of #SO without the scroll bar :)
' ':s/~~5*\(7&5*\,.4*@+):k;+):c;9,{5<'#'9**' | '4*+3/4<.1>+c*s.+*k>c<n+}%)s/'_'*
GolfScript - 81 Characters
' ': /((7&\,.4*@5*+:k;\~~5*+):c;9,{5<'#'9**' | '4*+3/4<.1>+c* +*k)>c<n+}%) /'_'*
Nicely formatted version (27 x 3)
' ': /((7&\,.4*@5*+:k;\~~5*
+):c;9,{5<'#'9**' | '4*+3/4
<.1>+9* +*k)>c<n+}%) /'_'*
GolfScript - 82 Characters
' '/((7&\,.4*@5*+:k;\~~5*+):c;9,{5<3*'### '*' | '4*+20<.5>+c*k)>c<n+}%)' '/'_'*
GolfScript - 85 Characters
' '/((7&\,.4*@5*+:k;\~~5*+):c;9,{.5<3*'### '*' _'1/@8=='|'1$3*++4*+20<.5>+c*k)>c<n}%
Nicely formatted version (17 x 5)
' '/((7&\,.4*@5*+
:k;\~~5*+):c;9,{.
5<3*'### '*' _'1
/@8=='|'1$3*++4*+
20<.5>+c*k)>c<n}%
GolfScript - 94 Characters
' ': /~~5*:c;(7&5*:^;,:&;['### '3*' | '+.5>+c*1>{^4&*+>&c+)<n}:f~]5*' _'1/{'|'\4*+7*c*f}%
GolfScript - 98 Characters
' ': /~~5*:c;(7&5*:^;,:&;['### '3*' | '+.5>+c*^4&*+:^)>&c+):&<n]5*[ '_']{['|'\4*+7*c*^>&<n]}%
GolfScript - 101 Characters
' ': /~~5*:c;(7&5*:^;,:&;['### '3*' | '+.5>+c*^4&*+)>&c+)<n]5*[ '_']{['|'\4*+7*c*^4&*+>&c+)<n]}%
GolfScript - 109 Characters
' ': /~~5*:c;(7&5*:^;,:&;['##'' ###'.' | '++.' #'+++c*^4&*+>&c+)<n]5*[ '_']{['|'\4*+7*c*^4&*+>&c+)<n]}%
GolfScript - 120 Characters
' '/~~5*:c;(7&5*:^;,:&;['##'' ###'.' | '++.' #'+++c*^4&*+>&c+)<n]5*['| '7*c*^4&*+>&c+)<n]3*'|____'7*c*^4&*+>&c+)<
GolfScript - 127 Characters
' '/~~5*:c;(7&5*:^;,:&;['## ### ### | ### ### | #'c*^4&*+>&c+)<n]5*['| '7*c*^4&*+>&c+)<n]3*'|____'7*c*^4&*+>&c+)<
$ echo -n C 14 | ruby golfscript.rb piano.gs
| ### ### | ### ### ### | ### ### | ### ### ### |
| ### ### | ### ### ### | ### ### | ### ### ### |
| ### ### | ### ### ### | ### ### | ### ### ### |
| ### ### | ### ### ### | ### ### | ### ### ### |
| ### ### | ### ### ### | ### ### | ### ### ### |
| | | | | | | | | | | | | | |
| | | | | | | | | | | | | | |
| | | | | | | | | | | | | | |
|____|____|____|____|____|____|____|____|____|____|____|____|____|____|
$ echo -n D# 1| ruby golfscript.rb piano.gs
### |
### |
### |
### |
### |
| |
| |
| |
_|____|
$ echo -n A 7| ruby golfscript.rb piano.gs
## ### | ### ### | ### ##
## ### | ### ### | ### ##
## ### | ### ### | ### ##
## ### | ### ### | ### ##
## ### | ### ### | ### ##
| | | | | | | |
| | | | | | | |
| | | | | | | |
|____|____|____|____|____|____|____|