Make a Bowl of Alphabet Soup
$begingroup$
This is what we'll call a bowl of alphabet soup - a roughly circular ascii-art shape with the 26 uppercase English letters (A-Z) arranged clockwise to form the perimeter:
XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK
Write a program that takes in a single letter character, A-Z, and outputs that same bowl of alphabet soup "rotated", so to speak, so the input letter appears where the A
does in the example above and the rest of the alphabet cycles fully around clockwise.
So the output for input A
would be that same original bowl of alphabet soup.
And the output for input B
would be this one:
YZABCD
WX EF
V G
U H
T I
SR KJ
QPONML
Likewise the output for H
would be:
EFGHIJ
CD KL
B M
A N
Z O
YX QP
WVUTSR
Or for Z
:
WXYZAB
UV CD
T E
S F
R G
QP IH
ONMLKJ
This needs to work for all 26 letters, A through Z.
Details:
- You can assume the only input will be a single letter, A through Z.
- If convenient you may use lowercase a-z for input and/or output, you can even mix and match lower and uppercase.
- The alphabet order must cycle clockwise, not counter-clockwise.
- You must use spaces, not something else, to indent and fill the soup bowl.
- There may be leading or trailing newlines or spaces in the output as long as the soup bowl is arranged properly.
- Note that the bowl shape is 12 characters wide by 7 tall to make it appear roughly circular as text. Your bowls need to be the same shape.
This is code golf so the shortest code wins!
code-golf string ascii-art
New contributor
$endgroup$
add a comment |
$begingroup$
This is what we'll call a bowl of alphabet soup - a roughly circular ascii-art shape with the 26 uppercase English letters (A-Z) arranged clockwise to form the perimeter:
XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK
Write a program that takes in a single letter character, A-Z, and outputs that same bowl of alphabet soup "rotated", so to speak, so the input letter appears where the A
does in the example above and the rest of the alphabet cycles fully around clockwise.
So the output for input A
would be that same original bowl of alphabet soup.
And the output for input B
would be this one:
YZABCD
WX EF
V G
U H
T I
SR KJ
QPONML
Likewise the output for H
would be:
EFGHIJ
CD KL
B M
A N
Z O
YX QP
WVUTSR
Or for Z
:
WXYZAB
UV CD
T E
S F
R G
QP IH
ONMLKJ
This needs to work for all 26 letters, A through Z.
Details:
- You can assume the only input will be a single letter, A through Z.
- If convenient you may use lowercase a-z for input and/or output, you can even mix and match lower and uppercase.
- The alphabet order must cycle clockwise, not counter-clockwise.
- You must use spaces, not something else, to indent and fill the soup bowl.
- There may be leading or trailing newlines or spaces in the output as long as the soup bowl is arranged properly.
- Note that the bowl shape is 12 characters wide by 7 tall to make it appear roughly circular as text. Your bowls need to be the same shape.
This is code golf so the shortest code wins!
code-golf string ascii-art
New contributor
$endgroup$
12
$begingroup$
Great challenge! It initially seems easy, but it's not
$endgroup$
– Luis Mendo
Mar 19 at 21:56
add a comment |
$begingroup$
This is what we'll call a bowl of alphabet soup - a roughly circular ascii-art shape with the 26 uppercase English letters (A-Z) arranged clockwise to form the perimeter:
XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK
Write a program that takes in a single letter character, A-Z, and outputs that same bowl of alphabet soup "rotated", so to speak, so the input letter appears where the A
does in the example above and the rest of the alphabet cycles fully around clockwise.
So the output for input A
would be that same original bowl of alphabet soup.
And the output for input B
would be this one:
YZABCD
WX EF
V G
U H
T I
SR KJ
QPONML
Likewise the output for H
would be:
EFGHIJ
CD KL
B M
A N
Z O
YX QP
WVUTSR
Or for Z
:
WXYZAB
UV CD
T E
S F
R G
QP IH
ONMLKJ
This needs to work for all 26 letters, A through Z.
Details:
- You can assume the only input will be a single letter, A through Z.
- If convenient you may use lowercase a-z for input and/or output, you can even mix and match lower and uppercase.
- The alphabet order must cycle clockwise, not counter-clockwise.
- You must use spaces, not something else, to indent and fill the soup bowl.
- There may be leading or trailing newlines or spaces in the output as long as the soup bowl is arranged properly.
- Note that the bowl shape is 12 characters wide by 7 tall to make it appear roughly circular as text. Your bowls need to be the same shape.
This is code golf so the shortest code wins!
code-golf string ascii-art
New contributor
$endgroup$
This is what we'll call a bowl of alphabet soup - a roughly circular ascii-art shape with the 26 uppercase English letters (A-Z) arranged clockwise to form the perimeter:
XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK
Write a program that takes in a single letter character, A-Z, and outputs that same bowl of alphabet soup "rotated", so to speak, so the input letter appears where the A
does in the example above and the rest of the alphabet cycles fully around clockwise.
So the output for input A
would be that same original bowl of alphabet soup.
And the output for input B
would be this one:
YZABCD
WX EF
V G
U H
T I
SR KJ
QPONML
Likewise the output for H
would be:
EFGHIJ
CD KL
B M
A N
Z O
YX QP
WVUTSR
Or for Z
:
WXYZAB
UV CD
T E
S F
R G
QP IH
ONMLKJ
This needs to work for all 26 letters, A through Z.
Details:
- You can assume the only input will be a single letter, A through Z.
- If convenient you may use lowercase a-z for input and/or output, you can even mix and match lower and uppercase.
- The alphabet order must cycle clockwise, not counter-clockwise.
- You must use spaces, not something else, to indent and fill the soup bowl.
- There may be leading or trailing newlines or spaces in the output as long as the soup bowl is arranged properly.
- Note that the bowl shape is 12 characters wide by 7 tall to make it appear roughly circular as text. Your bowls need to be the same shape.
This is code golf so the shortest code wins!
code-golf string ascii-art
code-golf string ascii-art
New contributor
New contributor
New contributor
asked Mar 19 at 21:34
Discrete GamesDiscrete Games
78648
78648
New contributor
New contributor
12
$begingroup$
Great challenge! It initially seems easy, but it's not
$endgroup$
– Luis Mendo
Mar 19 at 21:56
add a comment |
12
$begingroup$
Great challenge! It initially seems easy, but it's not
$endgroup$
– Luis Mendo
Mar 19 at 21:56
12
12
$begingroup$
Great challenge! It initially seems easy, but it's not
$endgroup$
– Luis Mendo
Mar 19 at 21:56
$begingroup$
Great challenge! It initially seems easy, but it's not
$endgroup$
– Luis Mendo
Mar 19 at 21:56
add a comment |
21 Answers
21
active
oldest
votes
$begingroup$
05AB1E, 21 bytes
Defines a program $f : color{purple}{texttt{AlphabeticChar}} rightarrow color{purple}{texttt{String}}$
Code:
2AA¹k._•1못*Ć,ãiDΣ•Λ
Try it online!
Breakdown:
2AA¹k._•1못*Ć,ãiDΣ•Λ
2 # <length>
AA¹k._ # <filler>
•1못*Ć,ãiDΣ• # <pattern>
Λ # Invoke the canvas function.
Explanation:
The canvas (Λ
) in this particular context works as a function with the following signature:
$$
mathsf{Lambda} : left(texttt{length}: color{purple}{texttt{Nat}}, texttt{filler}: color{purple}{texttt{String}}, texttt{pattern}: color{purple}{texttt{Nat}}right) rightarrow color{purple}{texttt{String}}
$$
The $texttt{pattern}$ parameter is in this situation a number defining the directions. In the code, this number is represented as •1못*Ć,ãiDΣ•
, which is a compressed version of the big number $2232344565666667670012122$. Directions are denoted in the following manner:
$$
begin{array}{l}
7 & & 0 & & 1 \
& nwarrow & uparrow & nearrow & \
6 & leftarrow & bullet & rightarrow & 2 \
& swarrow & downarrow & searrow & \
5 & & 4 & & 3
end{array}
$$
This means that the big number represents the following pattern of directions:
$$
[rightarrow, rightarrow, searrow, rightarrow, searrow, downarrow, downarrow, swarrow, leftarrow, swarrow, leftarrow, leftarrow, leftarrow, leftarrow, leftarrow, nwarrow, leftarrow, nwarrow, uparrow, uparrow, nearrow, rightarrow, nearrow, rightarrow, rightarrow]
$$
With this signature context, the canvas iterates through the $texttt{pattern}$ list and writes $texttt{length}$ characters from the $texttt{filler}$ in the current direction.
The $texttt{length}$ is specified in the code as $2$ (at the beginning of the code). For the $texttt{filler}$, we need a rotated version of the alphabet such that it starts with the given input. That is done with the following code (try it here):
AA¹k._
A¹k # Find the <index> of the given input character in the alphabet
A ._ # Rotate the alphabet to the left <index> times.
In pseudocode, this would be executed by the canvas function:
$
begin{array}{l}
1. & text{Write } color{blue}{texttt{ab}} text{ in the direction} rightarrow \
2. & text{Write } color{blue}{texttt{bc}} text{ in the direction} rightarrow \
3. & text{Write } color{blue}{texttt{cd}} text{ in the direction} searrow \
4. & text{Write } color{blue}{texttt{de}} text{ in the direction} rightarrow \
5. & text{Write } color{blue}{texttt{ef}} text{ in the direction} searrow \
6. & text{Write } color{blue}{texttt{fg}} text{ in the direction} downarrow \
dots
end{array}
$
Lastly, you can see that the filler argument is 'rotated' $texttt{length} - 1$ times to the right, meaning that the canvas would iterate through the following (cycled and therefore infinite) list:
$$
[color{blue}{texttt{ab}}, color{blue}{texttt{bc}}, color{blue}{texttt{cd}}, color{blue}{texttt{de}}, color{blue}{texttt{ef}}, color{blue}{texttt{fg}}, color{blue}{texttt{gh}}, color{blue}{texttt{hi}}, color{blue}{texttt{ij}}, color{blue}{texttt{jk}}, ...
$$
Which results in the desired alphabet soup ascii-art shape.
$endgroup$
$begingroup$
Ok, I give up. Tried to find shorter alternatives, but I'm not seeing it.AA¹k._
can alternatively beA¹¡RJ«
, but it's the same byte-count.•1못*Ć,ãiDΣ•
can alternatively be•õÕ₆qηµñ–†f•·
, but it's the same byte-count. Ah well. Nice answer!
$endgroup$
– Kevin Cruijssen
Mar 20 at 12:45
add a comment |
$begingroup$
Perl 6, 100 bytes
{"2XYZABC
VW5DE
U9F
T9G
S9H
RQ5JI
2PONMLK".trans(/S/=>{(try ' 'x$/+1)||chr ($/.ord+.ord)%26+65})}
Try it online!
Replaces all letters in the string with their shifted counterparts, while replacing digits with the number of spaces they represent plus one.
Explanation
{ }# Anonymous code block
"...".trans(/S/=>{ }) # Translate non-whitespace
(try ' 'x$/+1) # If digits, the amount of spaces plus one
||chr ($/.ord+.ord)%26+64 # Else the shifted letter
$endgroup$
add a comment |
$begingroup$
Ruby, 107 bytes
->n{a=(0..6).map{' '*11}
(?A..?Z).map{|i|j,k=(1i**((i.ord-n.ord-6)/6.5)).rect;a[3.5*k+=1][5.2*j+6]=i}
a*$/}
Try it online!
Improved syntax "i".to_c
-> 1i
(Suggested by Jordan)
Changed coordinate system so 0 degrees is at right instead of top. This enables 0.5
-> 6
Adjusted multipliers of j
and k
for shortness
Rather than print output puts a
, concatenate array elements and return a string a*$/
Ruby, 119 bytes
->n{a=(0..6).map{' '*11}
(?A..?Z).map{|i|j,k=("i".to_c**((i.ord-n.ord+0.5)/6.5)).rect;a[3.5-j*3.3][6+k*5.17]=i}
puts a}
Uses a complex number raised to a power to map to an ellipse. A complete turn is 26, so each quadrant is 6.5.
This approach relies on the required output resembling an ellipse sufficiently that a valid mapping can be achieved.
Try it online!
$endgroup$
$begingroup$
Instead of"i".to_c
can you just do1i
?
$endgroup$
– Jordan
Mar 20 at 15:04
$begingroup$
@Jordan thanks, I've not seen that syntax before!
$endgroup$
– Level River St
Mar 20 at 22:29
add a comment |
$begingroup$
Charcoal, 33 bytes
GH→→↘→↘↓↓77←←←←↖←↖↑↑↗→↗→→²✂⁺αα⌕αS
Try it online! Link is to verbose version of code. Explanation:
GH
Trace a path.
→→↘→↘↓↓77←←←←↖←↖↑↑↗→↗→→
Outline the bowl. Each 7
expands to ↙←
.
²
Move one character at a time (this API overlaps each line's ends with the next).
✂⁺αα⌕αS
Draw using the doubled alphabet, but starting at the position of the input character.
$endgroup$
add a comment |
$begingroup$
MATL, 49 bytes
7I8*32tvB[1b]&Zvc2Y2j7+_YSy&f7-w4-_Z;YPE,&S])yg(
What a mess. But it was fun writing. There's even an arctangent involved.
Try it online!
Explanation
The code
7I8*32tvB
creates an array of numbers and converts them to binary. This gives the zero-one matrix
0 0 0 1 1 1
0 1 1 0 0 0
1 0 0 0 0 0
1 0 0 0 0 0
which is the top left quadrant of a matrix specfying the positions of the letters.
[1b]&Zv
reflects that quadrant vertically without repeating the last row, and horizontally repeating the last column to produce the full matrix:
0 0 0 1 1 1 1 1 1 0 0 0
0 1 1 0 0 0 0 0 0 1 1 0
1 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 1
0 1 1 0 0 0 0 0 0 1 1 0
0 0 0 1 1 1 1 1 1 0 0 0
We now have a mask with the positions. The code
c
converts this to char, because the final result will be a char matrix. Character 0 is displayed as space, and the nonzero entries will be written with the appropriate letters.
2Y2
pushes the string 'abc···xyz'
, which contains the 26 letters. This string needs to be circularly shifted as per the input. To do that,
j7+_YS
reads the input letter, adds 7 to its ASCII code, and negates the result. For input 'a'
this gives −104, which is a multiple of 26, so circularly shifting by this amount will do nothing. If the input is b
this gives −105, which shifts the string 1 step to the left to produce 'bcd···yza'
; etc.
The next step is to define the order in which the shifted string will be written into the nonzero entries of the matrix. To this end,
y&f
creates a copy of the matrix and pushes two vectors containing the 1-based row and column positions of the nonzeros. Then
7-w4-_
subtracts 7 from the latter, brings the former to top, substracts 4 from it, and negates it. The 7 and 4 specify an origin of coordinates, so that the angles of the position vectors of the nonzero entries with respect to that origin define the desired order.
Z;YPE
computes the two-argument arctangent modulo 2*pi to produce those angles. Now the smallest angle, which is 0, corresponds to the entry where the first letter should go, and the rest advance counter-clockwise.
,&S])
rearranges the letters in the string according to those angles, so that when the letters are written into the nonzero entries of the matrix in column-major order (down, then across) the result will be correct. This is done by
yg(
For example, if the input is 'a'
the string was not circularly shifted:
abcdefghijklmnopqrstuvwxyz
The rearranging as per the angles transforms this into
utsvrwqxpyoznamblckdjeifgh
so that 'u'
will correctly go to the first (in column-major order) nonzero entry, which is (3,1) in matrix notation; 't'
will go to (4,1), 's'
to (5,1); 'v'
to (2,2) etc:
······
v· ··
u ·
t ·
s ·
·· ··
······
$endgroup$
$begingroup$
@EriktheOutgolfer I finally found some time to add an explanation
$endgroup$
– Luis Mendo
2 days ago
1
$begingroup$
Woah... I actually thought you abandoned this because you deleted that comment. :P
$endgroup$
– Erik the Outgolfer
2 days ago
add a comment |
$begingroup$
Python 2, 129 bytes
lambda x:''.join((i,chr((ord(x)+ord(i))%26+65),' '*5)[ord(i)/46]for i in''' XYZABC
VW] DE
U]]F
T]]G
S]]H
RQ] JI
PONMLK''')
Try it online!
$endgroup$
add a comment |
$begingroup$
R, 139 122 bytes
-17 bytes thanks to Giuseppe
u=utf8ToInt;`*`=rep;o=c(' '*12,'
')*7;o[u(" &3@LKWVUTSRDC5(")]=LETTERS[(13:38+u(scan(,'')))%%26+1];cat(o,sep='')
Explanation:
o=rep(c(rep(' ',12),'
'),7)
Builds an empty box of spaces
u(" &3@LKWVUTSRDC5(")
is a set of indices for letter positions corresponding to:
c(7:9,23,24,38,51,64,76,75,87:82,68,67,53,40,27,15,16,4:6)
TIO
$endgroup$
1
$begingroup$
you never useintToUtf8
so those are extraneous bytes, but if you use*
in place ofrep
, you can get save 2 bytes and get to 125 bytes
$endgroup$
– Giuseppe
Mar 20 at 18:00
1
$begingroup$
Oh, and using the low-byte characters instead of printable ascii you can shave off the-32
, for 122 bytes. You can generate them yourself by usingcat(intToUtf8(bytes))
.
$endgroup$
– Giuseppe
Mar 20 at 18:03
$begingroup$
@Giuseppe I was pretty sure I had already removed theintToUtf8
, too many versions of the function open at once I guess. Nice saves all roundthough, thanks
$endgroup$
– Aaron Hayman
Mar 20 at 21:30
add a comment |
$begingroup$
JavaScript (Node.js), 121 119 bytes
Saved 2 bytes thanks to @tsh
c=>`2XYZABC
0VW5DE
U9F
T9G
S9H
0RQ5JI
2PONMLK`.replace(/./g,x=>''.padEnd(+x+1)||(B=Buffer)([65+([a,b]=B(c+x),a+b)%26]))
Try it online!
How?
This code abuses Buffer
to extract the ASCII codes of the template letter $x$ and input letter $c$ and convert them back into the target letter.
Example with $c=$"H"
and $x=$"B"
// extracting the ASCII codes
Buffer(c + x) → Buffer("HB") → <Buffer 48 42>
// assigning them to variables
[a, b] = Buffer(c + x) → a = 0x48 (72) and b = 0x42 (66)
// computing the ASCII code of the target letter
65 + ((a + b) % 26) → 65 + (138 % 26) → 65 + 8 → 73
// turning it back into a character
Buffer([73]) → <Buffer 49> → implicitly coerced to "I" by replace()
$endgroup$
$begingroup$
119 bytes
$endgroup$
– tsh
Mar 20 at 5:56
add a comment |
$begingroup$
APL+WIN, 72 bytes
Prompts for character
m←7 12⍴' '⋄n←(7⍴2)⊤v,⌽v←(⍳3)/28 34 65⋄((,n)/,m)←(22+s⍳⎕)⌽s←⎕av[65+⍳26]⋄m
Try it online!Coutesy of Dyalog Classic
$endgroup$
add a comment |
$begingroup$
R, 218 197 bytes
-21 bytes thanks to Giuseppe
function(t,l=letters,`*`=rep,s=" ",n="
",`~`=`[`,r=c(l~l>=t,l))cat(s*3,r~24:26,r~1:3,n,s,r~22:23,q<-s*6,r~4:5,n,r~21,u<-s*10,r~6,n,r~20,u,r~7,n,r~19,u,r~8,n,s,r~17:18,q,r~10:9,n,s*3,r~16:11,sep='')
Try it online!
Ungolfed:
alphasoup <- function(startlet){
startnum <- which(l == startlet)
rotatedletters <- c(letters[startnum:26], letters[1:(startnum -1)])[1:26]
cat(' ',rotatedletters[24:26],rotatedletters[1:3], 'n ',
rotatedletters[22:23], s6 <- ' ', rotatedletters[4:5], 'n',
rotatedletters[21], s10 <- rep(' ', 10), rotatedletters[6], 'n',
rotatedletters[20], s10, rotatedletters[7], 'n',
rotatedletters[19], s10, rotatedletters[8], 'n ',
rotatedletters[17:18], s6, rotatedletters[10:9], 'n ',
rotatedletters[16:11],
sep = '')
}
Created rotated letter vector and uses cat
to fill out rim of bowl with that vector.
$endgroup$
$begingroup$
203 bytes if you don't mind one-line monstrosities; the biggest improvement was probably removing thewhich
and usingl>=t
as the index directly, which was worth 12 bytes.
$endgroup$
– Giuseppe
Mar 20 at 17:52
2
$begingroup$
198 bytes by aliasing[
with~
. This is a great answer; I was spending about 250 bytes in my first few attempts with a much more complex approach.
$endgroup$
– Giuseppe
Mar 20 at 17:56
$begingroup$
Ah, that's clever, I forget about string comparisons.
$endgroup$
– CT Hall
Mar 20 at 17:56
add a comment |
$begingroup$
Wolfram Language (Mathematica), 258 bytes
(t[x_]:=Table[" ",x];w=RotateRight[Alphabet,4-LetterNumber@#];j=Join;a[x_,y_]:=j[{w[[x]]},t@10,{w[[y]]}];b[m_,n_]:=j[t@1,w[[m;;m+1]],t@6,w[[n;;n+1]],t@1];""<>#&/@{j[t@3,w[[1;;6]]],b[25,7],a[24,9],a[23,10],a[22,11],Reverse@b[12,20],j[t@3,w[[19;;14;;-1]]]})&
Try it online!
$endgroup$
add a comment |
$begingroup$
Haskell, 127 bytes
("cXYZABC aVWfDE UjF TjG SjH aRQfJI cPONMLK">>=).(?)
t?c|c>'Z'=' '<$['a'..c]|c<'!'="n"|t<'B'=[c]|c>'Y'=t?'@'|1<2=pred t?succ c
Try it online!
Each character in the encoded string is decoded by function ?
into a string:
t?c -- 't' is the starting char,
-- 'c' the char from the encoded string
|c>'Z'=' '<$['a'..c] -- if 'c' is a lowercase letter, return some spaces
-- 'a': one, 'b': two, etc
|c<'!'="n" -- if 'c' is a space, return a newline
|t<'B'=[c] -- if 't' is the letter A, return 'c'
|c>'Y'=t?'@' -- wrap around Z
|1<2=pred t?succ c -- else the result is the same as starting one letter
-- earlier (pred t) but looking at the successor of 'c'
$endgroup$
add a comment |
$begingroup$
Java 11, 134 bytes
c->"2XYZABC_0VW5DE_U9F_T9G_S9H_0RQ5JI_2PONMLK".chars().forEach(i->System.out.print(i<59?" ".repeat(i-47):(char)(i>90?10:(c+i)%26+65)))
Try it online.
136 bytes version with potential to be golfed?
c->"2XYZABC_0VW5DE_U9F_T9G_S9H_0RQ5JI_2PONMLK".chars().forEach(i->System.out.printf("%"+(i<59?i-47:"")+"c",i>90?10:i<59?32:(c+i)%26+65))
Try it online.
Explanation (of the first answer)
c-> // Method with character parameter and no return-type
"2XYZABC_0VW5DE_U9F_T9G_S9H_0RQ5JI_2PONMLK"
// Template-String
.chars().forEach(i-> // Loop over the unicode values of its characters:
System.out.print( // Print:
i<59? // If the value is below 59 (so a digit character):
" ".repeat(i-47) // Repeat a space that digit + 1 amount of times
:(char)(i>90? // Else-if the value is above 90 (an underscore character):
10 // Print a newline
: // Else:
(c+i) // Add the current value and the input together
%26 // Take modulo-26 of it to get the index in the alphabet
+65))) // And add 65 to make it an uppercase letter
$endgroup$
$begingroup$
Why not replace digits with unprintables? That way, you could just omit thei-47
$endgroup$
– Embodiment of Ignorance
yesterday
$begingroup$
@EmbodimentofIgnorance I'm afraid it wouldn't save any bytes. The numbers of spaces are 3, 1, 6, and 10. The 10 is used three times and is 2 bytes each as character (n
). So whether I use unprintables and 3xn
withi
or digits-1 withi-47
, both are the same 134 byte-count. And unfortunately I can't have an unprintable0
, otherwise I could have used 2,0,5,9 instead, and usei+1
to save 1 byte in total.
$endgroup$
– Kevin Cruijssen
21 hours ago
add a comment |
$begingroup$
Kotlin, 148 146 145 bytes
Removed extra parentheses for -2
Replaced raw string for -1
{l:Char->"2XYZABC 0VW5DE U9F T9G S9H 0RQ5JI 2PONMLK".map{c->if(c>'@')((c-'A'+(l-'A'))%26+65).toChar()
else if(c>' ')" ".repeat(c-'/')
else 'n'}}
Try it online!
$endgroup$
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 126 118 bytes
n=>$@" XYZABC
VW{"",6}DE
U {"",9}F
T {"",9}G
S {"",9}H
RQ{"",6}JI
PONMLK".Select(b=>b<65?b:(char)((b+n)%26+65))
Saved 8 bytes thanks to @someone. Yes, that's actually his username.
Try it online!
$endgroup$
$begingroup$
String interpolation for 118 bytes. It is likely acceptable to return a array of charcodes (saving ~8 bytes), but I'm not sure.
$endgroup$
– someone
yesterday
$begingroup$
@someone Nice, forgot about string interpolation
$endgroup$
– Embodiment of Ignorance
yesterday
add a comment |
$begingroup$
TSQL query, 238 bytes
DECLARE @y char='G'
,@ char(91)=3;WITH C as(SELECT'5585877636333330301125255'z,8a,ascii(@y)x
UNION ALL
SELECT stuff(z,1,1,''),a+left(z,1)/3*13+left(z,1)%3-14,(x+14)%26+65FROM
C WHERE''<z)SELECT
@=stuff(stuff(@,a,1,char(x)),1+a/13*13,1,char(13))FROM
C PRINT @
The test link for this answer broke the line breaks and excluded the spaces. I have replaced the spaces with period and replaced char(13) with char(13)+char(10) in order to show a readable result.
Try it online
Ungolfed:
DECLARE @y char='G'
-- @ is the string being printed last.
-- @ is populated with 3 to save a byte
-- the number 3 gets replaced later
-- (this could have been any 1 digit value),
-- @ is automatically filled with spaces, because
-- it is declared as a char(x) and assigned a value
,@ char(91)=3;
-- recursive query
WITH C as
(
-- z string containing digits for the direction of next letter
-- z should not contain 4 because it will point to same position.
-- values in z 0,1,2,3,4,5,6,7,8 can logally convert to
-- (-1,-1),(-1,0),(-1,1),(0,-1),(0,0),(0,1),(1,-1),(1,0),(1,1)
-- a is the starting position
SELECT'5585877636333330301125255'z,8a,ascii(@y)x
UNION ALL
-- stuff remove first character from the z string
-- a calculate next position of the next letter
-- x rotate the input letter
SELECT stuff(z,1,1,''),a+left(z,1)/3*13+left(z,1)%3-14,(x+14)%26+65
-- repeat recursive until long string is empty
FROM C
WHERE''<z
)
SELECT
-- 1st stuff replace the character to created the start of a
-- logical line in the string @ this is where 3 gets overwritten
-- 2nd stuff replaces a character(space if coded correct)
-- with the letter at the calculated position.
@=stuff(stuff(@,a,1,char(x)),1+a/13*13,1,char(13))
FROM C
PRINT @
$endgroup$
$begingroup$
@MickyT ok, thanks for your feedback, I will fix it later today if i can get access to a db
$endgroup$
– t-clausen.dk
Mar 20 at 18:16
$begingroup$
@MickyT it should be fixed now
$endgroup$
– t-clausen.dk
Mar 21 at 10:24
1
$begingroup$
looks good now.
$endgroup$
– MickyT
Mar 21 at 17:17
add a comment |
$begingroup$
PHP, 236 229 226 bytes
<?=($a=ord(file_get_contents('php://stdin'))-65)?preg_replace_callback('~w~',function($m)use($a){return chr((ord($m[0])-65+$a)%26+65);},' XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK'):'';
Try it online!
Pre-golf:
<?php
$adjust = ord(file_get_contents('php://stdin')) - 65;
echo preg_replace_callback('~w~', function($match) use ($adjust) {
$new = ord($match[0]) - 65;
$new = ($new + $adjust) % 26;
$new += 65;
return chr($new);
}, ' XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK');
Explanation:
Using ord
we convert to an integer between 0 and 255. A is 65 and Z is 90.
Using this knowledge, we take the input and reduce it by 65 so we have an adjustment value.
We then iterate over all characters, call ord
on them, reduce them by 65, increase them by our adjustment value. Using modulo we loop back down to 0 if they exceed 26.
We then increase them by 65 again and convert them back into letters with chr
.
Sadly php://stdin can only be interogated once, so we need to pass the input into the function in our loop, preventing us from saving bytes on use($a)
and having to declare a variable outside the function stops us from cleanly using the <?=
echo method - we have to wrap everything in a giant ternary.
$endgroup$
add a comment |
$begingroup$
C(GCC) 286 bytes
Not exactly the shortest golf, but it works
#define r(a)(a+c)%26+65
#define R(a)for(i=10;i;a[--i]<33?:(a[i]=r(a[i])));
i;f(c){char*S=" ",T=" XYZABCn",E="VW DEn",F="RQ JIn",B=" PONMLK";R(T)R(E)R(F)R(B)printf("%s %s%c%s%cn%c%s%cn%c%s%cn %s%s",T,E,r(85),S,r(70),r(84),S,r(71),r(83),S,r(72),F,B);}
Try it online
$endgroup$
add a comment |
$begingroup$
Red, 139 bytes
func[a][foreach c{ XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK}[if c > sp[c: c + a % 26 + 65]prin c]]
Try it online!
A really naive solution.
$endgroup$
add a comment |
$begingroup$
Perl 5 -p
, 110 bytes
$b=/A/?Z:chr(-1+ord);$_=eval("'2XYZABC
VW5DE
U9F
T9G
S9H
RQ5JI
2PONMLK'=~y/A-Z/$_-ZA-$b/r");s/d/$".$"x$&/eg
Try it online!
$endgroup$
$begingroup$
$b is unnecessary. -24 bytes: TIO.
$endgroup$
– Grimy
Mar 21 at 8:44
$begingroup$
-2 bytes TIO
$endgroup$
– Nahuel Fouilleul
Mar 21 at 13:30
add a comment |
$begingroup$
Javascript (V8), 316 bytes
function a(b){n="abcdefghijklmnopqrstuvwxyz".split(b);n=b+n[1]+n[0],console.log(` ${n[23]+n[24]+n[25]+n[0]+n[1]+n[2]}n ${n[21]+n[22]} ${n[3]+n[4]}n${n[20]} ${n[5]}n${n[19]} ${n[6]}n${n[18]} ${n[7]}n ${n[17]+n[16]} ${n[9]+n[8]}n ${n[15]+n[14]+n[13]+n[12]+n[11]+n[10]}`)}
Try it online
First time trying code golf out. Appreciate any tips / feedback.
Original code before minifying:
function a(b){
var c = ("abcdefghijklmnopqrstuvwxyz").split(b);
c = b+c[1]+c[0]
console.log(` ${c[23]+c[24]+c[25]+c[0]+c[1]+c[2]}n ${c[21]+c[22]} ${c[3]+c[4]}n${c[20]} ${c[5]}n${c[19]} ${c[6]}n${c[18]} ${c[7]}n ${c[17]+c[16]} ${c[9]+c[8]}n ${c[15]+c[14]+c[13]+c[12]+c[11]+c[10]}`)
}
New contributor
$endgroup$
$begingroup$
Hello and welcome to PPCG. As it stands, your submission is a snippet, which is invalid I/O. Please fix your answer to either be a full program or function -- as in you non-minified version.
$endgroup$
– Jonathan Frech
2 days ago
$begingroup$
@Jonathan Fresch thanks! Would that suffice?
$endgroup$
– Edwin Chua
2 days ago
1
$begingroup$
Yes, this is now a valid submission.
$endgroup$
– Jonathan Frech
2 days ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "200"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Discrete Games is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f181843%2fmake-a-bowl-of-alphabet-soup%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
21 Answers
21
active
oldest
votes
21 Answers
21
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
05AB1E, 21 bytes
Defines a program $f : color{purple}{texttt{AlphabeticChar}} rightarrow color{purple}{texttt{String}}$
Code:
2AA¹k._•1못*Ć,ãiDΣ•Λ
Try it online!
Breakdown:
2AA¹k._•1못*Ć,ãiDΣ•Λ
2 # <length>
AA¹k._ # <filler>
•1못*Ć,ãiDΣ• # <pattern>
Λ # Invoke the canvas function.
Explanation:
The canvas (Λ
) in this particular context works as a function with the following signature:
$$
mathsf{Lambda} : left(texttt{length}: color{purple}{texttt{Nat}}, texttt{filler}: color{purple}{texttt{String}}, texttt{pattern}: color{purple}{texttt{Nat}}right) rightarrow color{purple}{texttt{String}}
$$
The $texttt{pattern}$ parameter is in this situation a number defining the directions. In the code, this number is represented as •1못*Ć,ãiDΣ•
, which is a compressed version of the big number $2232344565666667670012122$. Directions are denoted in the following manner:
$$
begin{array}{l}
7 & & 0 & & 1 \
& nwarrow & uparrow & nearrow & \
6 & leftarrow & bullet & rightarrow & 2 \
& swarrow & downarrow & searrow & \
5 & & 4 & & 3
end{array}
$$
This means that the big number represents the following pattern of directions:
$$
[rightarrow, rightarrow, searrow, rightarrow, searrow, downarrow, downarrow, swarrow, leftarrow, swarrow, leftarrow, leftarrow, leftarrow, leftarrow, leftarrow, nwarrow, leftarrow, nwarrow, uparrow, uparrow, nearrow, rightarrow, nearrow, rightarrow, rightarrow]
$$
With this signature context, the canvas iterates through the $texttt{pattern}$ list and writes $texttt{length}$ characters from the $texttt{filler}$ in the current direction.
The $texttt{length}$ is specified in the code as $2$ (at the beginning of the code). For the $texttt{filler}$, we need a rotated version of the alphabet such that it starts with the given input. That is done with the following code (try it here):
AA¹k._
A¹k # Find the <index> of the given input character in the alphabet
A ._ # Rotate the alphabet to the left <index> times.
In pseudocode, this would be executed by the canvas function:
$
begin{array}{l}
1. & text{Write } color{blue}{texttt{ab}} text{ in the direction} rightarrow \
2. & text{Write } color{blue}{texttt{bc}} text{ in the direction} rightarrow \
3. & text{Write } color{blue}{texttt{cd}} text{ in the direction} searrow \
4. & text{Write } color{blue}{texttt{de}} text{ in the direction} rightarrow \
5. & text{Write } color{blue}{texttt{ef}} text{ in the direction} searrow \
6. & text{Write } color{blue}{texttt{fg}} text{ in the direction} downarrow \
dots
end{array}
$
Lastly, you can see that the filler argument is 'rotated' $texttt{length} - 1$ times to the right, meaning that the canvas would iterate through the following (cycled and therefore infinite) list:
$$
[color{blue}{texttt{ab}}, color{blue}{texttt{bc}}, color{blue}{texttt{cd}}, color{blue}{texttt{de}}, color{blue}{texttt{ef}}, color{blue}{texttt{fg}}, color{blue}{texttt{gh}}, color{blue}{texttt{hi}}, color{blue}{texttt{ij}}, color{blue}{texttt{jk}}, ...
$$
Which results in the desired alphabet soup ascii-art shape.
$endgroup$
$begingroup$
Ok, I give up. Tried to find shorter alternatives, but I'm not seeing it.AA¹k._
can alternatively beA¹¡RJ«
, but it's the same byte-count.•1못*Ć,ãiDΣ•
can alternatively be•õÕ₆qηµñ–†f•·
, but it's the same byte-count. Ah well. Nice answer!
$endgroup$
– Kevin Cruijssen
Mar 20 at 12:45
add a comment |
$begingroup$
05AB1E, 21 bytes
Defines a program $f : color{purple}{texttt{AlphabeticChar}} rightarrow color{purple}{texttt{String}}$
Code:
2AA¹k._•1못*Ć,ãiDΣ•Λ
Try it online!
Breakdown:
2AA¹k._•1못*Ć,ãiDΣ•Λ
2 # <length>
AA¹k._ # <filler>
•1못*Ć,ãiDΣ• # <pattern>
Λ # Invoke the canvas function.
Explanation:
The canvas (Λ
) in this particular context works as a function with the following signature:
$$
mathsf{Lambda} : left(texttt{length}: color{purple}{texttt{Nat}}, texttt{filler}: color{purple}{texttt{String}}, texttt{pattern}: color{purple}{texttt{Nat}}right) rightarrow color{purple}{texttt{String}}
$$
The $texttt{pattern}$ parameter is in this situation a number defining the directions. In the code, this number is represented as •1못*Ć,ãiDΣ•
, which is a compressed version of the big number $2232344565666667670012122$. Directions are denoted in the following manner:
$$
begin{array}{l}
7 & & 0 & & 1 \
& nwarrow & uparrow & nearrow & \
6 & leftarrow & bullet & rightarrow & 2 \
& swarrow & downarrow & searrow & \
5 & & 4 & & 3
end{array}
$$
This means that the big number represents the following pattern of directions:
$$
[rightarrow, rightarrow, searrow, rightarrow, searrow, downarrow, downarrow, swarrow, leftarrow, swarrow, leftarrow, leftarrow, leftarrow, leftarrow, leftarrow, nwarrow, leftarrow, nwarrow, uparrow, uparrow, nearrow, rightarrow, nearrow, rightarrow, rightarrow]
$$
With this signature context, the canvas iterates through the $texttt{pattern}$ list and writes $texttt{length}$ characters from the $texttt{filler}$ in the current direction.
The $texttt{length}$ is specified in the code as $2$ (at the beginning of the code). For the $texttt{filler}$, we need a rotated version of the alphabet such that it starts with the given input. That is done with the following code (try it here):
AA¹k._
A¹k # Find the <index> of the given input character in the alphabet
A ._ # Rotate the alphabet to the left <index> times.
In pseudocode, this would be executed by the canvas function:
$
begin{array}{l}
1. & text{Write } color{blue}{texttt{ab}} text{ in the direction} rightarrow \
2. & text{Write } color{blue}{texttt{bc}} text{ in the direction} rightarrow \
3. & text{Write } color{blue}{texttt{cd}} text{ in the direction} searrow \
4. & text{Write } color{blue}{texttt{de}} text{ in the direction} rightarrow \
5. & text{Write } color{blue}{texttt{ef}} text{ in the direction} searrow \
6. & text{Write } color{blue}{texttt{fg}} text{ in the direction} downarrow \
dots
end{array}
$
Lastly, you can see that the filler argument is 'rotated' $texttt{length} - 1$ times to the right, meaning that the canvas would iterate through the following (cycled and therefore infinite) list:
$$
[color{blue}{texttt{ab}}, color{blue}{texttt{bc}}, color{blue}{texttt{cd}}, color{blue}{texttt{de}}, color{blue}{texttt{ef}}, color{blue}{texttt{fg}}, color{blue}{texttt{gh}}, color{blue}{texttt{hi}}, color{blue}{texttt{ij}}, color{blue}{texttt{jk}}, ...
$$
Which results in the desired alphabet soup ascii-art shape.
$endgroup$
$begingroup$
Ok, I give up. Tried to find shorter alternatives, but I'm not seeing it.AA¹k._
can alternatively beA¹¡RJ«
, but it's the same byte-count.•1못*Ć,ãiDΣ•
can alternatively be•õÕ₆qηµñ–†f•·
, but it's the same byte-count. Ah well. Nice answer!
$endgroup$
– Kevin Cruijssen
Mar 20 at 12:45
add a comment |
$begingroup$
05AB1E, 21 bytes
Defines a program $f : color{purple}{texttt{AlphabeticChar}} rightarrow color{purple}{texttt{String}}$
Code:
2AA¹k._•1못*Ć,ãiDΣ•Λ
Try it online!
Breakdown:
2AA¹k._•1못*Ć,ãiDΣ•Λ
2 # <length>
AA¹k._ # <filler>
•1못*Ć,ãiDΣ• # <pattern>
Λ # Invoke the canvas function.
Explanation:
The canvas (Λ
) in this particular context works as a function with the following signature:
$$
mathsf{Lambda} : left(texttt{length}: color{purple}{texttt{Nat}}, texttt{filler}: color{purple}{texttt{String}}, texttt{pattern}: color{purple}{texttt{Nat}}right) rightarrow color{purple}{texttt{String}}
$$
The $texttt{pattern}$ parameter is in this situation a number defining the directions. In the code, this number is represented as •1못*Ć,ãiDΣ•
, which is a compressed version of the big number $2232344565666667670012122$. Directions are denoted in the following manner:
$$
begin{array}{l}
7 & & 0 & & 1 \
& nwarrow & uparrow & nearrow & \
6 & leftarrow & bullet & rightarrow & 2 \
& swarrow & downarrow & searrow & \
5 & & 4 & & 3
end{array}
$$
This means that the big number represents the following pattern of directions:
$$
[rightarrow, rightarrow, searrow, rightarrow, searrow, downarrow, downarrow, swarrow, leftarrow, swarrow, leftarrow, leftarrow, leftarrow, leftarrow, leftarrow, nwarrow, leftarrow, nwarrow, uparrow, uparrow, nearrow, rightarrow, nearrow, rightarrow, rightarrow]
$$
With this signature context, the canvas iterates through the $texttt{pattern}$ list and writes $texttt{length}$ characters from the $texttt{filler}$ in the current direction.
The $texttt{length}$ is specified in the code as $2$ (at the beginning of the code). For the $texttt{filler}$, we need a rotated version of the alphabet such that it starts with the given input. That is done with the following code (try it here):
AA¹k._
A¹k # Find the <index> of the given input character in the alphabet
A ._ # Rotate the alphabet to the left <index> times.
In pseudocode, this would be executed by the canvas function:
$
begin{array}{l}
1. & text{Write } color{blue}{texttt{ab}} text{ in the direction} rightarrow \
2. & text{Write } color{blue}{texttt{bc}} text{ in the direction} rightarrow \
3. & text{Write } color{blue}{texttt{cd}} text{ in the direction} searrow \
4. & text{Write } color{blue}{texttt{de}} text{ in the direction} rightarrow \
5. & text{Write } color{blue}{texttt{ef}} text{ in the direction} searrow \
6. & text{Write } color{blue}{texttt{fg}} text{ in the direction} downarrow \
dots
end{array}
$
Lastly, you can see that the filler argument is 'rotated' $texttt{length} - 1$ times to the right, meaning that the canvas would iterate through the following (cycled and therefore infinite) list:
$$
[color{blue}{texttt{ab}}, color{blue}{texttt{bc}}, color{blue}{texttt{cd}}, color{blue}{texttt{de}}, color{blue}{texttt{ef}}, color{blue}{texttt{fg}}, color{blue}{texttt{gh}}, color{blue}{texttt{hi}}, color{blue}{texttt{ij}}, color{blue}{texttt{jk}}, ...
$$
Which results in the desired alphabet soup ascii-art shape.
$endgroup$
05AB1E, 21 bytes
Defines a program $f : color{purple}{texttt{AlphabeticChar}} rightarrow color{purple}{texttt{String}}$
Code:
2AA¹k._•1못*Ć,ãiDΣ•Λ
Try it online!
Breakdown:
2AA¹k._•1못*Ć,ãiDΣ•Λ
2 # <length>
AA¹k._ # <filler>
•1못*Ć,ãiDΣ• # <pattern>
Λ # Invoke the canvas function.
Explanation:
The canvas (Λ
) in this particular context works as a function with the following signature:
$$
mathsf{Lambda} : left(texttt{length}: color{purple}{texttt{Nat}}, texttt{filler}: color{purple}{texttt{String}}, texttt{pattern}: color{purple}{texttt{Nat}}right) rightarrow color{purple}{texttt{String}}
$$
The $texttt{pattern}$ parameter is in this situation a number defining the directions. In the code, this number is represented as •1못*Ć,ãiDΣ•
, which is a compressed version of the big number $2232344565666667670012122$. Directions are denoted in the following manner:
$$
begin{array}{l}
7 & & 0 & & 1 \
& nwarrow & uparrow & nearrow & \
6 & leftarrow & bullet & rightarrow & 2 \
& swarrow & downarrow & searrow & \
5 & & 4 & & 3
end{array}
$$
This means that the big number represents the following pattern of directions:
$$
[rightarrow, rightarrow, searrow, rightarrow, searrow, downarrow, downarrow, swarrow, leftarrow, swarrow, leftarrow, leftarrow, leftarrow, leftarrow, leftarrow, nwarrow, leftarrow, nwarrow, uparrow, uparrow, nearrow, rightarrow, nearrow, rightarrow, rightarrow]
$$
With this signature context, the canvas iterates through the $texttt{pattern}$ list and writes $texttt{length}$ characters from the $texttt{filler}$ in the current direction.
The $texttt{length}$ is specified in the code as $2$ (at the beginning of the code). For the $texttt{filler}$, we need a rotated version of the alphabet such that it starts with the given input. That is done with the following code (try it here):
AA¹k._
A¹k # Find the <index> of the given input character in the alphabet
A ._ # Rotate the alphabet to the left <index> times.
In pseudocode, this would be executed by the canvas function:
$
begin{array}{l}
1. & text{Write } color{blue}{texttt{ab}} text{ in the direction} rightarrow \
2. & text{Write } color{blue}{texttt{bc}} text{ in the direction} rightarrow \
3. & text{Write } color{blue}{texttt{cd}} text{ in the direction} searrow \
4. & text{Write } color{blue}{texttt{de}} text{ in the direction} rightarrow \
5. & text{Write } color{blue}{texttt{ef}} text{ in the direction} searrow \
6. & text{Write } color{blue}{texttt{fg}} text{ in the direction} downarrow \
dots
end{array}
$
Lastly, you can see that the filler argument is 'rotated' $texttt{length} - 1$ times to the right, meaning that the canvas would iterate through the following (cycled and therefore infinite) list:
$$
[color{blue}{texttt{ab}}, color{blue}{texttt{bc}}, color{blue}{texttt{cd}}, color{blue}{texttt{de}}, color{blue}{texttt{ef}}, color{blue}{texttt{fg}}, color{blue}{texttt{gh}}, color{blue}{texttt{hi}}, color{blue}{texttt{ij}}, color{blue}{texttt{jk}}, ...
$$
Which results in the desired alphabet soup ascii-art shape.
edited Mar 20 at 10:33
answered Mar 19 at 22:00
AdnanAdnan
35.9k562226
35.9k562226
$begingroup$
Ok, I give up. Tried to find shorter alternatives, but I'm not seeing it.AA¹k._
can alternatively beA¹¡RJ«
, but it's the same byte-count.•1못*Ć,ãiDΣ•
can alternatively be•õÕ₆qηµñ–†f•·
, but it's the same byte-count. Ah well. Nice answer!
$endgroup$
– Kevin Cruijssen
Mar 20 at 12:45
add a comment |
$begingroup$
Ok, I give up. Tried to find shorter alternatives, but I'm not seeing it.AA¹k._
can alternatively beA¹¡RJ«
, but it's the same byte-count.•1못*Ć,ãiDΣ•
can alternatively be•õÕ₆qηµñ–†f•·
, but it's the same byte-count. Ah well. Nice answer!
$endgroup$
– Kevin Cruijssen
Mar 20 at 12:45
$begingroup$
Ok, I give up. Tried to find shorter alternatives, but I'm not seeing it.
AA¹k._
can alternatively be A¹¡RJ«
, but it's the same byte-count. •1못*Ć,ãiDΣ•
can alternatively be •õÕ₆qηµñ–†f•·
, but it's the same byte-count. Ah well. Nice answer!$endgroup$
– Kevin Cruijssen
Mar 20 at 12:45
$begingroup$
Ok, I give up. Tried to find shorter alternatives, but I'm not seeing it.
AA¹k._
can alternatively be A¹¡RJ«
, but it's the same byte-count. •1못*Ć,ãiDΣ•
can alternatively be •õÕ₆qηµñ–†f•·
, but it's the same byte-count. Ah well. Nice answer!$endgroup$
– Kevin Cruijssen
Mar 20 at 12:45
add a comment |
$begingroup$
Perl 6, 100 bytes
{"2XYZABC
VW5DE
U9F
T9G
S9H
RQ5JI
2PONMLK".trans(/S/=>{(try ' 'x$/+1)||chr ($/.ord+.ord)%26+65})}
Try it online!
Replaces all letters in the string with their shifted counterparts, while replacing digits with the number of spaces they represent plus one.
Explanation
{ }# Anonymous code block
"...".trans(/S/=>{ }) # Translate non-whitespace
(try ' 'x$/+1) # If digits, the amount of spaces plus one
||chr ($/.ord+.ord)%26+64 # Else the shifted letter
$endgroup$
add a comment |
$begingroup$
Perl 6, 100 bytes
{"2XYZABC
VW5DE
U9F
T9G
S9H
RQ5JI
2PONMLK".trans(/S/=>{(try ' 'x$/+1)||chr ($/.ord+.ord)%26+65})}
Try it online!
Replaces all letters in the string with their shifted counterparts, while replacing digits with the number of spaces they represent plus one.
Explanation
{ }# Anonymous code block
"...".trans(/S/=>{ }) # Translate non-whitespace
(try ' 'x$/+1) # If digits, the amount of spaces plus one
||chr ($/.ord+.ord)%26+64 # Else the shifted letter
$endgroup$
add a comment |
$begingroup$
Perl 6, 100 bytes
{"2XYZABC
VW5DE
U9F
T9G
S9H
RQ5JI
2PONMLK".trans(/S/=>{(try ' 'x$/+1)||chr ($/.ord+.ord)%26+65})}
Try it online!
Replaces all letters in the string with their shifted counterparts, while replacing digits with the number of spaces they represent plus one.
Explanation
{ }# Anonymous code block
"...".trans(/S/=>{ }) # Translate non-whitespace
(try ' 'x$/+1) # If digits, the amount of spaces plus one
||chr ($/.ord+.ord)%26+64 # Else the shifted letter
$endgroup$
Perl 6, 100 bytes
{"2XYZABC
VW5DE
U9F
T9G
S9H
RQ5JI
2PONMLK".trans(/S/=>{(try ' 'x$/+1)||chr ($/.ord+.ord)%26+65})}
Try it online!
Replaces all letters in the string with their shifted counterparts, while replacing digits with the number of spaces they represent plus one.
Explanation
{ }# Anonymous code block
"...".trans(/S/=>{ }) # Translate non-whitespace
(try ' 'x$/+1) # If digits, the amount of spaces plus one
||chr ($/.ord+.ord)%26+64 # Else the shifted letter
edited Mar 20 at 1:17
answered Mar 20 at 0:59
Jo KingJo King
25.3k361129
25.3k361129
add a comment |
add a comment |
$begingroup$
Ruby, 107 bytes
->n{a=(0..6).map{' '*11}
(?A..?Z).map{|i|j,k=(1i**((i.ord-n.ord-6)/6.5)).rect;a[3.5*k+=1][5.2*j+6]=i}
a*$/}
Try it online!
Improved syntax "i".to_c
-> 1i
(Suggested by Jordan)
Changed coordinate system so 0 degrees is at right instead of top. This enables 0.5
-> 6
Adjusted multipliers of j
and k
for shortness
Rather than print output puts a
, concatenate array elements and return a string a*$/
Ruby, 119 bytes
->n{a=(0..6).map{' '*11}
(?A..?Z).map{|i|j,k=("i".to_c**((i.ord-n.ord+0.5)/6.5)).rect;a[3.5-j*3.3][6+k*5.17]=i}
puts a}
Uses a complex number raised to a power to map to an ellipse. A complete turn is 26, so each quadrant is 6.5.
This approach relies on the required output resembling an ellipse sufficiently that a valid mapping can be achieved.
Try it online!
$endgroup$
$begingroup$
Instead of"i".to_c
can you just do1i
?
$endgroup$
– Jordan
Mar 20 at 15:04
$begingroup$
@Jordan thanks, I've not seen that syntax before!
$endgroup$
– Level River St
Mar 20 at 22:29
add a comment |
$begingroup$
Ruby, 107 bytes
->n{a=(0..6).map{' '*11}
(?A..?Z).map{|i|j,k=(1i**((i.ord-n.ord-6)/6.5)).rect;a[3.5*k+=1][5.2*j+6]=i}
a*$/}
Try it online!
Improved syntax "i".to_c
-> 1i
(Suggested by Jordan)
Changed coordinate system so 0 degrees is at right instead of top. This enables 0.5
-> 6
Adjusted multipliers of j
and k
for shortness
Rather than print output puts a
, concatenate array elements and return a string a*$/
Ruby, 119 bytes
->n{a=(0..6).map{' '*11}
(?A..?Z).map{|i|j,k=("i".to_c**((i.ord-n.ord+0.5)/6.5)).rect;a[3.5-j*3.3][6+k*5.17]=i}
puts a}
Uses a complex number raised to a power to map to an ellipse. A complete turn is 26, so each quadrant is 6.5.
This approach relies on the required output resembling an ellipse sufficiently that a valid mapping can be achieved.
Try it online!
$endgroup$
$begingroup$
Instead of"i".to_c
can you just do1i
?
$endgroup$
– Jordan
Mar 20 at 15:04
$begingroup$
@Jordan thanks, I've not seen that syntax before!
$endgroup$
– Level River St
Mar 20 at 22:29
add a comment |
$begingroup$
Ruby, 107 bytes
->n{a=(0..6).map{' '*11}
(?A..?Z).map{|i|j,k=(1i**((i.ord-n.ord-6)/6.5)).rect;a[3.5*k+=1][5.2*j+6]=i}
a*$/}
Try it online!
Improved syntax "i".to_c
-> 1i
(Suggested by Jordan)
Changed coordinate system so 0 degrees is at right instead of top. This enables 0.5
-> 6
Adjusted multipliers of j
and k
for shortness
Rather than print output puts a
, concatenate array elements and return a string a*$/
Ruby, 119 bytes
->n{a=(0..6).map{' '*11}
(?A..?Z).map{|i|j,k=("i".to_c**((i.ord-n.ord+0.5)/6.5)).rect;a[3.5-j*3.3][6+k*5.17]=i}
puts a}
Uses a complex number raised to a power to map to an ellipse. A complete turn is 26, so each quadrant is 6.5.
This approach relies on the required output resembling an ellipse sufficiently that a valid mapping can be achieved.
Try it online!
$endgroup$
Ruby, 107 bytes
->n{a=(0..6).map{' '*11}
(?A..?Z).map{|i|j,k=(1i**((i.ord-n.ord-6)/6.5)).rect;a[3.5*k+=1][5.2*j+6]=i}
a*$/}
Try it online!
Improved syntax "i".to_c
-> 1i
(Suggested by Jordan)
Changed coordinate system so 0 degrees is at right instead of top. This enables 0.5
-> 6
Adjusted multipliers of j
and k
for shortness
Rather than print output puts a
, concatenate array elements and return a string a*$/
Ruby, 119 bytes
->n{a=(0..6).map{' '*11}
(?A..?Z).map{|i|j,k=("i".to_c**((i.ord-n.ord+0.5)/6.5)).rect;a[3.5-j*3.3][6+k*5.17]=i}
puts a}
Uses a complex number raised to a power to map to an ellipse. A complete turn is 26, so each quadrant is 6.5.
This approach relies on the required output resembling an ellipse sufficiently that a valid mapping can be achieved.
Try it online!
edited Mar 20 at 22:23
answered Mar 19 at 23:59
Level River StLevel River St
20.4k32680
20.4k32680
$begingroup$
Instead of"i".to_c
can you just do1i
?
$endgroup$
– Jordan
Mar 20 at 15:04
$begingroup$
@Jordan thanks, I've not seen that syntax before!
$endgroup$
– Level River St
Mar 20 at 22:29
add a comment |
$begingroup$
Instead of"i".to_c
can you just do1i
?
$endgroup$
– Jordan
Mar 20 at 15:04
$begingroup$
@Jordan thanks, I've not seen that syntax before!
$endgroup$
– Level River St
Mar 20 at 22:29
$begingroup$
Instead of
"i".to_c
can you just do 1i
?$endgroup$
– Jordan
Mar 20 at 15:04
$begingroup$
Instead of
"i".to_c
can you just do 1i
?$endgroup$
– Jordan
Mar 20 at 15:04
$begingroup$
@Jordan thanks, I've not seen that syntax before!
$endgroup$
– Level River St
Mar 20 at 22:29
$begingroup$
@Jordan thanks, I've not seen that syntax before!
$endgroup$
– Level River St
Mar 20 at 22:29
add a comment |
$begingroup$
Charcoal, 33 bytes
GH→→↘→↘↓↓77←←←←↖←↖↑↑↗→↗→→²✂⁺αα⌕αS
Try it online! Link is to verbose version of code. Explanation:
GH
Trace a path.
→→↘→↘↓↓77←←←←↖←↖↑↑↗→↗→→
Outline the bowl. Each 7
expands to ↙←
.
²
Move one character at a time (this API overlaps each line's ends with the next).
✂⁺αα⌕αS
Draw using the doubled alphabet, but starting at the position of the input character.
$endgroup$
add a comment |
$begingroup$
Charcoal, 33 bytes
GH→→↘→↘↓↓77←←←←↖←↖↑↑↗→↗→→²✂⁺αα⌕αS
Try it online! Link is to verbose version of code. Explanation:
GH
Trace a path.
→→↘→↘↓↓77←←←←↖←↖↑↑↗→↗→→
Outline the bowl. Each 7
expands to ↙←
.
²
Move one character at a time (this API overlaps each line's ends with the next).
✂⁺αα⌕αS
Draw using the doubled alphabet, but starting at the position of the input character.
$endgroup$
add a comment |
$begingroup$
Charcoal, 33 bytes
GH→→↘→↘↓↓77←←←←↖←↖↑↑↗→↗→→²✂⁺αα⌕αS
Try it online! Link is to verbose version of code. Explanation:
GH
Trace a path.
→→↘→↘↓↓77←←←←↖←↖↑↑↗→↗→→
Outline the bowl. Each 7
expands to ↙←
.
²
Move one character at a time (this API overlaps each line's ends with the next).
✂⁺αα⌕αS
Draw using the doubled alphabet, but starting at the position of the input character.
$endgroup$
Charcoal, 33 bytes
GH→→↘→↘↓↓77←←←←↖←↖↑↑↗→↗→→²✂⁺αα⌕αS
Try it online! Link is to verbose version of code. Explanation:
GH
Trace a path.
→→↘→↘↓↓77←←←←↖←↖↑↑↗→↗→→
Outline the bowl. Each 7
expands to ↙←
.
²
Move one character at a time (this API overlaps each line's ends with the next).
✂⁺αα⌕αS
Draw using the doubled alphabet, but starting at the position of the input character.
answered Mar 20 at 0:01
NeilNeil
82k745178
82k745178
add a comment |
add a comment |
$begingroup$
MATL, 49 bytes
7I8*32tvB[1b]&Zvc2Y2j7+_YSy&f7-w4-_Z;YPE,&S])yg(
What a mess. But it was fun writing. There's even an arctangent involved.
Try it online!
Explanation
The code
7I8*32tvB
creates an array of numbers and converts them to binary. This gives the zero-one matrix
0 0 0 1 1 1
0 1 1 0 0 0
1 0 0 0 0 0
1 0 0 0 0 0
which is the top left quadrant of a matrix specfying the positions of the letters.
[1b]&Zv
reflects that quadrant vertically without repeating the last row, and horizontally repeating the last column to produce the full matrix:
0 0 0 1 1 1 1 1 1 0 0 0
0 1 1 0 0 0 0 0 0 1 1 0
1 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 1
0 1 1 0 0 0 0 0 0 1 1 0
0 0 0 1 1 1 1 1 1 0 0 0
We now have a mask with the positions. The code
c
converts this to char, because the final result will be a char matrix. Character 0 is displayed as space, and the nonzero entries will be written with the appropriate letters.
2Y2
pushes the string 'abc···xyz'
, which contains the 26 letters. This string needs to be circularly shifted as per the input. To do that,
j7+_YS
reads the input letter, adds 7 to its ASCII code, and negates the result. For input 'a'
this gives −104, which is a multiple of 26, so circularly shifting by this amount will do nothing. If the input is b
this gives −105, which shifts the string 1 step to the left to produce 'bcd···yza'
; etc.
The next step is to define the order in which the shifted string will be written into the nonzero entries of the matrix. To this end,
y&f
creates a copy of the matrix and pushes two vectors containing the 1-based row and column positions of the nonzeros. Then
7-w4-_
subtracts 7 from the latter, brings the former to top, substracts 4 from it, and negates it. The 7 and 4 specify an origin of coordinates, so that the angles of the position vectors of the nonzero entries with respect to that origin define the desired order.
Z;YPE
computes the two-argument arctangent modulo 2*pi to produce those angles. Now the smallest angle, which is 0, corresponds to the entry where the first letter should go, and the rest advance counter-clockwise.
,&S])
rearranges the letters in the string according to those angles, so that when the letters are written into the nonzero entries of the matrix in column-major order (down, then across) the result will be correct. This is done by
yg(
For example, if the input is 'a'
the string was not circularly shifted:
abcdefghijklmnopqrstuvwxyz
The rearranging as per the angles transforms this into
utsvrwqxpyoznamblckdjeifgh
so that 'u'
will correctly go to the first (in column-major order) nonzero entry, which is (3,1) in matrix notation; 't'
will go to (4,1), 's'
to (5,1); 'v'
to (2,2) etc:
······
v· ··
u ·
t ·
s ·
·· ··
······
$endgroup$
$begingroup$
@EriktheOutgolfer I finally found some time to add an explanation
$endgroup$
– Luis Mendo
2 days ago
1
$begingroup$
Woah... I actually thought you abandoned this because you deleted that comment. :P
$endgroup$
– Erik the Outgolfer
2 days ago
add a comment |
$begingroup$
MATL, 49 bytes
7I8*32tvB[1b]&Zvc2Y2j7+_YSy&f7-w4-_Z;YPE,&S])yg(
What a mess. But it was fun writing. There's even an arctangent involved.
Try it online!
Explanation
The code
7I8*32tvB
creates an array of numbers and converts them to binary. This gives the zero-one matrix
0 0 0 1 1 1
0 1 1 0 0 0
1 0 0 0 0 0
1 0 0 0 0 0
which is the top left quadrant of a matrix specfying the positions of the letters.
[1b]&Zv
reflects that quadrant vertically without repeating the last row, and horizontally repeating the last column to produce the full matrix:
0 0 0 1 1 1 1 1 1 0 0 0
0 1 1 0 0 0 0 0 0 1 1 0
1 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 1
0 1 1 0 0 0 0 0 0 1 1 0
0 0 0 1 1 1 1 1 1 0 0 0
We now have a mask with the positions. The code
c
converts this to char, because the final result will be a char matrix. Character 0 is displayed as space, and the nonzero entries will be written with the appropriate letters.
2Y2
pushes the string 'abc···xyz'
, which contains the 26 letters. This string needs to be circularly shifted as per the input. To do that,
j7+_YS
reads the input letter, adds 7 to its ASCII code, and negates the result. For input 'a'
this gives −104, which is a multiple of 26, so circularly shifting by this amount will do nothing. If the input is b
this gives −105, which shifts the string 1 step to the left to produce 'bcd···yza'
; etc.
The next step is to define the order in which the shifted string will be written into the nonzero entries of the matrix. To this end,
y&f
creates a copy of the matrix and pushes two vectors containing the 1-based row and column positions of the nonzeros. Then
7-w4-_
subtracts 7 from the latter, brings the former to top, substracts 4 from it, and negates it. The 7 and 4 specify an origin of coordinates, so that the angles of the position vectors of the nonzero entries with respect to that origin define the desired order.
Z;YPE
computes the two-argument arctangent modulo 2*pi to produce those angles. Now the smallest angle, which is 0, corresponds to the entry where the first letter should go, and the rest advance counter-clockwise.
,&S])
rearranges the letters in the string according to those angles, so that when the letters are written into the nonzero entries of the matrix in column-major order (down, then across) the result will be correct. This is done by
yg(
For example, if the input is 'a'
the string was not circularly shifted:
abcdefghijklmnopqrstuvwxyz
The rearranging as per the angles transforms this into
utsvrwqxpyoznamblckdjeifgh
so that 'u'
will correctly go to the first (in column-major order) nonzero entry, which is (3,1) in matrix notation; 't'
will go to (4,1), 's'
to (5,1); 'v'
to (2,2) etc:
······
v· ··
u ·
t ·
s ·
·· ··
······
$endgroup$
$begingroup$
@EriktheOutgolfer I finally found some time to add an explanation
$endgroup$
– Luis Mendo
2 days ago
1
$begingroup$
Woah... I actually thought you abandoned this because you deleted that comment. :P
$endgroup$
– Erik the Outgolfer
2 days ago
add a comment |
$begingroup$
MATL, 49 bytes
7I8*32tvB[1b]&Zvc2Y2j7+_YSy&f7-w4-_Z;YPE,&S])yg(
What a mess. But it was fun writing. There's even an arctangent involved.
Try it online!
Explanation
The code
7I8*32tvB
creates an array of numbers and converts them to binary. This gives the zero-one matrix
0 0 0 1 1 1
0 1 1 0 0 0
1 0 0 0 0 0
1 0 0 0 0 0
which is the top left quadrant of a matrix specfying the positions of the letters.
[1b]&Zv
reflects that quadrant vertically without repeating the last row, and horizontally repeating the last column to produce the full matrix:
0 0 0 1 1 1 1 1 1 0 0 0
0 1 1 0 0 0 0 0 0 1 1 0
1 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 1
0 1 1 0 0 0 0 0 0 1 1 0
0 0 0 1 1 1 1 1 1 0 0 0
We now have a mask with the positions. The code
c
converts this to char, because the final result will be a char matrix. Character 0 is displayed as space, and the nonzero entries will be written with the appropriate letters.
2Y2
pushes the string 'abc···xyz'
, which contains the 26 letters. This string needs to be circularly shifted as per the input. To do that,
j7+_YS
reads the input letter, adds 7 to its ASCII code, and negates the result. For input 'a'
this gives −104, which is a multiple of 26, so circularly shifting by this amount will do nothing. If the input is b
this gives −105, which shifts the string 1 step to the left to produce 'bcd···yza'
; etc.
The next step is to define the order in which the shifted string will be written into the nonzero entries of the matrix. To this end,
y&f
creates a copy of the matrix and pushes two vectors containing the 1-based row and column positions of the nonzeros. Then
7-w4-_
subtracts 7 from the latter, brings the former to top, substracts 4 from it, and negates it. The 7 and 4 specify an origin of coordinates, so that the angles of the position vectors of the nonzero entries with respect to that origin define the desired order.
Z;YPE
computes the two-argument arctangent modulo 2*pi to produce those angles. Now the smallest angle, which is 0, corresponds to the entry where the first letter should go, and the rest advance counter-clockwise.
,&S])
rearranges the letters in the string according to those angles, so that when the letters are written into the nonzero entries of the matrix in column-major order (down, then across) the result will be correct. This is done by
yg(
For example, if the input is 'a'
the string was not circularly shifted:
abcdefghijklmnopqrstuvwxyz
The rearranging as per the angles transforms this into
utsvrwqxpyoznamblckdjeifgh
so that 'u'
will correctly go to the first (in column-major order) nonzero entry, which is (3,1) in matrix notation; 't'
will go to (4,1), 's'
to (5,1); 'v'
to (2,2) etc:
······
v· ··
u ·
t ·
s ·
·· ··
······
$endgroup$
MATL, 49 bytes
7I8*32tvB[1b]&Zvc2Y2j7+_YSy&f7-w4-_Z;YPE,&S])yg(
What a mess. But it was fun writing. There's even an arctangent involved.
Try it online!
Explanation
The code
7I8*32tvB
creates an array of numbers and converts them to binary. This gives the zero-one matrix
0 0 0 1 1 1
0 1 1 0 0 0
1 0 0 0 0 0
1 0 0 0 0 0
which is the top left quadrant of a matrix specfying the positions of the letters.
[1b]&Zv
reflects that quadrant vertically without repeating the last row, and horizontally repeating the last column to produce the full matrix:
0 0 0 1 1 1 1 1 1 0 0 0
0 1 1 0 0 0 0 0 0 1 1 0
1 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 1
0 1 1 0 0 0 0 0 0 1 1 0
0 0 0 1 1 1 1 1 1 0 0 0
We now have a mask with the positions. The code
c
converts this to char, because the final result will be a char matrix. Character 0 is displayed as space, and the nonzero entries will be written with the appropriate letters.
2Y2
pushes the string 'abc···xyz'
, which contains the 26 letters. This string needs to be circularly shifted as per the input. To do that,
j7+_YS
reads the input letter, adds 7 to its ASCII code, and negates the result. For input 'a'
this gives −104, which is a multiple of 26, so circularly shifting by this amount will do nothing. If the input is b
this gives −105, which shifts the string 1 step to the left to produce 'bcd···yza'
; etc.
The next step is to define the order in which the shifted string will be written into the nonzero entries of the matrix. To this end,
y&f
creates a copy of the matrix and pushes two vectors containing the 1-based row and column positions of the nonzeros. Then
7-w4-_
subtracts 7 from the latter, brings the former to top, substracts 4 from it, and negates it. The 7 and 4 specify an origin of coordinates, so that the angles of the position vectors of the nonzero entries with respect to that origin define the desired order.
Z;YPE
computes the two-argument arctangent modulo 2*pi to produce those angles. Now the smallest angle, which is 0, corresponds to the entry where the first letter should go, and the rest advance counter-clockwise.
,&S])
rearranges the letters in the string according to those angles, so that when the letters are written into the nonzero entries of the matrix in column-major order (down, then across) the result will be correct. This is done by
yg(
For example, if the input is 'a'
the string was not circularly shifted:
abcdefghijklmnopqrstuvwxyz
The rearranging as per the angles transforms this into
utsvrwqxpyoznamblckdjeifgh
so that 'u'
will correctly go to the first (in column-major order) nonzero entry, which is (3,1) in matrix notation; 't'
will go to (4,1), 's'
to (5,1); 'v'
to (2,2) etc:
······
v· ··
u ·
t ·
s ·
·· ··
······
edited 2 days ago
answered Mar 19 at 22:23
Luis MendoLuis Mendo
75k888291
75k888291
$begingroup$
@EriktheOutgolfer I finally found some time to add an explanation
$endgroup$
– Luis Mendo
2 days ago
1
$begingroup$
Woah... I actually thought you abandoned this because you deleted that comment. :P
$endgroup$
– Erik the Outgolfer
2 days ago
add a comment |
$begingroup$
@EriktheOutgolfer I finally found some time to add an explanation
$endgroup$
– Luis Mendo
2 days ago
1
$begingroup$
Woah... I actually thought you abandoned this because you deleted that comment. :P
$endgroup$
– Erik the Outgolfer
2 days ago
$begingroup$
@EriktheOutgolfer I finally found some time to add an explanation
$endgroup$
– Luis Mendo
2 days ago
$begingroup$
@EriktheOutgolfer I finally found some time to add an explanation
$endgroup$
– Luis Mendo
2 days ago
1
1
$begingroup$
Woah... I actually thought you abandoned this because you deleted that comment. :P
$endgroup$
– Erik the Outgolfer
2 days ago
$begingroup$
Woah... I actually thought you abandoned this because you deleted that comment. :P
$endgroup$
– Erik the Outgolfer
2 days ago
add a comment |
$begingroup$
Python 2, 129 bytes
lambda x:''.join((i,chr((ord(x)+ord(i))%26+65),' '*5)[ord(i)/46]for i in''' XYZABC
VW] DE
U]]F
T]]G
S]]H
RQ] JI
PONMLK''')
Try it online!
$endgroup$
add a comment |
$begingroup$
Python 2, 129 bytes
lambda x:''.join((i,chr((ord(x)+ord(i))%26+65),' '*5)[ord(i)/46]for i in''' XYZABC
VW] DE
U]]F
T]]G
S]]H
RQ] JI
PONMLK''')
Try it online!
$endgroup$
add a comment |
$begingroup$
Python 2, 129 bytes
lambda x:''.join((i,chr((ord(x)+ord(i))%26+65),' '*5)[ord(i)/46]for i in''' XYZABC
VW] DE
U]]F
T]]G
S]]H
RQ] JI
PONMLK''')
Try it online!
$endgroup$
Python 2, 129 bytes
lambda x:''.join((i,chr((ord(x)+ord(i))%26+65),' '*5)[ord(i)/46]for i in''' XYZABC
VW] DE
U]]F
T]]G
S]]H
RQ] JI
PONMLK''')
Try it online!
answered Mar 19 at 22:23
Erik the OutgolferErik the Outgolfer
32.7k429105
32.7k429105
add a comment |
add a comment |
$begingroup$
R, 139 122 bytes
-17 bytes thanks to Giuseppe
u=utf8ToInt;`*`=rep;o=c(' '*12,'
')*7;o[u(" &3@LKWVUTSRDC5(")]=LETTERS[(13:38+u(scan(,'')))%%26+1];cat(o,sep='')
Explanation:
o=rep(c(rep(' ',12),'
'),7)
Builds an empty box of spaces
u(" &3@LKWVUTSRDC5(")
is a set of indices for letter positions corresponding to:
c(7:9,23,24,38,51,64,76,75,87:82,68,67,53,40,27,15,16,4:6)
TIO
$endgroup$
1
$begingroup$
you never useintToUtf8
so those are extraneous bytes, but if you use*
in place ofrep
, you can get save 2 bytes and get to 125 bytes
$endgroup$
– Giuseppe
Mar 20 at 18:00
1
$begingroup$
Oh, and using the low-byte characters instead of printable ascii you can shave off the-32
, for 122 bytes. You can generate them yourself by usingcat(intToUtf8(bytes))
.
$endgroup$
– Giuseppe
Mar 20 at 18:03
$begingroup$
@Giuseppe I was pretty sure I had already removed theintToUtf8
, too many versions of the function open at once I guess. Nice saves all roundthough, thanks
$endgroup$
– Aaron Hayman
Mar 20 at 21:30
add a comment |
$begingroup$
R, 139 122 bytes
-17 bytes thanks to Giuseppe
u=utf8ToInt;`*`=rep;o=c(' '*12,'
')*7;o[u(" &3@LKWVUTSRDC5(")]=LETTERS[(13:38+u(scan(,'')))%%26+1];cat(o,sep='')
Explanation:
o=rep(c(rep(' ',12),'
'),7)
Builds an empty box of spaces
u(" &3@LKWVUTSRDC5(")
is a set of indices for letter positions corresponding to:
c(7:9,23,24,38,51,64,76,75,87:82,68,67,53,40,27,15,16,4:6)
TIO
$endgroup$
1
$begingroup$
you never useintToUtf8
so those are extraneous bytes, but if you use*
in place ofrep
, you can get save 2 bytes and get to 125 bytes
$endgroup$
– Giuseppe
Mar 20 at 18:00
1
$begingroup$
Oh, and using the low-byte characters instead of printable ascii you can shave off the-32
, for 122 bytes. You can generate them yourself by usingcat(intToUtf8(bytes))
.
$endgroup$
– Giuseppe
Mar 20 at 18:03
$begingroup$
@Giuseppe I was pretty sure I had already removed theintToUtf8
, too many versions of the function open at once I guess. Nice saves all roundthough, thanks
$endgroup$
– Aaron Hayman
Mar 20 at 21:30
add a comment |
$begingroup$
R, 139 122 bytes
-17 bytes thanks to Giuseppe
u=utf8ToInt;`*`=rep;o=c(' '*12,'
')*7;o[u(" &3@LKWVUTSRDC5(")]=LETTERS[(13:38+u(scan(,'')))%%26+1];cat(o,sep='')
Explanation:
o=rep(c(rep(' ',12),'
'),7)
Builds an empty box of spaces
u(" &3@LKWVUTSRDC5(")
is a set of indices for letter positions corresponding to:
c(7:9,23,24,38,51,64,76,75,87:82,68,67,53,40,27,15,16,4:6)
TIO
$endgroup$
R, 139 122 bytes
-17 bytes thanks to Giuseppe
u=utf8ToInt;`*`=rep;o=c(' '*12,'
')*7;o[u(" &3@LKWVUTSRDC5(")]=LETTERS[(13:38+u(scan(,'')))%%26+1];cat(o,sep='')
Explanation:
o=rep(c(rep(' ',12),'
'),7)
Builds an empty box of spaces
u(" &3@LKWVUTSRDC5(")
is a set of indices for letter positions corresponding to:
c(7:9,23,24,38,51,64,76,75,87:82,68,67,53,40,27,15,16,4:6)
TIO
edited Mar 20 at 21:37
answered Mar 20 at 17:53
Aaron HaymanAaron Hayman
2815
2815
1
$begingroup$
you never useintToUtf8
so those are extraneous bytes, but if you use*
in place ofrep
, you can get save 2 bytes and get to 125 bytes
$endgroup$
– Giuseppe
Mar 20 at 18:00
1
$begingroup$
Oh, and using the low-byte characters instead of printable ascii you can shave off the-32
, for 122 bytes. You can generate them yourself by usingcat(intToUtf8(bytes))
.
$endgroup$
– Giuseppe
Mar 20 at 18:03
$begingroup$
@Giuseppe I was pretty sure I had already removed theintToUtf8
, too many versions of the function open at once I guess. Nice saves all roundthough, thanks
$endgroup$
– Aaron Hayman
Mar 20 at 21:30
add a comment |
1
$begingroup$
you never useintToUtf8
so those are extraneous bytes, but if you use*
in place ofrep
, you can get save 2 bytes and get to 125 bytes
$endgroup$
– Giuseppe
Mar 20 at 18:00
1
$begingroup$
Oh, and using the low-byte characters instead of printable ascii you can shave off the-32
, for 122 bytes. You can generate them yourself by usingcat(intToUtf8(bytes))
.
$endgroup$
– Giuseppe
Mar 20 at 18:03
$begingroup$
@Giuseppe I was pretty sure I had already removed theintToUtf8
, too many versions of the function open at once I guess. Nice saves all roundthough, thanks
$endgroup$
– Aaron Hayman
Mar 20 at 21:30
1
1
$begingroup$
you never use
intToUtf8
so those are extraneous bytes, but if you use *
in place of rep
, you can get save 2 bytes and get to 125 bytes$endgroup$
– Giuseppe
Mar 20 at 18:00
$begingroup$
you never use
intToUtf8
so those are extraneous bytes, but if you use *
in place of rep
, you can get save 2 bytes and get to 125 bytes$endgroup$
– Giuseppe
Mar 20 at 18:00
1
1
$begingroup$
Oh, and using the low-byte characters instead of printable ascii you can shave off the
-32
, for 122 bytes. You can generate them yourself by using cat(intToUtf8(bytes))
.$endgroup$
– Giuseppe
Mar 20 at 18:03
$begingroup$
Oh, and using the low-byte characters instead of printable ascii you can shave off the
-32
, for 122 bytes. You can generate them yourself by using cat(intToUtf8(bytes))
.$endgroup$
– Giuseppe
Mar 20 at 18:03
$begingroup$
@Giuseppe I was pretty sure I had already removed the
intToUtf8
, too many versions of the function open at once I guess. Nice saves all roundthough, thanks$endgroup$
– Aaron Hayman
Mar 20 at 21:30
$begingroup$
@Giuseppe I was pretty sure I had already removed the
intToUtf8
, too many versions of the function open at once I guess. Nice saves all roundthough, thanks$endgroup$
– Aaron Hayman
Mar 20 at 21:30
add a comment |
$begingroup$
JavaScript (Node.js), 121 119 bytes
Saved 2 bytes thanks to @tsh
c=>`2XYZABC
0VW5DE
U9F
T9G
S9H
0RQ5JI
2PONMLK`.replace(/./g,x=>''.padEnd(+x+1)||(B=Buffer)([65+([a,b]=B(c+x),a+b)%26]))
Try it online!
How?
This code abuses Buffer
to extract the ASCII codes of the template letter $x$ and input letter $c$ and convert them back into the target letter.
Example with $c=$"H"
and $x=$"B"
// extracting the ASCII codes
Buffer(c + x) → Buffer("HB") → <Buffer 48 42>
// assigning them to variables
[a, b] = Buffer(c + x) → a = 0x48 (72) and b = 0x42 (66)
// computing the ASCII code of the target letter
65 + ((a + b) % 26) → 65 + (138 % 26) → 65 + 8 → 73
// turning it back into a character
Buffer([73]) → <Buffer 49> → implicitly coerced to "I" by replace()
$endgroup$
$begingroup$
119 bytes
$endgroup$
– tsh
Mar 20 at 5:56
add a comment |
$begingroup$
JavaScript (Node.js), 121 119 bytes
Saved 2 bytes thanks to @tsh
c=>`2XYZABC
0VW5DE
U9F
T9G
S9H
0RQ5JI
2PONMLK`.replace(/./g,x=>''.padEnd(+x+1)||(B=Buffer)([65+([a,b]=B(c+x),a+b)%26]))
Try it online!
How?
This code abuses Buffer
to extract the ASCII codes of the template letter $x$ and input letter $c$ and convert them back into the target letter.
Example with $c=$"H"
and $x=$"B"
// extracting the ASCII codes
Buffer(c + x) → Buffer("HB") → <Buffer 48 42>
// assigning them to variables
[a, b] = Buffer(c + x) → a = 0x48 (72) and b = 0x42 (66)
// computing the ASCII code of the target letter
65 + ((a + b) % 26) → 65 + (138 % 26) → 65 + 8 → 73
// turning it back into a character
Buffer([73]) → <Buffer 49> → implicitly coerced to "I" by replace()
$endgroup$
$begingroup$
119 bytes
$endgroup$
– tsh
Mar 20 at 5:56
add a comment |
$begingroup$
JavaScript (Node.js), 121 119 bytes
Saved 2 bytes thanks to @tsh
c=>`2XYZABC
0VW5DE
U9F
T9G
S9H
0RQ5JI
2PONMLK`.replace(/./g,x=>''.padEnd(+x+1)||(B=Buffer)([65+([a,b]=B(c+x),a+b)%26]))
Try it online!
How?
This code abuses Buffer
to extract the ASCII codes of the template letter $x$ and input letter $c$ and convert them back into the target letter.
Example with $c=$"H"
and $x=$"B"
// extracting the ASCII codes
Buffer(c + x) → Buffer("HB") → <Buffer 48 42>
// assigning them to variables
[a, b] = Buffer(c + x) → a = 0x48 (72) and b = 0x42 (66)
// computing the ASCII code of the target letter
65 + ((a + b) % 26) → 65 + (138 % 26) → 65 + 8 → 73
// turning it back into a character
Buffer([73]) → <Buffer 49> → implicitly coerced to "I" by replace()
$endgroup$
JavaScript (Node.js), 121 119 bytes
Saved 2 bytes thanks to @tsh
c=>`2XYZABC
0VW5DE
U9F
T9G
S9H
0RQ5JI
2PONMLK`.replace(/./g,x=>''.padEnd(+x+1)||(B=Buffer)([65+([a,b]=B(c+x),a+b)%26]))
Try it online!
How?
This code abuses Buffer
to extract the ASCII codes of the template letter $x$ and input letter $c$ and convert them back into the target letter.
Example with $c=$"H"
and $x=$"B"
// extracting the ASCII codes
Buffer(c + x) → Buffer("HB") → <Buffer 48 42>
// assigning them to variables
[a, b] = Buffer(c + x) → a = 0x48 (72) and b = 0x42 (66)
// computing the ASCII code of the target letter
65 + ((a + b) % 26) → 65 + (138 % 26) → 65 + 8 → 73
// turning it back into a character
Buffer([73]) → <Buffer 49> → implicitly coerced to "I" by replace()
edited Mar 20 at 13:18
answered Mar 19 at 22:19
ArnauldArnauld
79.6k796330
79.6k796330
$begingroup$
119 bytes
$endgroup$
– tsh
Mar 20 at 5:56
add a comment |
$begingroup$
119 bytes
$endgroup$
– tsh
Mar 20 at 5:56
$begingroup$
119 bytes
$endgroup$
– tsh
Mar 20 at 5:56
$begingroup$
119 bytes
$endgroup$
– tsh
Mar 20 at 5:56
add a comment |
$begingroup$
APL+WIN, 72 bytes
Prompts for character
m←7 12⍴' '⋄n←(7⍴2)⊤v,⌽v←(⍳3)/28 34 65⋄((,n)/,m)←(22+s⍳⎕)⌽s←⎕av[65+⍳26]⋄m
Try it online!Coutesy of Dyalog Classic
$endgroup$
add a comment |
$begingroup$
APL+WIN, 72 bytes
Prompts for character
m←7 12⍴' '⋄n←(7⍴2)⊤v,⌽v←(⍳3)/28 34 65⋄((,n)/,m)←(22+s⍳⎕)⌽s←⎕av[65+⍳26]⋄m
Try it online!Coutesy of Dyalog Classic
$endgroup$
add a comment |
$begingroup$
APL+WIN, 72 bytes
Prompts for character
m←7 12⍴' '⋄n←(7⍴2)⊤v,⌽v←(⍳3)/28 34 65⋄((,n)/,m)←(22+s⍳⎕)⌽s←⎕av[65+⍳26]⋄m
Try it online!Coutesy of Dyalog Classic
$endgroup$
APL+WIN, 72 bytes
Prompts for character
m←7 12⍴' '⋄n←(7⍴2)⊤v,⌽v←(⍳3)/28 34 65⋄((,n)/,m)←(22+s⍳⎕)⌽s←⎕av[65+⍳26]⋄m
Try it online!Coutesy of Dyalog Classic
answered Mar 20 at 7:12
GrahamGraham
2,61678
2,61678
add a comment |
add a comment |
$begingroup$
R, 218 197 bytes
-21 bytes thanks to Giuseppe
function(t,l=letters,`*`=rep,s=" ",n="
",`~`=`[`,r=c(l~l>=t,l))cat(s*3,r~24:26,r~1:3,n,s,r~22:23,q<-s*6,r~4:5,n,r~21,u<-s*10,r~6,n,r~20,u,r~7,n,r~19,u,r~8,n,s,r~17:18,q,r~10:9,n,s*3,r~16:11,sep='')
Try it online!
Ungolfed:
alphasoup <- function(startlet){
startnum <- which(l == startlet)
rotatedletters <- c(letters[startnum:26], letters[1:(startnum -1)])[1:26]
cat(' ',rotatedletters[24:26],rotatedletters[1:3], 'n ',
rotatedletters[22:23], s6 <- ' ', rotatedletters[4:5], 'n',
rotatedletters[21], s10 <- rep(' ', 10), rotatedletters[6], 'n',
rotatedletters[20], s10, rotatedletters[7], 'n',
rotatedletters[19], s10, rotatedletters[8], 'n ',
rotatedletters[17:18], s6, rotatedletters[10:9], 'n ',
rotatedletters[16:11],
sep = '')
}
Created rotated letter vector and uses cat
to fill out rim of bowl with that vector.
$endgroup$
$begingroup$
203 bytes if you don't mind one-line monstrosities; the biggest improvement was probably removing thewhich
and usingl>=t
as the index directly, which was worth 12 bytes.
$endgroup$
– Giuseppe
Mar 20 at 17:52
2
$begingroup$
198 bytes by aliasing[
with~
. This is a great answer; I was spending about 250 bytes in my first few attempts with a much more complex approach.
$endgroup$
– Giuseppe
Mar 20 at 17:56
$begingroup$
Ah, that's clever, I forget about string comparisons.
$endgroup$
– CT Hall
Mar 20 at 17:56
add a comment |
$begingroup$
R, 218 197 bytes
-21 bytes thanks to Giuseppe
function(t,l=letters,`*`=rep,s=" ",n="
",`~`=`[`,r=c(l~l>=t,l))cat(s*3,r~24:26,r~1:3,n,s,r~22:23,q<-s*6,r~4:5,n,r~21,u<-s*10,r~6,n,r~20,u,r~7,n,r~19,u,r~8,n,s,r~17:18,q,r~10:9,n,s*3,r~16:11,sep='')
Try it online!
Ungolfed:
alphasoup <- function(startlet){
startnum <- which(l == startlet)
rotatedletters <- c(letters[startnum:26], letters[1:(startnum -1)])[1:26]
cat(' ',rotatedletters[24:26],rotatedletters[1:3], 'n ',
rotatedletters[22:23], s6 <- ' ', rotatedletters[4:5], 'n',
rotatedletters[21], s10 <- rep(' ', 10), rotatedletters[6], 'n',
rotatedletters[20], s10, rotatedletters[7], 'n',
rotatedletters[19], s10, rotatedletters[8], 'n ',
rotatedletters[17:18], s6, rotatedletters[10:9], 'n ',
rotatedletters[16:11],
sep = '')
}
Created rotated letter vector and uses cat
to fill out rim of bowl with that vector.
$endgroup$
$begingroup$
203 bytes if you don't mind one-line monstrosities; the biggest improvement was probably removing thewhich
and usingl>=t
as the index directly, which was worth 12 bytes.
$endgroup$
– Giuseppe
Mar 20 at 17:52
2
$begingroup$
198 bytes by aliasing[
with~
. This is a great answer; I was spending about 250 bytes in my first few attempts with a much more complex approach.
$endgroup$
– Giuseppe
Mar 20 at 17:56
$begingroup$
Ah, that's clever, I forget about string comparisons.
$endgroup$
– CT Hall
Mar 20 at 17:56
add a comment |
$begingroup$
R, 218 197 bytes
-21 bytes thanks to Giuseppe
function(t,l=letters,`*`=rep,s=" ",n="
",`~`=`[`,r=c(l~l>=t,l))cat(s*3,r~24:26,r~1:3,n,s,r~22:23,q<-s*6,r~4:5,n,r~21,u<-s*10,r~6,n,r~20,u,r~7,n,r~19,u,r~8,n,s,r~17:18,q,r~10:9,n,s*3,r~16:11,sep='')
Try it online!
Ungolfed:
alphasoup <- function(startlet){
startnum <- which(l == startlet)
rotatedletters <- c(letters[startnum:26], letters[1:(startnum -1)])[1:26]
cat(' ',rotatedletters[24:26],rotatedletters[1:3], 'n ',
rotatedletters[22:23], s6 <- ' ', rotatedletters[4:5], 'n',
rotatedletters[21], s10 <- rep(' ', 10), rotatedletters[6], 'n',
rotatedletters[20], s10, rotatedletters[7], 'n',
rotatedletters[19], s10, rotatedletters[8], 'n ',
rotatedletters[17:18], s6, rotatedletters[10:9], 'n ',
rotatedletters[16:11],
sep = '')
}
Created rotated letter vector and uses cat
to fill out rim of bowl with that vector.
$endgroup$
R, 218 197 bytes
-21 bytes thanks to Giuseppe
function(t,l=letters,`*`=rep,s=" ",n="
",`~`=`[`,r=c(l~l>=t,l))cat(s*3,r~24:26,r~1:3,n,s,r~22:23,q<-s*6,r~4:5,n,r~21,u<-s*10,r~6,n,r~20,u,r~7,n,r~19,u,r~8,n,s,r~17:18,q,r~10:9,n,s*3,r~16:11,sep='')
Try it online!
Ungolfed:
alphasoup <- function(startlet){
startnum <- which(l == startlet)
rotatedletters <- c(letters[startnum:26], letters[1:(startnum -1)])[1:26]
cat(' ',rotatedletters[24:26],rotatedletters[1:3], 'n ',
rotatedletters[22:23], s6 <- ' ', rotatedletters[4:5], 'n',
rotatedletters[21], s10 <- rep(' ', 10), rotatedletters[6], 'n',
rotatedletters[20], s10, rotatedletters[7], 'n',
rotatedletters[19], s10, rotatedletters[8], 'n ',
rotatedletters[17:18], s6, rotatedletters[10:9], 'n ',
rotatedletters[16:11],
sep = '')
}
Created rotated letter vector and uses cat
to fill out rim of bowl with that vector.
edited Mar 20 at 18:05
answered Mar 20 at 15:26
CT HallCT Hall
46110
46110
$begingroup$
203 bytes if you don't mind one-line monstrosities; the biggest improvement was probably removing thewhich
and usingl>=t
as the index directly, which was worth 12 bytes.
$endgroup$
– Giuseppe
Mar 20 at 17:52
2
$begingroup$
198 bytes by aliasing[
with~
. This is a great answer; I was spending about 250 bytes in my first few attempts with a much more complex approach.
$endgroup$
– Giuseppe
Mar 20 at 17:56
$begingroup$
Ah, that's clever, I forget about string comparisons.
$endgroup$
– CT Hall
Mar 20 at 17:56
add a comment |
$begingroup$
203 bytes if you don't mind one-line monstrosities; the biggest improvement was probably removing thewhich
and usingl>=t
as the index directly, which was worth 12 bytes.
$endgroup$
– Giuseppe
Mar 20 at 17:52
2
$begingroup$
198 bytes by aliasing[
with~
. This is a great answer; I was spending about 250 bytes in my first few attempts with a much more complex approach.
$endgroup$
– Giuseppe
Mar 20 at 17:56
$begingroup$
Ah, that's clever, I forget about string comparisons.
$endgroup$
– CT Hall
Mar 20 at 17:56
$begingroup$
203 bytes if you don't mind one-line monstrosities; the biggest improvement was probably removing the
which
and using l>=t
as the index directly, which was worth 12 bytes.$endgroup$
– Giuseppe
Mar 20 at 17:52
$begingroup$
203 bytes if you don't mind one-line monstrosities; the biggest improvement was probably removing the
which
and using l>=t
as the index directly, which was worth 12 bytes.$endgroup$
– Giuseppe
Mar 20 at 17:52
2
2
$begingroup$
198 bytes by aliasing
[
with ~
. This is a great answer; I was spending about 250 bytes in my first few attempts with a much more complex approach.$endgroup$
– Giuseppe
Mar 20 at 17:56
$begingroup$
198 bytes by aliasing
[
with ~
. This is a great answer; I was spending about 250 bytes in my first few attempts with a much more complex approach.$endgroup$
– Giuseppe
Mar 20 at 17:56
$begingroup$
Ah, that's clever, I forget about string comparisons.
$endgroup$
– CT Hall
Mar 20 at 17:56
$begingroup$
Ah, that's clever, I forget about string comparisons.
$endgroup$
– CT Hall
Mar 20 at 17:56
add a comment |
$begingroup$
Wolfram Language (Mathematica), 258 bytes
(t[x_]:=Table[" ",x];w=RotateRight[Alphabet,4-LetterNumber@#];j=Join;a[x_,y_]:=j[{w[[x]]},t@10,{w[[y]]}];b[m_,n_]:=j[t@1,w[[m;;m+1]],t@6,w[[n;;n+1]],t@1];""<>#&/@{j[t@3,w[[1;;6]]],b[25,7],a[24,9],a[23,10],a[22,11],Reverse@b[12,20],j[t@3,w[[19;;14;;-1]]]})&
Try it online!
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 258 bytes
(t[x_]:=Table[" ",x];w=RotateRight[Alphabet,4-LetterNumber@#];j=Join;a[x_,y_]:=j[{w[[x]]},t@10,{w[[y]]}];b[m_,n_]:=j[t@1,w[[m;;m+1]],t@6,w[[n;;n+1]],t@1];""<>#&/@{j[t@3,w[[1;;6]]],b[25,7],a[24,9],a[23,10],a[22,11],Reverse@b[12,20],j[t@3,w[[19;;14;;-1]]]})&
Try it online!
$endgroup$
add a comment |
$begingroup$
Wolfram Language (Mathematica), 258 bytes
(t[x_]:=Table[" ",x];w=RotateRight[Alphabet,4-LetterNumber@#];j=Join;a[x_,y_]:=j[{w[[x]]},t@10,{w[[y]]}];b[m_,n_]:=j[t@1,w[[m;;m+1]],t@6,w[[n;;n+1]],t@1];""<>#&/@{j[t@3,w[[1;;6]]],b[25,7],a[24,9],a[23,10],a[22,11],Reverse@b[12,20],j[t@3,w[[19;;14;;-1]]]})&
Try it online!
$endgroup$
Wolfram Language (Mathematica), 258 bytes
(t[x_]:=Table[" ",x];w=RotateRight[Alphabet,4-LetterNumber@#];j=Join;a[x_,y_]:=j[{w[[x]]},t@10,{w[[y]]}];b[m_,n_]:=j[t@1,w[[m;;m+1]],t@6,w[[n;;n+1]],t@1];""<>#&/@{j[t@3,w[[1;;6]]],b[25,7],a[24,9],a[23,10],a[22,11],Reverse@b[12,20],j[t@3,w[[19;;14;;-1]]]})&
Try it online!
answered Mar 19 at 23:08
J42161217J42161217
13.5k21252
13.5k21252
add a comment |
add a comment |
$begingroup$
Haskell, 127 bytes
("cXYZABC aVWfDE UjF TjG SjH aRQfJI cPONMLK">>=).(?)
t?c|c>'Z'=' '<$['a'..c]|c<'!'="n"|t<'B'=[c]|c>'Y'=t?'@'|1<2=pred t?succ c
Try it online!
Each character in the encoded string is decoded by function ?
into a string:
t?c -- 't' is the starting char,
-- 'c' the char from the encoded string
|c>'Z'=' '<$['a'..c] -- if 'c' is a lowercase letter, return some spaces
-- 'a': one, 'b': two, etc
|c<'!'="n" -- if 'c' is a space, return a newline
|t<'B'=[c] -- if 't' is the letter A, return 'c'
|c>'Y'=t?'@' -- wrap around Z
|1<2=pred t?succ c -- else the result is the same as starting one letter
-- earlier (pred t) but looking at the successor of 'c'
$endgroup$
add a comment |
$begingroup$
Haskell, 127 bytes
("cXYZABC aVWfDE UjF TjG SjH aRQfJI cPONMLK">>=).(?)
t?c|c>'Z'=' '<$['a'..c]|c<'!'="n"|t<'B'=[c]|c>'Y'=t?'@'|1<2=pred t?succ c
Try it online!
Each character in the encoded string is decoded by function ?
into a string:
t?c -- 't' is the starting char,
-- 'c' the char from the encoded string
|c>'Z'=' '<$['a'..c] -- if 'c' is a lowercase letter, return some spaces
-- 'a': one, 'b': two, etc
|c<'!'="n" -- if 'c' is a space, return a newline
|t<'B'=[c] -- if 't' is the letter A, return 'c'
|c>'Y'=t?'@' -- wrap around Z
|1<2=pred t?succ c -- else the result is the same as starting one letter
-- earlier (pred t) but looking at the successor of 'c'
$endgroup$
add a comment |
$begingroup$
Haskell, 127 bytes
("cXYZABC aVWfDE UjF TjG SjH aRQfJI cPONMLK">>=).(?)
t?c|c>'Z'=' '<$['a'..c]|c<'!'="n"|t<'B'=[c]|c>'Y'=t?'@'|1<2=pred t?succ c
Try it online!
Each character in the encoded string is decoded by function ?
into a string:
t?c -- 't' is the starting char,
-- 'c' the char from the encoded string
|c>'Z'=' '<$['a'..c] -- if 'c' is a lowercase letter, return some spaces
-- 'a': one, 'b': two, etc
|c<'!'="n" -- if 'c' is a space, return a newline
|t<'B'=[c] -- if 't' is the letter A, return 'c'
|c>'Y'=t?'@' -- wrap around Z
|1<2=pred t?succ c -- else the result is the same as starting one letter
-- earlier (pred t) but looking at the successor of 'c'
$endgroup$
Haskell, 127 bytes
("cXYZABC aVWfDE UjF TjG SjH aRQfJI cPONMLK">>=).(?)
t?c|c>'Z'=' '<$['a'..c]|c<'!'="n"|t<'B'=[c]|c>'Y'=t?'@'|1<2=pred t?succ c
Try it online!
Each character in the encoded string is decoded by function ?
into a string:
t?c -- 't' is the starting char,
-- 'c' the char from the encoded string
|c>'Z'=' '<$['a'..c] -- if 'c' is a lowercase letter, return some spaces
-- 'a': one, 'b': two, etc
|c<'!'="n" -- if 'c' is a space, return a newline
|t<'B'=[c] -- if 't' is the letter A, return 'c'
|c>'Y'=t?'@' -- wrap around Z
|1<2=pred t?succ c -- else the result is the same as starting one letter
-- earlier (pred t) but looking at the successor of 'c'
answered Mar 20 at 22:21
niminimi
32.4k32389
32.4k32389
add a comment |
add a comment |
$begingroup$
Java 11, 134 bytes
c->"2XYZABC_0VW5DE_U9F_T9G_S9H_0RQ5JI_2PONMLK".chars().forEach(i->System.out.print(i<59?" ".repeat(i-47):(char)(i>90?10:(c+i)%26+65)))
Try it online.
136 bytes version with potential to be golfed?
c->"2XYZABC_0VW5DE_U9F_T9G_S9H_0RQ5JI_2PONMLK".chars().forEach(i->System.out.printf("%"+(i<59?i-47:"")+"c",i>90?10:i<59?32:(c+i)%26+65))
Try it online.
Explanation (of the first answer)
c-> // Method with character parameter and no return-type
"2XYZABC_0VW5DE_U9F_T9G_S9H_0RQ5JI_2PONMLK"
// Template-String
.chars().forEach(i-> // Loop over the unicode values of its characters:
System.out.print( // Print:
i<59? // If the value is below 59 (so a digit character):
" ".repeat(i-47) // Repeat a space that digit + 1 amount of times
:(char)(i>90? // Else-if the value is above 90 (an underscore character):
10 // Print a newline
: // Else:
(c+i) // Add the current value and the input together
%26 // Take modulo-26 of it to get the index in the alphabet
+65))) // And add 65 to make it an uppercase letter
$endgroup$
$begingroup$
Why not replace digits with unprintables? That way, you could just omit thei-47
$endgroup$
– Embodiment of Ignorance
yesterday
$begingroup$
@EmbodimentofIgnorance I'm afraid it wouldn't save any bytes. The numbers of spaces are 3, 1, 6, and 10. The 10 is used three times and is 2 bytes each as character (n
). So whether I use unprintables and 3xn
withi
or digits-1 withi-47
, both are the same 134 byte-count. And unfortunately I can't have an unprintable0
, otherwise I could have used 2,0,5,9 instead, and usei+1
to save 1 byte in total.
$endgroup$
– Kevin Cruijssen
21 hours ago
add a comment |
$begingroup$
Java 11, 134 bytes
c->"2XYZABC_0VW5DE_U9F_T9G_S9H_0RQ5JI_2PONMLK".chars().forEach(i->System.out.print(i<59?" ".repeat(i-47):(char)(i>90?10:(c+i)%26+65)))
Try it online.
136 bytes version with potential to be golfed?
c->"2XYZABC_0VW5DE_U9F_T9G_S9H_0RQ5JI_2PONMLK".chars().forEach(i->System.out.printf("%"+(i<59?i-47:"")+"c",i>90?10:i<59?32:(c+i)%26+65))
Try it online.
Explanation (of the first answer)
c-> // Method with character parameter and no return-type
"2XYZABC_0VW5DE_U9F_T9G_S9H_0RQ5JI_2PONMLK"
// Template-String
.chars().forEach(i-> // Loop over the unicode values of its characters:
System.out.print( // Print:
i<59? // If the value is below 59 (so a digit character):
" ".repeat(i-47) // Repeat a space that digit + 1 amount of times
:(char)(i>90? // Else-if the value is above 90 (an underscore character):
10 // Print a newline
: // Else:
(c+i) // Add the current value and the input together
%26 // Take modulo-26 of it to get the index in the alphabet
+65))) // And add 65 to make it an uppercase letter
$endgroup$
$begingroup$
Why not replace digits with unprintables? That way, you could just omit thei-47
$endgroup$
– Embodiment of Ignorance
yesterday
$begingroup$
@EmbodimentofIgnorance I'm afraid it wouldn't save any bytes. The numbers of spaces are 3, 1, 6, and 10. The 10 is used three times and is 2 bytes each as character (n
). So whether I use unprintables and 3xn
withi
or digits-1 withi-47
, both are the same 134 byte-count. And unfortunately I can't have an unprintable0
, otherwise I could have used 2,0,5,9 instead, and usei+1
to save 1 byte in total.
$endgroup$
– Kevin Cruijssen
21 hours ago
add a comment |
$begingroup$
Java 11, 134 bytes
c->"2XYZABC_0VW5DE_U9F_T9G_S9H_0RQ5JI_2PONMLK".chars().forEach(i->System.out.print(i<59?" ".repeat(i-47):(char)(i>90?10:(c+i)%26+65)))
Try it online.
136 bytes version with potential to be golfed?
c->"2XYZABC_0VW5DE_U9F_T9G_S9H_0RQ5JI_2PONMLK".chars().forEach(i->System.out.printf("%"+(i<59?i-47:"")+"c",i>90?10:i<59?32:(c+i)%26+65))
Try it online.
Explanation (of the first answer)
c-> // Method with character parameter and no return-type
"2XYZABC_0VW5DE_U9F_T9G_S9H_0RQ5JI_2PONMLK"
// Template-String
.chars().forEach(i-> // Loop over the unicode values of its characters:
System.out.print( // Print:
i<59? // If the value is below 59 (so a digit character):
" ".repeat(i-47) // Repeat a space that digit + 1 amount of times
:(char)(i>90? // Else-if the value is above 90 (an underscore character):
10 // Print a newline
: // Else:
(c+i) // Add the current value and the input together
%26 // Take modulo-26 of it to get the index in the alphabet
+65))) // And add 65 to make it an uppercase letter
$endgroup$
Java 11, 134 bytes
c->"2XYZABC_0VW5DE_U9F_T9G_S9H_0RQ5JI_2PONMLK".chars().forEach(i->System.out.print(i<59?" ".repeat(i-47):(char)(i>90?10:(c+i)%26+65)))
Try it online.
136 bytes version with potential to be golfed?
c->"2XYZABC_0VW5DE_U9F_T9G_S9H_0RQ5JI_2PONMLK".chars().forEach(i->System.out.printf("%"+(i<59?i-47:"")+"c",i>90?10:i<59?32:(c+i)%26+65))
Try it online.
Explanation (of the first answer)
c-> // Method with character parameter and no return-type
"2XYZABC_0VW5DE_U9F_T9G_S9H_0RQ5JI_2PONMLK"
// Template-String
.chars().forEach(i-> // Loop over the unicode values of its characters:
System.out.print( // Print:
i<59? // If the value is below 59 (so a digit character):
" ".repeat(i-47) // Repeat a space that digit + 1 amount of times
:(char)(i>90? // Else-if the value is above 90 (an underscore character):
10 // Print a newline
: // Else:
(c+i) // Add the current value and the input together
%26 // Take modulo-26 of it to get the index in the alphabet
+65))) // And add 65 to make it an uppercase letter
edited Mar 21 at 11:12
answered Mar 21 at 10:56
Kevin CruijssenKevin Cruijssen
41.3k567213
41.3k567213
$begingroup$
Why not replace digits with unprintables? That way, you could just omit thei-47
$endgroup$
– Embodiment of Ignorance
yesterday
$begingroup$
@EmbodimentofIgnorance I'm afraid it wouldn't save any bytes. The numbers of spaces are 3, 1, 6, and 10. The 10 is used three times and is 2 bytes each as character (n
). So whether I use unprintables and 3xn
withi
or digits-1 withi-47
, both are the same 134 byte-count. And unfortunately I can't have an unprintable0
, otherwise I could have used 2,0,5,9 instead, and usei+1
to save 1 byte in total.
$endgroup$
– Kevin Cruijssen
21 hours ago
add a comment |
$begingroup$
Why not replace digits with unprintables? That way, you could just omit thei-47
$endgroup$
– Embodiment of Ignorance
yesterday
$begingroup$
@EmbodimentofIgnorance I'm afraid it wouldn't save any bytes. The numbers of spaces are 3, 1, 6, and 10. The 10 is used three times and is 2 bytes each as character (n
). So whether I use unprintables and 3xn
withi
or digits-1 withi-47
, both are the same 134 byte-count. And unfortunately I can't have an unprintable0
, otherwise I could have used 2,0,5,9 instead, and usei+1
to save 1 byte in total.
$endgroup$
– Kevin Cruijssen
21 hours ago
$begingroup$
Why not replace digits with unprintables? That way, you could just omit the
i-47
$endgroup$
– Embodiment of Ignorance
yesterday
$begingroup$
Why not replace digits with unprintables? That way, you could just omit the
i-47
$endgroup$
– Embodiment of Ignorance
yesterday
$begingroup$
@EmbodimentofIgnorance I'm afraid it wouldn't save any bytes. The numbers of spaces are 3, 1, 6, and 10. The 10 is used three times and is 2 bytes each as character (
n
). So whether I use unprintables and 3x n
with i
or digits-1 with i-47
, both are the same 134 byte-count. And unfortunately I can't have an unprintable 0
, otherwise I could have used 2,0,5,9 instead, and use i+1
to save 1 byte in total.$endgroup$
– Kevin Cruijssen
21 hours ago
$begingroup$
@EmbodimentofIgnorance I'm afraid it wouldn't save any bytes. The numbers of spaces are 3, 1, 6, and 10. The 10 is used three times and is 2 bytes each as character (
n
). So whether I use unprintables and 3x n
with i
or digits-1 with i-47
, both are the same 134 byte-count. And unfortunately I can't have an unprintable 0
, otherwise I could have used 2,0,5,9 instead, and use i+1
to save 1 byte in total.$endgroup$
– Kevin Cruijssen
21 hours ago
add a comment |
$begingroup$
Kotlin, 148 146 145 bytes
Removed extra parentheses for -2
Replaced raw string for -1
{l:Char->"2XYZABC 0VW5DE U9F T9G S9H 0RQ5JI 2PONMLK".map{c->if(c>'@')((c-'A'+(l-'A'))%26+65).toChar()
else if(c>' ')" ".repeat(c-'/')
else 'n'}}
Try it online!
$endgroup$
add a comment |
$begingroup$
Kotlin, 148 146 145 bytes
Removed extra parentheses for -2
Replaced raw string for -1
{l:Char->"2XYZABC 0VW5DE U9F T9G S9H 0RQ5JI 2PONMLK".map{c->if(c>'@')((c-'A'+(l-'A'))%26+65).toChar()
else if(c>' ')" ".repeat(c-'/')
else 'n'}}
Try it online!
$endgroup$
add a comment |
$begingroup$
Kotlin, 148 146 145 bytes
Removed extra parentheses for -2
Replaced raw string for -1
{l:Char->"2XYZABC 0VW5DE U9F T9G S9H 0RQ5JI 2PONMLK".map{c->if(c>'@')((c-'A'+(l-'A'))%26+65).toChar()
else if(c>' ')" ".repeat(c-'/')
else 'n'}}
Try it online!
$endgroup$
Kotlin, 148 146 145 bytes
Removed extra parentheses for -2
Replaced raw string for -1
{l:Char->"2XYZABC 0VW5DE U9F T9G S9H 0RQ5JI 2PONMLK".map{c->if(c>'@')((c-'A'+(l-'A'))%26+65).toChar()
else if(c>' ')" ".repeat(c-'/')
else 'n'}}
Try it online!
edited Mar 21 at 13:04
answered Mar 20 at 22:05
JohnWellsJohnWells
5416
5416
add a comment |
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 126 118 bytes
n=>$@" XYZABC
VW{"",6}DE
U {"",9}F
T {"",9}G
S {"",9}H
RQ{"",6}JI
PONMLK".Select(b=>b<65?b:(char)((b+n)%26+65))
Saved 8 bytes thanks to @someone. Yes, that's actually his username.
Try it online!
$endgroup$
$begingroup$
String interpolation for 118 bytes. It is likely acceptable to return a array of charcodes (saving ~8 bytes), but I'm not sure.
$endgroup$
– someone
yesterday
$begingroup$
@someone Nice, forgot about string interpolation
$endgroup$
– Embodiment of Ignorance
yesterday
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 126 118 bytes
n=>$@" XYZABC
VW{"",6}DE
U {"",9}F
T {"",9}G
S {"",9}H
RQ{"",6}JI
PONMLK".Select(b=>b<65?b:(char)((b+n)%26+65))
Saved 8 bytes thanks to @someone. Yes, that's actually his username.
Try it online!
$endgroup$
$begingroup$
String interpolation for 118 bytes. It is likely acceptable to return a array of charcodes (saving ~8 bytes), but I'm not sure.
$endgroup$
– someone
yesterday
$begingroup$
@someone Nice, forgot about string interpolation
$endgroup$
– Embodiment of Ignorance
yesterday
add a comment |
$begingroup$
C# (Visual C# Interactive Compiler), 126 118 bytes
n=>$@" XYZABC
VW{"",6}DE
U {"",9}F
T {"",9}G
S {"",9}H
RQ{"",6}JI
PONMLK".Select(b=>b<65?b:(char)((b+n)%26+65))
Saved 8 bytes thanks to @someone. Yes, that's actually his username.
Try it online!
$endgroup$
C# (Visual C# Interactive Compiler), 126 118 bytes
n=>$@" XYZABC
VW{"",6}DE
U {"",9}F
T {"",9}G
S {"",9}H
RQ{"",6}JI
PONMLK".Select(b=>b<65?b:(char)((b+n)%26+65))
Saved 8 bytes thanks to @someone. Yes, that's actually his username.
Try it online!
edited yesterday
answered Mar 21 at 4:05
Embodiment of IgnoranceEmbodiment of Ignorance
2,148125
2,148125
$begingroup$
String interpolation for 118 bytes. It is likely acceptable to return a array of charcodes (saving ~8 bytes), but I'm not sure.
$endgroup$
– someone
yesterday
$begingroup$
@someone Nice, forgot about string interpolation
$endgroup$
– Embodiment of Ignorance
yesterday
add a comment |
$begingroup$
String interpolation for 118 bytes. It is likely acceptable to return a array of charcodes (saving ~8 bytes), but I'm not sure.
$endgroup$
– someone
yesterday
$begingroup$
@someone Nice, forgot about string interpolation
$endgroup$
– Embodiment of Ignorance
yesterday
$begingroup$
String interpolation for 118 bytes. It is likely acceptable to return a array of charcodes (saving ~8 bytes), but I'm not sure.
$endgroup$
– someone
yesterday
$begingroup$
String interpolation for 118 bytes. It is likely acceptable to return a array of charcodes (saving ~8 bytes), but I'm not sure.
$endgroup$
– someone
yesterday
$begingroup$
@someone Nice, forgot about string interpolation
$endgroup$
– Embodiment of Ignorance
yesterday
$begingroup$
@someone Nice, forgot about string interpolation
$endgroup$
– Embodiment of Ignorance
yesterday
add a comment |
$begingroup$
TSQL query, 238 bytes
DECLARE @y char='G'
,@ char(91)=3;WITH C as(SELECT'5585877636333330301125255'z,8a,ascii(@y)x
UNION ALL
SELECT stuff(z,1,1,''),a+left(z,1)/3*13+left(z,1)%3-14,(x+14)%26+65FROM
C WHERE''<z)SELECT
@=stuff(stuff(@,a,1,char(x)),1+a/13*13,1,char(13))FROM
C PRINT @
The test link for this answer broke the line breaks and excluded the spaces. I have replaced the spaces with period and replaced char(13) with char(13)+char(10) in order to show a readable result.
Try it online
Ungolfed:
DECLARE @y char='G'
-- @ is the string being printed last.
-- @ is populated with 3 to save a byte
-- the number 3 gets replaced later
-- (this could have been any 1 digit value),
-- @ is automatically filled with spaces, because
-- it is declared as a char(x) and assigned a value
,@ char(91)=3;
-- recursive query
WITH C as
(
-- z string containing digits for the direction of next letter
-- z should not contain 4 because it will point to same position.
-- values in z 0,1,2,3,4,5,6,7,8 can logally convert to
-- (-1,-1),(-1,0),(-1,1),(0,-1),(0,0),(0,1),(1,-1),(1,0),(1,1)
-- a is the starting position
SELECT'5585877636333330301125255'z,8a,ascii(@y)x
UNION ALL
-- stuff remove first character from the z string
-- a calculate next position of the next letter
-- x rotate the input letter
SELECT stuff(z,1,1,''),a+left(z,1)/3*13+left(z,1)%3-14,(x+14)%26+65
-- repeat recursive until long string is empty
FROM C
WHERE''<z
)
SELECT
-- 1st stuff replace the character to created the start of a
-- logical line in the string @ this is where 3 gets overwritten
-- 2nd stuff replaces a character(space if coded correct)
-- with the letter at the calculated position.
@=stuff(stuff(@,a,1,char(x)),1+a/13*13,1,char(13))
FROM C
PRINT @
$endgroup$
$begingroup$
@MickyT ok, thanks for your feedback, I will fix it later today if i can get access to a db
$endgroup$
– t-clausen.dk
Mar 20 at 18:16
$begingroup$
@MickyT it should be fixed now
$endgroup$
– t-clausen.dk
Mar 21 at 10:24
1
$begingroup$
looks good now.
$endgroup$
– MickyT
Mar 21 at 17:17
add a comment |
$begingroup$
TSQL query, 238 bytes
DECLARE @y char='G'
,@ char(91)=3;WITH C as(SELECT'5585877636333330301125255'z,8a,ascii(@y)x
UNION ALL
SELECT stuff(z,1,1,''),a+left(z,1)/3*13+left(z,1)%3-14,(x+14)%26+65FROM
C WHERE''<z)SELECT
@=stuff(stuff(@,a,1,char(x)),1+a/13*13,1,char(13))FROM
C PRINT @
The test link for this answer broke the line breaks and excluded the spaces. I have replaced the spaces with period and replaced char(13) with char(13)+char(10) in order to show a readable result.
Try it online
Ungolfed:
DECLARE @y char='G'
-- @ is the string being printed last.
-- @ is populated with 3 to save a byte
-- the number 3 gets replaced later
-- (this could have been any 1 digit value),
-- @ is automatically filled with spaces, because
-- it is declared as a char(x) and assigned a value
,@ char(91)=3;
-- recursive query
WITH C as
(
-- z string containing digits for the direction of next letter
-- z should not contain 4 because it will point to same position.
-- values in z 0,1,2,3,4,5,6,7,8 can logally convert to
-- (-1,-1),(-1,0),(-1,1),(0,-1),(0,0),(0,1),(1,-1),(1,0),(1,1)
-- a is the starting position
SELECT'5585877636333330301125255'z,8a,ascii(@y)x
UNION ALL
-- stuff remove first character from the z string
-- a calculate next position of the next letter
-- x rotate the input letter
SELECT stuff(z,1,1,''),a+left(z,1)/3*13+left(z,1)%3-14,(x+14)%26+65
-- repeat recursive until long string is empty
FROM C
WHERE''<z
)
SELECT
-- 1st stuff replace the character to created the start of a
-- logical line in the string @ this is where 3 gets overwritten
-- 2nd stuff replaces a character(space if coded correct)
-- with the letter at the calculated position.
@=stuff(stuff(@,a,1,char(x)),1+a/13*13,1,char(13))
FROM C
PRINT @
$endgroup$
$begingroup$
@MickyT ok, thanks for your feedback, I will fix it later today if i can get access to a db
$endgroup$
– t-clausen.dk
Mar 20 at 18:16
$begingroup$
@MickyT it should be fixed now
$endgroup$
– t-clausen.dk
Mar 21 at 10:24
1
$begingroup$
looks good now.
$endgroup$
– MickyT
Mar 21 at 17:17
add a comment |
$begingroup$
TSQL query, 238 bytes
DECLARE @y char='G'
,@ char(91)=3;WITH C as(SELECT'5585877636333330301125255'z,8a,ascii(@y)x
UNION ALL
SELECT stuff(z,1,1,''),a+left(z,1)/3*13+left(z,1)%3-14,(x+14)%26+65FROM
C WHERE''<z)SELECT
@=stuff(stuff(@,a,1,char(x)),1+a/13*13,1,char(13))FROM
C PRINT @
The test link for this answer broke the line breaks and excluded the spaces. I have replaced the spaces with period and replaced char(13) with char(13)+char(10) in order to show a readable result.
Try it online
Ungolfed:
DECLARE @y char='G'
-- @ is the string being printed last.
-- @ is populated with 3 to save a byte
-- the number 3 gets replaced later
-- (this could have been any 1 digit value),
-- @ is automatically filled with spaces, because
-- it is declared as a char(x) and assigned a value
,@ char(91)=3;
-- recursive query
WITH C as
(
-- z string containing digits for the direction of next letter
-- z should not contain 4 because it will point to same position.
-- values in z 0,1,2,3,4,5,6,7,8 can logally convert to
-- (-1,-1),(-1,0),(-1,1),(0,-1),(0,0),(0,1),(1,-1),(1,0),(1,1)
-- a is the starting position
SELECT'5585877636333330301125255'z,8a,ascii(@y)x
UNION ALL
-- stuff remove first character from the z string
-- a calculate next position of the next letter
-- x rotate the input letter
SELECT stuff(z,1,1,''),a+left(z,1)/3*13+left(z,1)%3-14,(x+14)%26+65
-- repeat recursive until long string is empty
FROM C
WHERE''<z
)
SELECT
-- 1st stuff replace the character to created the start of a
-- logical line in the string @ this is where 3 gets overwritten
-- 2nd stuff replaces a character(space if coded correct)
-- with the letter at the calculated position.
@=stuff(stuff(@,a,1,char(x)),1+a/13*13,1,char(13))
FROM C
PRINT @
$endgroup$
TSQL query, 238 bytes
DECLARE @y char='G'
,@ char(91)=3;WITH C as(SELECT'5585877636333330301125255'z,8a,ascii(@y)x
UNION ALL
SELECT stuff(z,1,1,''),a+left(z,1)/3*13+left(z,1)%3-14,(x+14)%26+65FROM
C WHERE''<z)SELECT
@=stuff(stuff(@,a,1,char(x)),1+a/13*13,1,char(13))FROM
C PRINT @
The test link for this answer broke the line breaks and excluded the spaces. I have replaced the spaces with period and replaced char(13) with char(13)+char(10) in order to show a readable result.
Try it online
Ungolfed:
DECLARE @y char='G'
-- @ is the string being printed last.
-- @ is populated with 3 to save a byte
-- the number 3 gets replaced later
-- (this could have been any 1 digit value),
-- @ is automatically filled with spaces, because
-- it is declared as a char(x) and assigned a value
,@ char(91)=3;
-- recursive query
WITH C as
(
-- z string containing digits for the direction of next letter
-- z should not contain 4 because it will point to same position.
-- values in z 0,1,2,3,4,5,6,7,8 can logally convert to
-- (-1,-1),(-1,0),(-1,1),(0,-1),(0,0),(0,1),(1,-1),(1,0),(1,1)
-- a is the starting position
SELECT'5585877636333330301125255'z,8a,ascii(@y)x
UNION ALL
-- stuff remove first character from the z string
-- a calculate next position of the next letter
-- x rotate the input letter
SELECT stuff(z,1,1,''),a+left(z,1)/3*13+left(z,1)%3-14,(x+14)%26+65
-- repeat recursive until long string is empty
FROM C
WHERE''<z
)
SELECT
-- 1st stuff replace the character to created the start of a
-- logical line in the string @ this is where 3 gets overwritten
-- 2nd stuff replaces a character(space if coded correct)
-- with the letter at the calculated position.
@=stuff(stuff(@,a,1,char(x)),1+a/13*13,1,char(13))
FROM C
PRINT @
edited 3 mins ago
answered Mar 20 at 14:24
t-clausen.dkt-clausen.dk
1,984314
1,984314
$begingroup$
@MickyT ok, thanks for your feedback, I will fix it later today if i can get access to a db
$endgroup$
– t-clausen.dk
Mar 20 at 18:16
$begingroup$
@MickyT it should be fixed now
$endgroup$
– t-clausen.dk
Mar 21 at 10:24
1
$begingroup$
looks good now.
$endgroup$
– MickyT
Mar 21 at 17:17
add a comment |
$begingroup$
@MickyT ok, thanks for your feedback, I will fix it later today if i can get access to a db
$endgroup$
– t-clausen.dk
Mar 20 at 18:16
$begingroup$
@MickyT it should be fixed now
$endgroup$
– t-clausen.dk
Mar 21 at 10:24
1
$begingroup$
looks good now.
$endgroup$
– MickyT
Mar 21 at 17:17
$begingroup$
@MickyT ok, thanks for your feedback, I will fix it later today if i can get access to a db
$endgroup$
– t-clausen.dk
Mar 20 at 18:16
$begingroup$
@MickyT ok, thanks for your feedback, I will fix it later today if i can get access to a db
$endgroup$
– t-clausen.dk
Mar 20 at 18:16
$begingroup$
@MickyT it should be fixed now
$endgroup$
– t-clausen.dk
Mar 21 at 10:24
$begingroup$
@MickyT it should be fixed now
$endgroup$
– t-clausen.dk
Mar 21 at 10:24
1
1
$begingroup$
looks good now.
$endgroup$
– MickyT
Mar 21 at 17:17
$begingroup$
looks good now.
$endgroup$
– MickyT
Mar 21 at 17:17
add a comment |
$begingroup$
PHP, 236 229 226 bytes
<?=($a=ord(file_get_contents('php://stdin'))-65)?preg_replace_callback('~w~',function($m)use($a){return chr((ord($m[0])-65+$a)%26+65);},' XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK'):'';
Try it online!
Pre-golf:
<?php
$adjust = ord(file_get_contents('php://stdin')) - 65;
echo preg_replace_callback('~w~', function($match) use ($adjust) {
$new = ord($match[0]) - 65;
$new = ($new + $adjust) % 26;
$new += 65;
return chr($new);
}, ' XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK');
Explanation:
Using ord
we convert to an integer between 0 and 255. A is 65 and Z is 90.
Using this knowledge, we take the input and reduce it by 65 so we have an adjustment value.
We then iterate over all characters, call ord
on them, reduce them by 65, increase them by our adjustment value. Using modulo we loop back down to 0 if they exceed 26.
We then increase them by 65 again and convert them back into letters with chr
.
Sadly php://stdin can only be interogated once, so we need to pass the input into the function in our loop, preventing us from saving bytes on use($a)
and having to declare a variable outside the function stops us from cleanly using the <?=
echo method - we have to wrap everything in a giant ternary.
$endgroup$
add a comment |
$begingroup$
PHP, 236 229 226 bytes
<?=($a=ord(file_get_contents('php://stdin'))-65)?preg_replace_callback('~w~',function($m)use($a){return chr((ord($m[0])-65+$a)%26+65);},' XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK'):'';
Try it online!
Pre-golf:
<?php
$adjust = ord(file_get_contents('php://stdin')) - 65;
echo preg_replace_callback('~w~', function($match) use ($adjust) {
$new = ord($match[0]) - 65;
$new = ($new + $adjust) % 26;
$new += 65;
return chr($new);
}, ' XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK');
Explanation:
Using ord
we convert to an integer between 0 and 255. A is 65 and Z is 90.
Using this knowledge, we take the input and reduce it by 65 so we have an adjustment value.
We then iterate over all characters, call ord
on them, reduce them by 65, increase them by our adjustment value. Using modulo we loop back down to 0 if they exceed 26.
We then increase them by 65 again and convert them back into letters with chr
.
Sadly php://stdin can only be interogated once, so we need to pass the input into the function in our loop, preventing us from saving bytes on use($a)
and having to declare a variable outside the function stops us from cleanly using the <?=
echo method - we have to wrap everything in a giant ternary.
$endgroup$
add a comment |
$begingroup$
PHP, 236 229 226 bytes
<?=($a=ord(file_get_contents('php://stdin'))-65)?preg_replace_callback('~w~',function($m)use($a){return chr((ord($m[0])-65+$a)%26+65);},' XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK'):'';
Try it online!
Pre-golf:
<?php
$adjust = ord(file_get_contents('php://stdin')) - 65;
echo preg_replace_callback('~w~', function($match) use ($adjust) {
$new = ord($match[0]) - 65;
$new = ($new + $adjust) % 26;
$new += 65;
return chr($new);
}, ' XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK');
Explanation:
Using ord
we convert to an integer between 0 and 255. A is 65 and Z is 90.
Using this knowledge, we take the input and reduce it by 65 so we have an adjustment value.
We then iterate over all characters, call ord
on them, reduce them by 65, increase them by our adjustment value. Using modulo we loop back down to 0 if they exceed 26.
We then increase them by 65 again and convert them back into letters with chr
.
Sadly php://stdin can only be interogated once, so we need to pass the input into the function in our loop, preventing us from saving bytes on use($a)
and having to declare a variable outside the function stops us from cleanly using the <?=
echo method - we have to wrap everything in a giant ternary.
$endgroup$
PHP, 236 229 226 bytes
<?=($a=ord(file_get_contents('php://stdin'))-65)?preg_replace_callback('~w~',function($m)use($a){return chr((ord($m[0])-65+$a)%26+65);},' XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK'):'';
Try it online!
Pre-golf:
<?php
$adjust = ord(file_get_contents('php://stdin')) - 65;
echo preg_replace_callback('~w~', function($match) use ($adjust) {
$new = ord($match[0]) - 65;
$new = ($new + $adjust) % 26;
$new += 65;
return chr($new);
}, ' XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK');
Explanation:
Using ord
we convert to an integer between 0 and 255. A is 65 and Z is 90.
Using this knowledge, we take the input and reduce it by 65 so we have an adjustment value.
We then iterate over all characters, call ord
on them, reduce them by 65, increase them by our adjustment value. Using modulo we loop back down to 0 if they exceed 26.
We then increase them by 65 again and convert them back into letters with chr
.
Sadly php://stdin can only be interogated once, so we need to pass the input into the function in our loop, preventing us from saving bytes on use($a)
and having to declare a variable outside the function stops us from cleanly using the <?=
echo method - we have to wrap everything in a giant ternary.
edited Mar 21 at 12:40
answered Mar 21 at 12:10
ScootsScoots
424411
424411
add a comment |
add a comment |
$begingroup$
C(GCC) 286 bytes
Not exactly the shortest golf, but it works
#define r(a)(a+c)%26+65
#define R(a)for(i=10;i;a[--i]<33?:(a[i]=r(a[i])));
i;f(c){char*S=" ",T=" XYZABCn",E="VW DEn",F="RQ JIn",B=" PONMLK";R(T)R(E)R(F)R(B)printf("%s %s%c%s%cn%c%s%cn%c%s%cn %s%s",T,E,r(85),S,r(70),r(84),S,r(71),r(83),S,r(72),F,B);}
Try it online
$endgroup$
add a comment |
$begingroup$
C(GCC) 286 bytes
Not exactly the shortest golf, but it works
#define r(a)(a+c)%26+65
#define R(a)for(i=10;i;a[--i]<33?:(a[i]=r(a[i])));
i;f(c){char*S=" ",T=" XYZABCn",E="VW DEn",F="RQ JIn",B=" PONMLK";R(T)R(E)R(F)R(B)printf("%s %s%c%s%cn%c%s%cn%c%s%cn %s%s",T,E,r(85),S,r(70),r(84),S,r(71),r(83),S,r(72),F,B);}
Try it online
$endgroup$
add a comment |
$begingroup$
C(GCC) 286 bytes
Not exactly the shortest golf, but it works
#define r(a)(a+c)%26+65
#define R(a)for(i=10;i;a[--i]<33?:(a[i]=r(a[i])));
i;f(c){char*S=" ",T=" XYZABCn",E="VW DEn",F="RQ JIn",B=" PONMLK";R(T)R(E)R(F)R(B)printf("%s %s%c%s%cn%c%s%cn%c%s%cn %s%s",T,E,r(85),S,r(70),r(84),S,r(71),r(83),S,r(72),F,B);}
Try it online
$endgroup$
C(GCC) 286 bytes
Not exactly the shortest golf, but it works
#define r(a)(a+c)%26+65
#define R(a)for(i=10;i;a[--i]<33?:(a[i]=r(a[i])));
i;f(c){char*S=" ",T=" XYZABCn",E="VW DEn",F="RQ JIn",B=" PONMLK";R(T)R(E)R(F)R(B)printf("%s %s%c%s%cn%c%s%cn%c%s%cn %s%s",T,E,r(85),S,r(70),r(84),S,r(71),r(83),S,r(72),F,B);}
Try it online
answered Mar 21 at 19:48
rtpaxrtpax
3065
3065
add a comment |
add a comment |
$begingroup$
Red, 139 bytes
func[a][foreach c{ XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK}[if c > sp[c: c + a % 26 + 65]prin c]]
Try it online!
A really naive solution.
$endgroup$
add a comment |
$begingroup$
Red, 139 bytes
func[a][foreach c{ XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK}[if c > sp[c: c + a % 26 + 65]prin c]]
Try it online!
A really naive solution.
$endgroup$
add a comment |
$begingroup$
Red, 139 bytes
func[a][foreach c{ XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK}[if c > sp[c: c + a % 26 + 65]prin c]]
Try it online!
A really naive solution.
$endgroup$
Red, 139 bytes
func[a][foreach c{ XYZABC
VW DE
U F
T G
S H
RQ JI
PONMLK}[if c > sp[c: c + a % 26 + 65]prin c]]
Try it online!
A really naive solution.
edited Mar 20 at 12:35
answered Mar 20 at 12:28
Galen IvanovGalen Ivanov
7,24211034
7,24211034
add a comment |
add a comment |
$begingroup$
Perl 5 -p
, 110 bytes
$b=/A/?Z:chr(-1+ord);$_=eval("'2XYZABC
VW5DE
U9F
T9G
S9H
RQ5JI
2PONMLK'=~y/A-Z/$_-ZA-$b/r");s/d/$".$"x$&/eg
Try it online!
$endgroup$
$begingroup$
$b is unnecessary. -24 bytes: TIO.
$endgroup$
– Grimy
Mar 21 at 8:44
$begingroup$
-2 bytes TIO
$endgroup$
– Nahuel Fouilleul
Mar 21 at 13:30
add a comment |
$begingroup$
Perl 5 -p
, 110 bytes
$b=/A/?Z:chr(-1+ord);$_=eval("'2XYZABC
VW5DE
U9F
T9G
S9H
RQ5JI
2PONMLK'=~y/A-Z/$_-ZA-$b/r");s/d/$".$"x$&/eg
Try it online!
$endgroup$
$begingroup$
$b is unnecessary. -24 bytes: TIO.
$endgroup$
– Grimy
Mar 21 at 8:44
$begingroup$
-2 bytes TIO
$endgroup$
– Nahuel Fouilleul
Mar 21 at 13:30
add a comment |
$begingroup$
Perl 5 -p
, 110 bytes
$b=/A/?Z:chr(-1+ord);$_=eval("'2XYZABC
VW5DE
U9F
T9G
S9H
RQ5JI
2PONMLK'=~y/A-Z/$_-ZA-$b/r");s/d/$".$"x$&/eg
Try it online!
$endgroup$
Perl 5 -p
, 110 bytes
$b=/A/?Z:chr(-1+ord);$_=eval("'2XYZABC
VW5DE
U9F
T9G
S9H
RQ5JI
2PONMLK'=~y/A-Z/$_-ZA-$b/r");s/d/$".$"x$&/eg
Try it online!
answered Mar 20 at 20:35
XcaliXcali
5,445520
5,445520
$begingroup$
$b is unnecessary. -24 bytes: TIO.
$endgroup$
– Grimy
Mar 21 at 8:44
$begingroup$
-2 bytes TIO
$endgroup$
– Nahuel Fouilleul
Mar 21 at 13:30
add a comment |
$begingroup$
$b is unnecessary. -24 bytes: TIO.
$endgroup$
– Grimy
Mar 21 at 8:44
$begingroup$
-2 bytes TIO
$endgroup$
– Nahuel Fouilleul
Mar 21 at 13:30
$begingroup$
$b is unnecessary. -24 bytes: TIO.
$endgroup$
– Grimy
Mar 21 at 8:44
$begingroup$
$b is unnecessary. -24 bytes: TIO.
$endgroup$
– Grimy
Mar 21 at 8:44
$begingroup$
-2 bytes TIO
$endgroup$
– Nahuel Fouilleul
Mar 21 at 13:30
$begingroup$
-2 bytes TIO
$endgroup$
– Nahuel Fouilleul
Mar 21 at 13:30
add a comment |
$begingroup$
Javascript (V8), 316 bytes
function a(b){n="abcdefghijklmnopqrstuvwxyz".split(b);n=b+n[1]+n[0],console.log(` ${n[23]+n[24]+n[25]+n[0]+n[1]+n[2]}n ${n[21]+n[22]} ${n[3]+n[4]}n${n[20]} ${n[5]}n${n[19]} ${n[6]}n${n[18]} ${n[7]}n ${n[17]+n[16]} ${n[9]+n[8]}n ${n[15]+n[14]+n[13]+n[12]+n[11]+n[10]}`)}
Try it online
First time trying code golf out. Appreciate any tips / feedback.
Original code before minifying:
function a(b){
var c = ("abcdefghijklmnopqrstuvwxyz").split(b);
c = b+c[1]+c[0]
console.log(` ${c[23]+c[24]+c[25]+c[0]+c[1]+c[2]}n ${c[21]+c[22]} ${c[3]+c[4]}n${c[20]} ${c[5]}n${c[19]} ${c[6]}n${c[18]} ${c[7]}n ${c[17]+c[16]} ${c[9]+c[8]}n ${c[15]+c[14]+c[13]+c[12]+c[11]+c[10]}`)
}
New contributor
$endgroup$
$begingroup$
Hello and welcome to PPCG. As it stands, your submission is a snippet, which is invalid I/O. Please fix your answer to either be a full program or function -- as in you non-minified version.
$endgroup$
– Jonathan Frech
2 days ago
$begingroup$
@Jonathan Fresch thanks! Would that suffice?
$endgroup$
– Edwin Chua
2 days ago
1
$begingroup$
Yes, this is now a valid submission.
$endgroup$
– Jonathan Frech
2 days ago
add a comment |
$begingroup$
Javascript (V8), 316 bytes
function a(b){n="abcdefghijklmnopqrstuvwxyz".split(b);n=b+n[1]+n[0],console.log(` ${n[23]+n[24]+n[25]+n[0]+n[1]+n[2]}n ${n[21]+n[22]} ${n[3]+n[4]}n${n[20]} ${n[5]}n${n[19]} ${n[6]}n${n[18]} ${n[7]}n ${n[17]+n[16]} ${n[9]+n[8]}n ${n[15]+n[14]+n[13]+n[12]+n[11]+n[10]}`)}
Try it online
First time trying code golf out. Appreciate any tips / feedback.
Original code before minifying:
function a(b){
var c = ("abcdefghijklmnopqrstuvwxyz").split(b);
c = b+c[1]+c[0]
console.log(` ${c[23]+c[24]+c[25]+c[0]+c[1]+c[2]}n ${c[21]+c[22]} ${c[3]+c[4]}n${c[20]} ${c[5]}n${c[19]} ${c[6]}n${c[18]} ${c[7]}n ${c[17]+c[16]} ${c[9]+c[8]}n ${c[15]+c[14]+c[13]+c[12]+c[11]+c[10]}`)
}
New contributor
$endgroup$
$begingroup$
Hello and welcome to PPCG. As it stands, your submission is a snippet, which is invalid I/O. Please fix your answer to either be a full program or function -- as in you non-minified version.
$endgroup$
– Jonathan Frech
2 days ago
$begingroup$
@Jonathan Fresch thanks! Would that suffice?
$endgroup$
– Edwin Chua
2 days ago
1
$begingroup$
Yes, this is now a valid submission.
$endgroup$
– Jonathan Frech
2 days ago
add a comment |
$begingroup$
Javascript (V8), 316 bytes
function a(b){n="abcdefghijklmnopqrstuvwxyz".split(b);n=b+n[1]+n[0],console.log(` ${n[23]+n[24]+n[25]+n[0]+n[1]+n[2]}n ${n[21]+n[22]} ${n[3]+n[4]}n${n[20]} ${n[5]}n${n[19]} ${n[6]}n${n[18]} ${n[7]}n ${n[17]+n[16]} ${n[9]+n[8]}n ${n[15]+n[14]+n[13]+n[12]+n[11]+n[10]}`)}
Try it online
First time trying code golf out. Appreciate any tips / feedback.
Original code before minifying:
function a(b){
var c = ("abcdefghijklmnopqrstuvwxyz").split(b);
c = b+c[1]+c[0]
console.log(` ${c[23]+c[24]+c[25]+c[0]+c[1]+c[2]}n ${c[21]+c[22]} ${c[3]+c[4]}n${c[20]} ${c[5]}n${c[19]} ${c[6]}n${c[18]} ${c[7]}n ${c[17]+c[16]} ${c[9]+c[8]}n ${c[15]+c[14]+c[13]+c[12]+c[11]+c[10]}`)
}
New contributor
$endgroup$
Javascript (V8), 316 bytes
function a(b){n="abcdefghijklmnopqrstuvwxyz".split(b);n=b+n[1]+n[0],console.log(` ${n[23]+n[24]+n[25]+n[0]+n[1]+n[2]}n ${n[21]+n[22]} ${n[3]+n[4]}n${n[20]} ${n[5]}n${n[19]} ${n[6]}n${n[18]} ${n[7]}n ${n[17]+n[16]} ${n[9]+n[8]}n ${n[15]+n[14]+n[13]+n[12]+n[11]+n[10]}`)}
Try it online
First time trying code golf out. Appreciate any tips / feedback.
Original code before minifying:
function a(b){
var c = ("abcdefghijklmnopqrstuvwxyz").split(b);
c = b+c[1]+c[0]
console.log(` ${c[23]+c[24]+c[25]+c[0]+c[1]+c[2]}n ${c[21]+c[22]} ${c[3]+c[4]}n${c[20]} ${c[5]}n${c[19]} ${c[6]}n${c[18]} ${c[7]}n ${c[17]+c[16]} ${c[9]+c[8]}n ${c[15]+c[14]+c[13]+c[12]+c[11]+c[10]}`)
}
New contributor
edited 2 days ago
New contributor
answered Mar 22 at 7:34
Edwin ChuaEdwin Chua
1012
1012
New contributor
New contributor
$begingroup$
Hello and welcome to PPCG. As it stands, your submission is a snippet, which is invalid I/O. Please fix your answer to either be a full program or function -- as in you non-minified version.
$endgroup$
– Jonathan Frech
2 days ago
$begingroup$
@Jonathan Fresch thanks! Would that suffice?
$endgroup$
– Edwin Chua
2 days ago
1
$begingroup$
Yes, this is now a valid submission.
$endgroup$
– Jonathan Frech
2 days ago
add a comment |
$begingroup$
Hello and welcome to PPCG. As it stands, your submission is a snippet, which is invalid I/O. Please fix your answer to either be a full program or function -- as in you non-minified version.
$endgroup$
– Jonathan Frech
2 days ago
$begingroup$
@Jonathan Fresch thanks! Would that suffice?
$endgroup$
– Edwin Chua
2 days ago
1
$begingroup$
Yes, this is now a valid submission.
$endgroup$
– Jonathan Frech
2 days ago
$begingroup$
Hello and welcome to PPCG. As it stands, your submission is a snippet, which is invalid I/O. Please fix your answer to either be a full program or function -- as in you non-minified version.
$endgroup$
– Jonathan Frech
2 days ago
$begingroup$
Hello and welcome to PPCG. As it stands, your submission is a snippet, which is invalid I/O. Please fix your answer to either be a full program or function -- as in you non-minified version.
$endgroup$
– Jonathan Frech
2 days ago
$begingroup$
@Jonathan Fresch thanks! Would that suffice?
$endgroup$
– Edwin Chua
2 days ago
$begingroup$
@Jonathan Fresch thanks! Would that suffice?
$endgroup$
– Edwin Chua
2 days ago
1
1
$begingroup$
Yes, this is now a valid submission.
$endgroup$
– Jonathan Frech
2 days ago
$begingroup$
Yes, this is now a valid submission.
$endgroup$
– Jonathan Frech
2 days ago
add a comment |
Discrete Games is a new contributor. Be nice, and check out our Code of Conduct.
Discrete Games is a new contributor. Be nice, and check out our Code of Conduct.
Discrete Games is a new contributor. Be nice, and check out our Code of Conduct.
Discrete Games is a new contributor. Be nice, and check out our Code of Conduct.
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f181843%2fmake-a-bowl-of-alphabet-soup%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
12
$begingroup$
Great challenge! It initially seems easy, but it's not
$endgroup$
– Luis Mendo
Mar 19 at 21:56