36
\$\begingroup\$

Problem

Given no input write a program or a function that outputs or returns the following string:

(<(<>(<>.(<>.<(<>.<>(<>.<>)<>.<>)>.<>).<>)<>)>)

Rules

  • Shortest program wins.
  • Trailing whitespace allowed.
  • Trailing newlines allowed.
  • Unused parameters for functions allowed.
\$\endgroup\$
  • 5
    \$\begingroup\$ Note: this string is the concatenation of substrings of (<>.<>): "(<" + "(<>" + "(<>." + ... + "(<>.<>)" + "<>.<>)" + ">.<>)" + ... + ">)" \$\endgroup\$ – JungHwan Min Jun 20 '17 at 11:38
  • 2
    \$\begingroup\$ This would've been a little less "hardcode all the text!" if it were a bigger crowd... \$\endgroup\$ – totallyhuman Jun 20 '17 at 21:56
  • \$\begingroup\$ @totallyhuman Will think about it next time \$\endgroup\$ – LiefdeWen Jun 21 '17 at 6:15

45 Answers 45

1
\$\begingroup\$

J, 30 25 24 Bytes

;}.}:~.(<\,<\.)'(<>.<>)'

Explanation later, I have a feeling I can golf this more...

Edit:

-5 6 Bytes thanks to @FrownyFrog :)

Explanation:

               '(<>.<>)'   | The face
       (   <\.)            | Apply box to the suffixes of '(<>.<>)': Gives '(<>.<>)', '<>.<>)' ... ')'
          ,                | Append to...
        <\                 | Box applied to the prefixes of '(<>.<>)'
 }.}:~.                    | Remove the extra '(<>.<>)', as well as '(' and ')' from the front and back
;                          | Join into one string
\$\endgroup\$
  • \$\begingroup\$ @FrownyFrog ...maybe.... :P \$\endgroup\$ – Bolce Bussiere Jan 25 '18 at 19:26
1
\$\begingroup\$

Python 2, 54 bytes

f=lambda i=5:L*0**i or L[:-i]+f(i-1)+L[i:]
L='(<>.<>)'

Try it online!

Slight improvement on the leading Python 2 answer

Port of my Lenny's answer

\$\endgroup\$
1
\$\begingroup\$

Stax, 16 14 bytes

ü■_'σIHa¬ø·hÑè

Run and debug it at staxlang.xyz!

Unpacked (16 bytes) and explanation:

"(<>.":w|[D$3T:w
"(<>."              String literal                     (<>.
      :w            Palindromize, flipping (){}[]<>    (<>.<>)
        |[          Array of prefixes                  [ ( (< .. (<>.<>) ]
          D         Drop first                         [ (< (<> .. (<>.<>) ]
           $        Concatenate                        (<(<>(<>.(<>.<(<>.<>(<>.<>)
            3T      Drop last three                    (<(<>(<>.(<>.<(<>.<>(<>.
              :w    Palindromize, flipping (){}[]<>    
\$\endgroup\$
0
\$\begingroup\$

Retina, 39 bytes


(<(a(a.(a.<(a.a(abab>bba)>)
b
.a)
a
<>

Try it online!

\$\endgroup\$
0
\$\begingroup\$

JavaScript (ES6), 52 bytes

Obvious solution; doesn't seem to be much room for any trickery here.

f=

_=>"(<(<>(<>.(<>.<(<>.<>(<>.<>)<>.<>)>.<>).<>)<>)>)"

o.innerText=f()
<pre id=o>

\$\endgroup\$
  • \$\begingroup\$ I did some trickery! \$\endgroup\$ – Artyer Jun 20 '17 at 11:49
  • \$\begingroup\$ @Artyer, so I saw, nicely done :) \$\endgroup\$ – Shaggy Jun 20 '17 at 11:49
0
\$\begingroup\$

Brainfuck, 489 bytes

++[------>+<]>---.[-->+++<]>.[--->++<]>.[-->+++<]>.++.--[--->++<]>.[-->+++<]>.++.[->+++++++++<]>.------.[-->+++<]>.++.[->+++++++++<]>.--[----->+<]>.[--->++<]>.[-->+++<]>.++.[->+++++++++<]>.--[----->+<]>.++.--[--->++<]>.[-->+++<]>.++.[->+++++++++<]>.--[----->+<]>.++.+[--->++<]>-.-[-->+++<]>.++.[->+++++++++<]>.--[----->+<]>.++.+[--->++<]>-.+[-->+++<]>-.[->+++++++++<]>.--[----->+<]>.++.+[--->++<]>-.+++++.--[----->+<]>.++.+[--->++<]>-.-[-->+++<]>.++.+[--->++<]>-.+[-->+++<]>-.+[--->++<]>-.
\$\endgroup\$
0
\$\begingroup\$

C#, 104 bytes

string a="(<>.<>)",s="";for(int i=2,k=a.Length;i<k*2-1;i++){s+=(k>i)?a.Substring(0,i):a.Substring(i-k);}

Try it online!

\$\endgroup\$
  • \$\begingroup\$ t.Text? Do you perhaps mean another variable? \$\endgroup\$ – LiefdeWen Jun 20 '17 at 10:54
  • 9
    \$\begingroup\$ I think it would be shorter to... just do the entire string. \$\endgroup\$ – Leaky Nun Jun 20 '17 at 10:56
  • \$\begingroup\$ @LiefdeWen done \$\endgroup\$ – Erlantz Calvo Jun 20 '17 at 11:03
  • \$\begingroup\$ @LeakyNun Yeah C# doesn't fare well at all at most kolmogorov complexity questions \$\endgroup\$ – LiefdeWen Jun 20 '17 at 11:06
  • \$\begingroup\$ @LeakyNun just trying to give tips \$\endgroup\$ – LiefdeWen Jun 20 '17 at 11:07
0
\$\begingroup\$

Bubblegum, 24 bytes

0000000: d3 b0 d1 b0 b1 03 22 3d 10 b6 01 13 76 10 52 13  ......"=....v.R.
0000010: 42 82 09 10 06 b1 35 01                          B.....5.

Try it online!

\$\endgroup\$
0
\$\begingroup\$

Pyth, 29 bytes

K"(<>.<>)"s++m<KhdS5Km>hdK_S5

Try it here!

\$\endgroup\$
0
\$\begingroup\$

Perl 5, 75+1(-w) = 76 bytes

I'm unsure of how needed -w is, but it wasn't printing the output until I tried it.

for(-5..5){$l=-abs($_)+7;$o=$_>0?7-$l:0;$s.=substr"(<>.<>)",$o,$l;}print$s;

Try it online!

Ungolfed

for(-5..5){
  $l = -abs($_) + 7;
  $o = $_ > 0 ? 7 - $l : 0;
  $s .= substr "(<>.<>)", $o, $l;
}
\$\endgroup\$
0
\$\begingroup\$

T-SQL, 54 bytes (the trivial solution)

PRINT'(<(<>(<>.(<>.<(<>.<>(<>.<>)<>.<>)>.<>).<>)<>)>)'

I like this challenge, simple and yet so annoying.

I tried hard to find alternates, but nothing was shorter, due mostly due to the length of SQL keywords. Hmm, maybe I need to create GolfSQL with minimized keywords and other optimizations...

Here's my best attempt at a procedural solution (97 bytes golfed, presented here formatted):

DECLARE @ INT=-4, @o VARCHAR(99)=''
a:
    SET @o+=SUBSTRING('(<>.<>)',@,7)
    SET @+=1
IF @<7 GOTO a
PRINT @o

This works because SUBSTRING can take a negative start value, in which case it simply reduces the length.

Edit: Found a slightly shorter non-trivial solution (96 bytes):

SELECT STRING_AGG(SUBSTRING('(<>.<>)',number-4,7),'')FROM
spt_values WHERE TYPE='P'AND number<11

Only works on MS SQL Server, where the master database has a built-in system table called spt_values. This table (when filtered by WHERE TYPE='P') can be used as a number table to generate the values from -4 to 6.

\$\endgroup\$
0
\$\begingroup\$

Japt, 41 25 bytes

"(<>.<>)"
¤£¯Ò°TÃ+U+¤£s°V

Test it

\$\endgroup\$
0
\$\begingroup\$

Julia, 60 bytes

prod([("(<>.<>)"^2)[min(x,8):max(x,7)] for x in[9:13;1:6]])
\$\endgroup\$
  • 1
    \$\begingroup\$ I think there is a superfluous space in ] for \$\endgroup\$ – Jonathan Frech Aug 30 '18 at 20:46
  • \$\begingroup\$ @JonathanFrech This is new, in Julia 1.0 it is needed. Julia had some potential but really seems to lack commitment to become a serious golfing language. \$\endgroup\$ – mschauer Aug 31 '18 at 15:40
  • \$\begingroup\$ I do not know a lot about Julia, but TIO's Julia seems to be on version 0.4; the space does not appear necessary there. \$\endgroup\$ – Jonathan Frech Aug 31 '18 at 17:03
0
\$\begingroup\$

Matlab, 74 68 65 bytes

function[m]=f,s='(<>.<>)';m=s;for i=2:6,m=[s(1:8-i),m,s(i:7)];end

Runs perfectly on Matlab and prints: (<(<>(<>.(<>.<(<>.<>(<>.<>)<>.<>)>.<>).<>)<>)>). However, it prints on Octave. So the link is useless.

Try it Online!

\$\endgroup\$
-2
\$\begingroup\$

PHP, 47 bytes

Needs a file with the Content-Type text/plain

(<(<>(<>.(<>.<(<>.<>(<>.<>)<>.<>)>.<>).<>)<>)>)

Try it online!

PHP, 53 bytes

<?="(<(<>(<>.(<>.<(<>.<>(<>.<>)<>.<>)>.<>).<>)<>)>)";

Try it online!

\$\endgroup\$
  • 1
    \$\begingroup\$ The first one is also a valid echo program. \$\endgroup\$ – CalculatorFeline Jun 20 '17 at 18:56
  • \$\begingroup\$ @CalculatorFeline No in the first example the PHP interpreter prints only the text. There is no start tag. We must avoid to do this in a html file. \$\endgroup\$ – Jörg Hülsermann Jun 21 '17 at 0:04
  • \$\begingroup\$ ...Confused. Where did I mention HTML? \$\endgroup\$ – CalculatorFeline Jun 21 '17 at 0:51
  • \$\begingroup\$ @CalculatorFeline Nowhere! You can not use echo in the first case \$\endgroup\$ – Jörg Hülsermann Jun 21 '17 at 13:10
  • \$\begingroup\$ I suppose the correct language is cat. \$\endgroup\$ – CalculatorFeline Jun 21 '17 at 15:18

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.