28
\$\begingroup\$

Write a program for a specific language that in different orientations performs different tasks.

Your code should have at least two non-empty lines and at least two non-empty columns and should complete at least one challenge from each category of challenges below when oriented in different ways.

Orientations

Your code can be arranged eight different ways, original and three ninety degree rotations and each reversed, eg:

$_=     $@$      /$     =. 
@F.     /F_     .F@     _F/
$/       .=     =_$     $@$

=_$      .=     $/      $@$
.F@     /F_     @F.     _F/
 /$     $@$     $_=     =.

Here's a generator (thanks to @fireflame241!)

Tasks

Scoring

Your score will be the number of different tasks solved by your code (higher is better) with code length as a tie-breaker (lower is better).

Rules

  • All programs must be in the same language
  • The rules for each task are as specified in the linked questions.
  • Multiple tasks can be completed in the same orientation to help maximise score. For example, if s challenge has no expectation to handle the empty input, you could instead perform another task that takes no input.
  • Your code must perform tasks when oriented in at least three unique rotations.
  • You can assume that spaces will be automatically added when rotating your code, however if your code does necessitate space padding on the end of lines of each rotation, these should be included.
\$\endgroup\$
  • \$\begingroup\$ Thanks to everyone for their input in the sandbox (deleted). \$\endgroup\$ – Dom Hastings Jun 30 at 7:53
  • 1
    \$\begingroup\$ How do we measure the size of the program? Are we going to assume that shorter lines are space padded so all lines are the same length? Or can the program size increase if we rotate/flip the program? If the latter, if a line starts with spaces and is reversed, do the trailing spaces disappear? For some languages, trailing spaces may matter. How do we deal with the absence of a trailing newline on the last line when we flip a program horizontally? \$\endgroup\$ – Abigail Jun 30 at 14:07
  • \$\begingroup\$ @Abigail this is a good question. I think once I changed the intended scoring from code-golf to the number of tasks, I neglected to clarify the position (which I'd originally intended to be the largest byte count), but the approach that the current answers have taken is to minimise the byte-count which is quite interesting so keeping the minimal count is fine by me and assuming that the rotations will include spaces is fine too. If spaces are required in the originating code thought they should be counted. \$\endgroup\$ – Dom Hastings Jun 30 at 16:52
34
\$\begingroup\$

05AB1E, 5 14 15 18 rotations (5 6 7 8 unique, 61 213 1488 4367 bytes)

.ï i…( )7ÝJ»•αγʒδÓ₂©8¥ŽQxΣxêÿ•sÅвJIvN”</[(0._-=:"ÆŸ,*”0¶:º•DùÙÂ+;Èγтáì³ÓW©ÎÂ_`ƒ≠îj*ΓçÊ~ÞÒ¸β¦oåb/õ47/vÎΓ”›≠øØZµλݺ•20в趡Nè4äyè.;ëĀiηû»ëтÝ3Å€"Fizz"}5Å€á”ÒÖ”J}¦»]q]À=F₂Aë}š.?ćvD¡SaA„iĀë∍sna„>+?Å8IàQô2$4Žнв₄iï.
ï                                                                                                                                                                                                             …
i                                                                                                                                                                                                             _
Å                                                                                                                                                                                                             |
f                                                                                                                                                                                                             _
ë                                                                                                                                                                                                             Ć
∞                                                                                                                                                                                                             Ƶ
€                                                                                                                                                                                                             м
,                                                                                                                                                                                                             ×
]                                                                                                                                                                                                             T
q                                                                                                                                                                                                             ä
]                                                                                                                                                                                                             »
.                                                                                                                                                                                                             q
                                                                                                                                                                                                              ”
.                                                                                                                                                                                                             !
…                                                                                                                                                                                                             ï
ë                                                                                                                                                                                                             ‚
p                                                                                                                                                                                                             ,
i                                                                                                                                                                                                             ™
ï                                                                                                                                                                                                             Ÿ
.ïi_i“Ûà€‰€ž€¢‡Í! :D“ćuìëdiU„ $„ |}…-~-`)X·>δ∍»}ëĀi1ú.γžOså}R`¦??н©?н®ì.•gÍĆdQ¸G•Â‡D?,듫·Ħí¥Â“#€¦`«'kì)™•1¢₂P•3вè4ô»]q]»ì” ©¢ØŽ”)s”E1BA50 Ž¬”Дî€ot”ëFëgiʹŠ'iĀëå4B23iï.                                 \””

Try it online (integer input): Do you want to code a snowman?
Try it online (string input): It took me a lot of time to make this, pls like. (YouTube Comments #1)
Try it online (no input): 1, 2, Fizz, 4, Buzz

Try it online with all rows reversed (integer input): It's my Birthday :D
Try it online with all rows reversed (string input): Covefify a string
Try it online with all rows reversed (no input): Hare Krishna Hare Krishna Krishna Krishna Hare Hare

Try it online with each row reversed (integer input): You're on a 8 day streak!
Try it online with each row reversed (string input): No A, just CAPS LOCK
Try it online with each row reversed (no input): Print a Tabula Recta!

Try it online with both the rows and each row itself reversed (integer input): Am I a Rude Number?
Try it online with both the rows and each row itself reversed (string input): Don't google "google"
Try it online with both the rows and each row itself reversed (no input): Sing Happy Birthday to your favourite programming language

Try it online rotated 90 degrees clockwise (integer input): Fibonacci function or sequence
Try it online rotated 90 degrees clockwise (no input): Count up forever

Try it online rotated 90 degrees clockwise and then each row reversed (integer input): Is this number a prime?
Try it online rotated 90 degrees clockwise and then each row reversed (no input): Print the last, middle and first character of your code

Try it online rotated 90 degrees counterclockwise (no input): Build me a brick wall!

Try it online rotated 90 degrees counterclockwise and then each row reversed (no input): "Hello, World!"

Explanation:

In general, I mostly rely on the builtin q. This will stop the program, making everything after it no-ops.

In addition, for the four main rotations, I split them up into integer/string/no input with:

.ïi         # If the (implicit) input is an integer:
            #  Do something with the integer-input
ëĀi         # Else-if the (implicit) input-string is NOT empty:
            # (using the Python-truthify builtin `Ā`)
            #  Do something else with the string-input
ë           # Else (there is no input):
            #  Do something else without input

For the two clockwise rotations it's similar, but only with integer or no input (since there aren't any other challenges available with input from the list in the challenge).
And for the two counterclockwise rotations it's just a kolmogorov-complexity output without input.

Some things I had to fix for the rotations include:

  • Adding an additional space between the and i at the start of the first line, and a space on each subsequent line. Without this space, the middle character for subprogram of the Print the last, middle and first character of your code challenge would have a newline character as the center, which isn't possible without screwing up the layout. With that added space, the middle character in that rotation also becomes a space (the first and last characters are both .).
  • Adding \” at the end of the final line. This is to close this string and discard it for the programs with all rows and each row itself reversed, which will now contain a leading ””\ followed by a bunch of no-op spaces.
  • For most rotations I reuse the . for the (is_integer check), but for one rotation it's .… instead. . opens up 2-byte builtins, but since .… doesn't exist, the . is a no-op instead in this case.

As for an explanation of each individual program:

Do you want to code a snowman?: …( )7ÝJ»•αγʒδÓ₂©8¥ŽQxΣxêÿ•sÅвJIvN”</[(0._-=:"ÆŸ,*”0¶:º•DùÙÂ+;Èγтáì³ÓW©ÎÂ_`ƒ≠îj*ΓçÊ~ÞÒ¸β¦oåb/õ47/vÎΓ”›≠øØZµλݺ•20в趡Nè4äyè.;
See this answer of mine, except that the actual newline is replaced with a 0, which we replace to a newline after creating the string with 0¶:.

It took me a lot of time to make this, pls like. (YouTube Comments #1): ηû»
See the second program in this answer of mine (provided by @Grimmy).

1, 2, Fizz, 4, Buzz: тÝ3Å€"Fizz"}5Å€á”ÒÖ”J}¦»
See this answer of @Grimmy.

It's my Birthday :D: _i“Ûà€‰€ž€¢‡Í! :D“ćuìëdiU„ $„ |}…-~-`)X·>δ∍»}
See this answer of @Grimmy, with additional trailing } to close the if-statement.

Covefify a string: 1ú.γžOså}R`¦??н©?н®ì.•gÍĆdQ¸G•Â‡D?,
See this answer of @Grimmy.

Hare Krishna Hare Krishna Krishna Krishna Hare Hare: “«Î‡Ä¦í¥Â“#€¦`«'kì)™•1¢₂P•3вè4ô»
See this comment of mine on the answer of @Emigna.

“«Î‡Ä¦í¥Â“  # Push dictionary string "drama share irish dna"
 #          # Split it on spaces: ["drama","share","irish","dna"]
  €¦        # Remove the first character of each word:
            #  ["rama","hare","rish","na"]
    `       # Push them separated to the stack
     «      # Merge the last two together: "rishna"
      'kì  '# Prepend a "k": "krishna"
         )  # And wrap everything on the stack into a list again:
            #  ["rama","hare","krishna"]
          ™ # Titlecase each: ["Rama","Hare","Krishna"]
•1¢₂P•      # Push compressed integer 27073120
 3в         # Convert it to base-3 as list: [1,2,1,2,2,2,1,1,1,0,1,0,0,0,1,1]
   è        # Index each integer into the list of words
    4ô      # Split the list of words into parts of size 4
      »     # Join each inner list by spaces, and then each string by newlines
            # (after which the result is output implicitly as result)

See this 05AB1E tip of mine (sections How to use the dictionary?, How to compress large integers?, and How to compress integer lists?) to understand why “«Î‡Ä¦í¥Â“ is "drama share irish dna"; •1¢₂P• is 27073120; and •1¢₂P•3в is [1,2,1,2,2,2,1,1,1,0,1,0,0,0,1,1].

You're on a 8 day streak!: ₄внŽ4$2ôQàI8Å?+>„ans∍
See this answer of mine.

No A, just CAPS LOCK: „AaS¡Dvć?.š
See this this answer of @Emigna, although without õ? and with instead of š, since his answer is built in the legacy version of 05AB1E instead of the new one.

Print a Tabula Recta!: A₂F=À
See this answer of @Adnan, although with ₂F instead of Dv, since I personally prefer to keep my programs as straight-forward as possible despite codegolfing (where is the builtin for 26, and F loops that many times).

Am I a Rude Number?: 32B4å
See this answer of mine.

Don't google "google": 'Š¹ÊigëF
Although there is this pretty old answer of @Adnan which worked on one of the earliest versions of 05AB1E when he posted it back in 2016, it doesn't even work anymore in the latest legacy version on TIO from around mid-2017, let alone in the latest 05AB1E version. So instead I now use this (which is also 2 bytes shorter anyway):

'Š¹        '# Push the dictionary string "google"
   Êi       # If the (implicit) input-string is NOT equal to "google":
     g      #  Pop and push the length of the (implicit) input-string
            #  (which will be output implicitly as result)
    ë       # Else:
     F      #  Start a loop using the (implicit) input-string,
            #  which will result in an error if it isn't an integer

See this 05AB1E tip of mine (section How to use the dictionary?) to understand why 'Š¹ is "google".

Sing Happy Birthday to your favourite programming language: ”to€î”Д¬Ž 05AB1E”s)”ŽØ¢© ”ì»
See this 05AB1E answer of @Grimmy.

Fibonacci function or sequence: Åf

Åf          # Given the (implicit) input-integer `n`, get the n'th Fibonacci number
            # (after which it is output implicitly as result)

Count up forever: ∞€,
See this answer of @Sagittarius.

Is this number a prime?: p

p           # Given the (implicit) input-integer, check if it's a prime number
            # (1 if truthy; 0 if falsey)
            # (after which it is output implicitly as result)

Print the last, middle and first character of your code: .…. .
As I already mentioned earlier, I added an additional no-op space to the program so the middle character in this orientation would be a space character, instead of a newline character. The first and last characters are ., so we'll have the following sub-program:

.           # No-op, since `.…` isn't an available 2-byte builtin
 …. .       # Push 3-char string ". ."
     q      # Stop the program, making everything after that no-ops
            # (after which the result is output implicitly)

Build me a brick wall!: .…_|_ĆƵм×Tä»
See this answer of @Adnan, although golfed by 2 bytes by replacing "_|__" with …_|_Ć (push 3-char string "_|_"; and then enclose, appending its own first character) and 175 with Ƶм (compressed integer).

"Hello, World!": ”Ÿ™,‚ï!”
See this answer of @Adnan, except with trailing to close the string.

The ] you see before the q in each program is to close all open if-else statements and loops before doing this q.

I'm unable to fit anything more in it from the list in the challenge description. The ones left are three (/) that require you to output something without input (which I have already used in all eight rotations) and four -related challenges, which are just impossible with this kind of layout in 05AB1E.
If there would have been more challenges taking integer/string inputs, those could have been added as well.

| improve this answer | |
\$\endgroup\$
  • 2
    \$\begingroup\$ Yes! Totally what I was hoping to see! \$\endgroup\$ – Dom Hastings Jun 30 at 10:42
  • 3
    \$\begingroup\$ This is a work of art! \$\endgroup\$ – Shaggy Jun 30 at 17:43
  • 2
    \$\begingroup\$ @DomHastings Ok, I'm finally done. All 8 rotations and 18 subprograms in total. Updating those TIOs is such a pain btw, haha. The 7 remaining challenges to choose from I won't be able to add (see what I mentioned at the very bottom). (If there were any other challenges that take input, I could have added them, but I'm kinda glad there aren't, since it's pretty time-consuming.. xD) \$\endgroup\$ – Kevin Cruijssen Jul 1 at 11:29
  • 1
    \$\begingroup\$ Nice dedication! I'll certainly take this aspect into consideration for any future challenges like this, I'm glad you (seemingly anyway) enjoyed this! \$\endgroup\$ – Dom Hastings Jul 1 at 13:03
13
\$\begingroup\$

perl -M5.010 -Mbigint, 8 orientations, 8 18 tasks, 1644 2840 bytes

####################################################iA;"/sv)=-=f{.{ei#
if(eof()){say+("11 *25 *\n7 4*10 *5 *10 4*" .##cAc##f.e[^ag.(-po$./lf#
"\n5 4*12 7*12 4*\n3 6*12 7*12 6*\n2 9*9 9*".##'+b##(.x^(yk$$$orp*^s(#
"9 9*\n 47*\n49*\n49*\n49*\n 47*\n  5*7 21*".##@wM##eYi$$$k3x_d =).ee#
"7 5*\n4 4*7 3*4 5*4 3*7 4*\n7 **7 *6 3*6 *".##@@E##o;tvc1g)[>#2$.+{o#
"7 **\n")=~s/(\d+)(\D)/$2 x$1/gre}else{chomp(##4`c##f/}]*.px1=%._(?$f#
$_=<>);if(/\D/){/^google/&&die;$_=length}else##":B##(.$"$(b ]00.>?(_(#
{$_=sprintf"00%b",$_;$_=/00100(.{5})*$/?1:0}}##VQl##){_;v(s2,;#$1{?=)#
say;#[447}E<vFX**gd's<kN6iiX#gS0qnsHgj'M%um$###>fr##)2=$*(z)$son;s{<)#
=pod#+RvC!y-9UwQ7ImGlBV03'UoBoqY:#OR`6z&C_;0###$I7##{6<v({t}xa+-$as>{#
[$1=~y,a-zA-Z,A-Za-z,r]ige}};say;#zG}B2|M}TI###X^4##$}>=$sde[yQ2nya;{#
"ur new baby! :D"}}else{s[a([^aA]*)a?] ##l"}###/)u##_(;"cpvl0$s;=$ycs#
$/,grep$_,@x}else{$_="Congratulations on yo".##"(O##=?$[)lfs]x9s$1$ha#
' $'x$_,' |'x$_,'-'x$x,'~'x$x,'-'x$x);$_=join##ZSo##j{v$)ize+[Ja_}&oy#
;if(/^-?\d+$/){if($_){$x=1+2*($_<0?1:$_);@x=(##)<V##os=v$ts{$0Jy;)}m+#
if(eof()){$_="Hello, World!"}else{$_=<>;chomp##WJ+##iaa]c/}@x]^!$()p+#
###############################################JvE##nye"*/-x[}@!p?(;$#
###############F+g@,ZHTSgmA|[\N"0`EV(>QJ'=b(9]+FJY##"$i;(,>=1#>$&!?i_#
###########.###lq{$LWnQj&g|l27@'o}Tr@VFDBI`K#np#7g##"&oi$b{(]6>p&)!f;#
#9Tj=~7D#Sxy{##.YTb}.:7dj+t|4-8Fo\GZJ?E=L7CWYq-RVu##,}ufvp$0){/}=/)(r#
#7$_j;&Q,A$b###<M+agLQ5{_6z^mL6V:VVo;Azb`4<5tAUx9###A)y()c2,wwd}$x//e#
#L[vlh(sa#ya(##hOy>[A&.[usZ_Xzkgn^{qdp|2B{T-g5&$u+##.(;#/g}1h;0#n};\d#
#,zQS#wBpraB.##(Qrc\!&X(_i[Cd1o:vuq76kWY/g0v>xso8|##.?$/)d|)id'[%e/Do#
#{x]V;Gzdos."##eXBcnsw2l?ImMzjJ;0NO045|JIrUh\sT@wh##Z!ca{t|;lCxd$l^/}#
###LuyK/nf;)k##G{3|#3B)J\n"rG__@*w0,6h6m6\MLggprbN##,)=[#f$@eiU\_s()}#
#";M!aBwa x3r##Oj@;),oZ-Yh6gBXx*B-Aq|!Xg;vx!@O7V^_###/###.2x#####e####
#t"]#sLTrr$xa##p79<GL"e"STDrRWLVRHuQY`_zmq;wDu`3cD####################
#ru}~;b'Ggy)h#########################################################
#io#=rgr,/a/S###rof zzuBzziF:zzuB:zziF:_$?3%_$?5%_$?51%_$yas{))(foe(fi
#BYyr!vay_s$ ###Xat(\'7O(>#;a:na?/$*)...(]81[1^|8^/~=><yas}tixe;001..1
#  a!l+7m$;.y###iv&.:!Pd.MSjhr6,|E+>cjA(%?NuLB"}ss#8H?<Otd~Bw0zy>#dop=
#yosrrm#m/")b###$#;yas}")".]]7[c$[)"   ","___",'" "'," : "(."( n\".]]5
#pt;ae{;oy!6a##[c$[)"$,"\\","$,">"(.")".]]6[c$[)"   ","< >","[ ]"," :"
#p yePVaMbkxB##."$(."(".]]4[c$[)"$,"/","$,"<"(./$.]]5[c$[)"$,"$,"/","$
#ayaD!~m,ar""##(.")".]]3[c$[)"-","O","o","."(.]]1[c$[)"$,"_",".",","(.
#Has!u#dyBao(##]]2[c$[)"-","O","o","."(."(".]]4[c$[)"$,"$,"\\","$(./$.
#"d;oodnd/ho(##]]0[c$[)")_*_(","\\_/ ",".....","_===_"(."$./$.]]0[c$[)
#=hytYoadsSd=##"___ ","_  ","___ ",""(."$=_$;g/./~=><}1-_${pam=c@{esle
#_"a!!pra~  x##}5=x _$;g//$..|..^/s;2=x _$;/$.)81x"|___"(=_${))(foe(fi
#$.sss=GD=""$#########################################################

Before explaining how it works, let me tell how I created the monster above. I started off with 8 programs, each doing 1 to 3 tasks. Which task they do depends on the input (all input is read as a single line from STDIN) they get: void, an integer, or a string. 8 programs handle void input, 6 handle integer input, and 4 handle string input. If there would be more tasks which take integer and/or string input, we could have handled 24 inputs.

Now, we take the 8 programs, and combine them in the following way:

###################PP=PP#
PROGRAM 1 TOP    ##RRpRR#
PROGRAM 1 BOTTOM ##OOoOO#
=pod             ##GGdGG#
PROGRAM 2 BOTTOM ##RR RR#
PROGRAM 2 TOP    ##AA AA#
###################MM MM#
#     #           #     #
# M M #           #44 33#
# O O #           #     #
# T T #           #TB BT#
#PT TP#           #OO OO#
#OO OO#           #PT TP#
#TB BT#           # T T #
#     #           # O O #
#77 88#           # M M #
#     #           #     #
#MM MM###################
#AA AA##    POT 6 MARGORP
#RR RR## MOTTOB 6 MARGORP
#GGdGG##             dop=
#OOoOO## MOTTOB 5 MARGORP
#RRpRR##    POT 5 MARGORP
#PP=PP###################

Any 'gaps' (whether from short lines, or how the programs are laid out) are filled with random characters, protected by comment characters. Any lines starting with =pod prevent Perl to see the rest of the program; this way we get to have two programs per rotation; flipping the program in the x-axis exposes the other program.

A few things need to be taken care off: programs should finish with semi-colon or a right-paren which closes a block. That way, the final statement is finished, and only then, Perl will recognized the =pod as the start of a POD section. Second, if we have a construct of the form s[pattern][replacement], with a newline between the s[pattern] and [replacement], we must add a space after s[pattern]. Otherwise, we may end up with s[pattern]#, and that # Perl will not see as a comment, but as a delimiter for the replacement part. With a space before the #, Perl will treat it as a comment.

Up to the tasks!

No rotations, no mirroring

if(eof()){say+("11 *25 *\n7 4*10 *5 *10 4*" .
"\n5 4*12 7*12 4*\n3 6*12 7*12 6*\n2 9*9 9*".
"9 9*\n 47*\n49*\n49*\n49*\n 47*\n  5*7 21*".
"7 5*\n4 4*7 3*4 5*4 3*7 4*\n7 **7 *6 3*6 *".
"7 **\n")=~s/(\d+)(\D)/$2 x$1/gre}else{chomp(
$_=<>);if(/\D/){/^google/&&die;$_=length}else
{$_=sprintf"00%b",$_;$_=/00100(.{5})*$/?1:0}}
say;

No input

Without input, this does the "In Honor of Adam West" task. We're using a simple encoded string, where repeated characters are encoded as NNc, which means NN times the character c. The string is decoded and printed.

Try it online!

Integer input (non negative)

Now we determine whether the given number is a Rude Number. We take the number, get the binary representation, prepend 00, and look whether the result contains 00100 followed by Ns 0s and 1s, where N is a multiple of 5.

Try it online!

String input

For other inputs, if the input equals google, we die. Otherwise, we print the length of the input.

Try it online!

No rotation, mirrored.

If we mirror the program, we effectively end up with:

if(eof()){$_="Hello, World!"}else{$_=<>;chomp
;if(/^-?\d+$/){if($_){$x=1+2*($_<0?1:$_);@x=(
' $'x$_,' |'x$_,'-'x$x,'~'x$x,'-'x$x);$_=join
$/,grep$_,@x}else{$_="Congratulations on yo".
"ur new baby! :D"}}else{s[a([^aA]*)a?] #
[$1=~y,a-zA-Z,A-Za-z,r]ige}};say;

No input.

The program prints out Hello, World!. Nothing creative going on here.

Try it online!

Integer input

We do the "It's my Birthday :D" task. If the input equals 0, we print out Congratulations on your new baby! :D. For the input (N) is positive, we start printing out N candles, then a cake of width 2 * N - 1. If the input is negative, we print a candleless cake, with width 3. All pretty straightforward.

Try it online!

String input

Now we do the "No A. just CAPS LOCK". We repeatedly find strings which are delimited by a (either case), with no a in between (with some trickery to make it work for the end of the string as well. We throw away the bounding as, and flip the case of the string between the as.

Try it online!

Rotating 90° counter clockwise, no mirroring

We then end up with effectively:

if(eof()){{say++$_;redo}}
else{$_=<>;chomp;if(/\D/)
{/^.+?(?{say$&})(?!)/;/^(
..*).(?{say$1})(?!)/x}else
{$p=$_>1;$n=$_;$p&&=$n%$_
for 2..$n-2;say!!$p}}

No input

With no input, we enter an infinite loop, where we increment $_ and print the result.

Try it online!

Integer input (non-negative)

We will now determine whether the given number is a prime number. We do this by checking whether non of the integers between (but not including) 1 and the input number evenly divides the input number. We then print the result (1 if it's a prime, an empty line if it's not).

Try it online!

String input

Now we do the YouTube Comments #1 task. We do this by finding all sub strings of the given string, which are anchored at the beginning. This is done by use a regexp (/^.*?/), printing the match (/(?{say $&})/) and then failing the match (/(?!)/ (it can never happen that the current position isn't followed by an empty string)). This cause Perl to backtrack and try the next match. The quantifier modifier ? makes Perl try the shortest strings first. This takes care of the first half (including the full line). For the second half, we use /^(..*)./, which does almost the same thing, except it only matches sub strings which are followed by at least one other character (so, it skips the full string), and it tries it in "longest first" order.

Try it online!

Rotating 90° counter clockwise, mirrored

Then we effectively get:

if(eof()){$_=join"",A..Z,
A..Y;/.{26}(?{say$&})(?!)/
;exit}$_=<>;$v=aeiouy;$c=
"[^$v]";$v="[$v]";if(
/^($c*$v*($c))$c*($v)/){ 
say$1.((({split//,bpcgdtf.
vgkkgpbsztdvfzs}->{$2}||$2
).$3)x 2)}else{@x=(0,1);@x
=($x[1],$x[0]+$x[1])while
--$_>=0;say$x[0]}

No input

This prints out the "Tabula Recta". It does so by creating a string consisting of all the letters A to Z, followed by the letters A to Y (so, 51 letters in total). We then find all sub strings of length 26 and print them, using the same trick as above.

Try it online!

Integer input (non negative)

In this case, we calculate the Nth Fibonacci number, where N is the input. We do this by keeping track of two numbers, initialized to (0, 1), and N times replacing (n, m) by (m, n + m).

Try it online!

String input

Now we "Covfefify a string". We start of by grabbing the parts of the string we need (/^($c*$v*($c))$c*($v)/, where $c and $v are character classes matching consonants and vowels). We find the replacement consonant by doing a lookup ({split//,bpcgdtfvgkkgpbsztdvfzs}->{$2}||$2 -- the string is split into a list of characters, the surrounding {} turns the list into a hash ref; the ->{$2} indexes the second captures; if there is no match, the ||$2 makes it return the second capture -- this takes care of consonants which are replaced by themselves). Then it's a matter of constructing the final string.

Try it online!

Rotate the program, no mirroring

We effectively end up with:

if(eof()){$_=("___|"x18).$/;$_ x=2;s/^..|..$//g;$_ x=5}
else{@c=map{$_-1}<>=~/./g;$_=$".(""," ___","  _"," ___"
)[$c[0]].$/.$".("_===_","....."," /_\\","(_*_)")[$c[0]]
.$/.($","\\",$",$")[$c[4]]."(".(".","o","O","-")[$c[2]]
.(",",".","_",$")[$c[1]].(".","o","O","-")[$c[3]].")".(
$","/",$",$")[$c[5]].$/.("<",$","/",$")[$c[4]]."(".($".
": ","] [","> <","   ")[$c[6]].")".(">",$","\\",$")[$c[
5]]."\n (".(" : ",'" "',"___","   ")[$c[7]].")"}say;

No input

We now "Build me a brick wall!". We start off by concatenating the string ___| 18 times by it self, adding a newline, then doubling the line. We remove the first two characters, and the last two characters before the final newline. We then print the result 5 times.

Try it online!

Other input

It's time to build a snowman. We split the input on characters (which is assumed to be a string consisting of 1s, 2s, 3s, and 4s). It's then just a matter of combining the pieces of the snowman by getting the right parts from a series of lists.

Try it online!

Rotated 180°, mirrored.

Effectively, we have:

if(eof()){say$_%15?$_%5?$_%3?$_:Fizz:Buzz:FizzBuzz for 
1..100;exit}say<>=~/^8|^1[18](...)*$/?an:a;

No input

Without input, the program does the FizzBuzz challenge. Nothing special going here, we loop numbers from 1 to 100, if 15 divides it evently, "FizzBuzz" is printed; if 5 divides it evently, "Buzz" is printed; if 3 divides it evenly, "Fizz" is printed, else, the number itself is printed.

Try it online!

Other input (assumed to be a non-negative integer)

This does the "You're on a 8 day streak!" task. If the input starts with 8, or starts with either 18 or 11 followed by 3 k digits for some k >= 0, we print "an", else we print "a".

Try it online!

Rotated 270° counter clockwise, no mirroring.

We end up with:

$_="Happy Birt"
."hday to You";
say;say;say
s!to!Dear!r=~
s!You!Perl!r;say;

This does only one thing, sing "Happy Birthday". The string "Happy Birthday to You" is created, and printed twice. Then it's printed with "to" replaced by "Dear", and "You" by "Perl". Then the original string is printed once again.

Try it online!

Rotated 270° counter clockwise, mirrored.

Effectively, we end up with:

$x=(("Baby Shark".(
" doo"x6).$/)x3).Baby.
" Shark!";say$x;say$x
=~s/Baby/$_/gr for
Daddy,Mommy,Grandpa,
Grandma;

This sings Baby Shark. It creates the string "Baby Shark doo doo doo doo\n", repeated thrice, followed by "Baby Shark!". This is printed, then it's printed another four times with Baby replaced by "Daddy", "Mommy", "Grandpa", and "Grandma" repectively.

Try it online!

| improve this answer | |
\$\endgroup\$
  • 2
    \$\begingroup\$ Nice work! Minor thing though, the "don't Google Google" challenge asks for the length of the input, rather than the reverse! \$\endgroup\$ – Dom Hastings Jun 30 at 19:35
  • \$\begingroup\$ @DomHastings Fixed now. Also added 4 more orientations. \$\endgroup\$ – Abigail Jul 1 at 19:14
  • \$\begingroup\$ Yes! Awesome work! \$\endgroup\$ – Dom Hastings Jul 1 at 19:44
  • 2
    \$\begingroup\$ I think I spend more work creating this post than actually coding. \$\endgroup\$ – Abigail Jul 3 at 15:38
4
\$\begingroup\$

Befunge-93, 4 orientations, 4 tasks, 1205 bytes

In Honor of Adam West

>52*"       **       *      ***      *       **       "v  v.:>1
v"    ****       ***    *****    ***       ****    "*52<  <1+^
>52*"  *****       *********************       *****  "v
v" *********************************************** "*52<
>52*"*************************************************"v
v"*************************************************"*52<
>52*"*************************************************"v
v" *********************************************** "*52<
>52*"  *********         *********         *********  "v
v"   ******            *******            ******   "*52<
>52*"     ****            *******            ****     "v
v"       ****          *     *          ****       "*52<
>52*"           *                         *           "v
                            >        ^v         **25"A"<
                            v-1,\_@#:<<
                            >        ^v       *2"s"<
>52*"EEEEE      DDDD     CCCC       BBBB      AAA "v
v"A   A     B   B     C         D   D     E    "*52<
>52*" EEEE     D   D         C      BBBB     AAAAA"v
v"A   A     B   B     C         D   D     E    "*52< <,,,,,,,,,,,,,,@
>52*"EEEEE      DDDD     CCCC       BBBB     A   A"v v"Hello, World!"*25

Try it online!

Nothing special here. We push the 650 characters which needs to be printed on the stack, then use a loop to print 650 characters.

5 Favorite Letters

Mirroring the original program vertically gives us:

>52*"EEEEE      DDDD     CCCC       BBBB     A   A"v v"Hello, World!"*25
v"A   A     B   B     C         D   D     E    "*52< <,,,,,,,,,,,,,,@
>52*" EEEE     D   D         C      BBBB     AAAAA"v
v"A   A     B   B     C         D   D     E    "*52<
>52*"EEEEE      DDDD     CCCC       BBBB      AAA "v
                            >        ^v       *2"s"<
                            v-1,\_@#:<<
                            >        ^v         **25"A"<
>52*"           *                         *           "v
v"       ****          *     *          ****       "*52<
>52*"     ****            *******            ****     "v
v"   ******            *******            ******   "*52<
>52*"  *********         *********         *********  "v
v" *********************************************** "*52<
>52*"*************************************************"v
v"*************************************************"*52<
>52*"*************************************************"v
v" *********************************************** "*52<
>52*"  *****       *********************       *****  "v
v"    ****       ***    *****    ***       ****    "*52<  <1+^
>52*"       **       *      ***      *       **       "v  v.:>1

Try it online!

As above; it pushes the 230 characters to be printed on the stack, and then uses a loop to print 230 characters. It will reuse part of the loop from the solution above.

Count up forever

Mirroring the original program horizontally give us:

         1>:.v  v"       **       *      ***      *       **       "*25>
          ^+1<  <25*"    ****       ***    *****    ***       ****    "v
                v"  *****       *********************       *****  "*25>
                <25*" *********************************************** "v
                v"*************************************************"*25>
                <25*"*************************************************"v
                v"*************************************************"*25>
                <25*" *********************************************** "v
                v"  *********         *********         *********  "*25>
                <25*"   ******            *******            ******   "v
                v"     ****            *******            ****     "*25>
                <25*"       ****          *     *          ****       "v
                v"           *                         *           "*25>
                <"A"52**         v^        >
                                 <<:#@_\,1-v
                    <"s"2*       v^        >
                    v" AAA      BBBB       CCCC     DDDD      EEEEE"*25>
                    <25*"    E     D   D         C     B   B     A   A"v
                    v"AAAAA     BBBB      C         D   D     EEEE "*25>
   @,,,,,,,,,,,,,,< <25*"    E     D   D         C     B   B     A   A"v
52*"!dlroW ,olleH"v v"A   A     BBBB       CCCC     DDDD      EEEEE"*25>

Try it online!

Uses a tiny loop. In the loop it duplicates the top of the stack, prints it, then adds 1 to the top of the stack. Rinse and repeat. 1 is pushed on the stack before entering the loop.

Hello, World

Rotating the original program by 180° gives the following program:

52*"!dlroW ,olleH"v v"A   A     BBBB       CCCC     DDDD      EEEEE"*25>
   @,,,,,,,,,,,,,,< <25*"    E     D   D         C     B   B     A   A"v
                    v"AAAAA     BBBB      C         D   D     EEEE "*25>
                    <25*"    E     D   D         C     B   B     A   A"v
                    v" AAA      BBBB       CCCC     DDDD      EEEEE"*25>
                    <"s"2*       v^        >
                                 <<:#@_\,1-v
                <"A"52**         v^        >
                v"           *                         *           "*25>
                <25*"       ****          *     *          ****       "v
                v"     ****            *******            ****     "*25>
                <25*"   ******            *******            ******   "v
                v"  *********         *********         *********  "*25>
                <25*" *********************************************** "v
                v"*************************************************"*25>
                <25*"*************************************************"v
                v"*************************************************"*25>
                <25*" *********************************************** "v
                v"  *****       *********************       *****  "*25>
          ^+1<  <25*"    ****       ***    *****    ***       ****    "v
         1>:.v  v"       **       *      ***      *       **       "*25>

Try it online!

This will push the necessary characters on the stack, and then prints those characters (no loop).

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

Bash, 4 orientations, 4 tasks, 1794 bytes

We are (ab)using the fact that (ba)sh is a true interpreter: it reads a line of code, and execute it. This means, once it has encountered an exit, it will never see the rest of the program, and won't complain it cannot parse it.

5 Favorite Letters

echo " AAA      BBBB       CCCC     DDDD      EEEEE";#   eedw
echo "A   A     B   B     C         D   D     E    ";#   xcoh
echo "AAAAA     BBBB      C         D   D     EEEE ";#   ih i
echo "A   A     B   B     C         D   D     E    ";#   toxl
echo "A   A     BBBB       CCCC     DDDD      EEEEE";#     =e
exit                                                ;#    $$
                                                          x([
                                                          ;(
                                                          dx1
                                                          o+
                                                          n1]
                                                          e)
                                                           )
###                                                      ;;;;
;;;                                                      ####
"
c" #;                                                    tixe
\! #;"       **       *      ***      *       **       " ohce
,d #;"    ****       ***    *****    ***       ****    " ohce
ol #;"  *****       *********************       *****  " ohce
lr #;" *********************************************** " ohce
lo #;"*************************************************" ohce
eW #;"*************************************************" ohce
H  #;"*************************************************" ohce
"" #;" *********************************************** " ohce
   #;"  *********         *********         *********  " ohce
oot#;"   ******            *******            ******   " ohce
hhi#;"     ****            *******            ****     " ohce
ccx#;"       ****          *     *          ****       " ohce
eee#;"           *                         *           " ohce

Try it online!

Count up forever

Rotating this by 90° counter clock wise, we end up with

while [ 1 ]  ;# eeeeeeeeeeeeee
do x=$((x+1));# xccccccccccccc
echo $x;done ;# ihhhhhhhhhhhhh
exit         ;# tooooooooooooo

                 """""""""""""
                     ***
######              *****
;;;;;;             *******
"""""              ********
E   E             *********
E E E             **********
E E E             **********
E E E            ** *********
EEEEE            *  *********
                    ******  *
                    ******  *
                    *****    *
                    *****
                    *****
 DDD               ******
D   D             *******
D   D            ********
D   D             *******
DDDDD              ******
                   ******
                   *******
                   **********
                  **********
                 ***********
C   C            ***********
C   C            ***********
C   C             **********
C   C              **********
 CCC               *******
                   ******
                   ******
                  *******
                 ********
                  *******
 B B               ******
B B B               *****
B B B               *****
B B B               *****    *
BBBBB               ******  *
                    ******  *
                 *  *********
                 ** *********
                  **********
                  **********
 AAAA             *********
A A                ********
A A                *******
A A                 *****
 AAAA                ***
"""""            """""""""""""
                ;;;;;;;;;;;;;;
ooooot          ##############
hhhhhi       #;           tixe
cccccx       #; "!dlroW " ohce
eeeeee       #;"c\,olleH" ohce

Try it online!

In Honor of Adam West

Rotating this once again by 90° counter clockwise, and we get:

echo "           *                         *           ";#eee
echo "       ****          *     *          ****       ";#xcc
echo "     ****            *******            ****     ";#ihh
echo "   ******            *******            ******   ";#too
echo "  *********         *********         *********  ";#
echo " *********************************************** ";# ""
echo "*************************************************";#  H
echo "*************************************************";# We
echo "*************************************************";# ol
echo " *********************************************** ";# rl
echo "  *****       *********************       *****  ";# lo
echo "    ****       ***    *****    ***       ****    ";# d,
echo "       **       *      ***      *       **       ";# !\
exit                                                    ;# "c
                                                            "
####                                                      ;;;
;;;;                                                      ###
 )
 )e
]1n
 +o
1xd
 (;
[(x
 $$    #;                                                tixe
e=     #;"EEEEE      DDDD     CCCC       BBBB     A   A" ohce
lxot   #;"    E     D   D         C     B   B     A   A" ohce
i hi   #;" EEEE     D   D         C      BBBB     AAAAA" ohce
hocx   #;"    E     D   D         C     B   B     A   A" ohce
wdee   #;"EEEEE      DDDD     CCCC       BBBB      AAA " ohce

Try it online!

Hello, World!

A final rotation of 90° counter clockwise, and we get:

echo "Hello,\c";#       eeeeee
echo " World!" ;#       xccccc
exit           ;#       ihhhhh
##############          tooooo
;;;;;;;;;;;;;;
"""""""""""""            """""
      ***                AAAA
     *****                 A A
    *******                A A
   ********                A A
   *********             AAAA
  **********
  **********
 ********* **
 *********  *
 *  ******
 *  ******               BBBBB
*    *****               B B B
     *****               B B B
     *****               B B B
     ******               B B
     *******
     ********
     *******
     ******
     ******
    *******               CCC
 **********              C   C
  **********             C   C
  ***********            C   C
  ***********            C   C
  ***********
  **********
 **********
    *******
     ******
     ******              DDDDD
     *******             D   D
     ********            D   D
     *******             D   D
     ******               DDD
     *****
     *****
*    *****
 *  ******
 *  ******
 *********  *            EEEEE
 ********* **            E E E
  **********             E E E
  **********             E E E
   *********             E   E
   ********              """""
    *******             ;;;;;;
     *****              ######
      ***
"""""""""""""

ooooooooooooot #;         tixe
hhhhhhhhhhhhhi #; enod;x$ ohce
cccccccccccccx #;))1+x(($=x od
eeeeeeeeeeeeee #;  ] 1 [ elihw

Try it online!

On TIO, this will actually print Hello,\c, followed by World! on a newline. Whether \c is supported is implementation defined according to POSIX.1, and so is the alternative, the -n option. The intention is to surpres the newline echo by default emits. (And on my system, the builtin echo omits a newline when encountering \c, but doesn't recognize -n -- and the standalone utility does both). YMMV.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.