# Display a Lemniscate (∞) [closed]

The infinity symbol is also called a lemniscate. Your program must draw a lemniscate with text via standard out (formatted with newline feeds) or graphically.

The infinity symbol (by my standards) must be continuous (that is, every non-whitespace character must be touching two other non-whitespace characters diagonally or orthogonally). It must also have two and no more than two gaps of enclosed whitespace (connectivity for whitespace is only orthogonal). Thus, the following output fails:

   ooo   ooo
o    o o    o
o      o      o
o    o o    o
ooo   ooo


A correct version the above example might be

  oooo   oooo
o    o o    o
o      o      o
o    o o    o
oooo   oooo


or

  ooo   ooo
o   o o   o
o     o     o
o   o o   o
ooo   ooo


The size of the ∞ is unimportant. The orientation of the ∞ is unimportant. Symmetry is also unimportant. Graphical displays are accepted as well. Appropriate newline feeds are required in the output.

This is a question so answers will be scored in bytes, with less bytes being better.

• "Your program must draw a lemnescate with text". OK: Print["∞"] – Not a tree Jul 18 '17 at 0:31
• @Notatree You can golf that to Print@"∞", or "∞"& if a lambda function is acceptable. (I assume your language is Mathematica judging by the square brackets and upercase Print) – Pavel Jul 18 '17 at 0:45
• Gotta have a winning criterion, or people'll bury your question. ;) Are you asking for the shortest code possible? – totallyhuman Jul 18 '17 at 0:48
• Why has this been closed as too broad? I get that it lacks a winning criterion, which as JonathanAllen mentioned is likely intended to be code-golf, but closing as too broad without explanation baffles me. – Wheat Wizard Jul 18 '17 at 1:29
• @WheatWizard, it clearly is too broad. Just looking at the first couple of answers shows that it's about arguing that a given output falls under the umbrella provided by the spec rather than golfing an implementation of a narrowly defined spec. It's really a bunch of similar questions rather than one question. – Peter Taylor Jul 18 '17 at 7:02

# Desmos, 22 bytes

r=\sqrt{\sin 2\theta }


Try it here! Desmos is a graphing tool. This plots the polar equation:

which draws a lemniscate shape.

• Where is "Desgos" and 4 bytes s½2Θ? :p – Jonathan Allan Jul 18 '17 at 1:27
• @JonathanAllan Believe it or not I was working a language to interface with desmos, I called it "sindesi". I started the project 2 ish years ago and haven't gotten back to it yet. – Conor O'Brien Jul 18 '17 at 1:30

# J, 8 bytes

3 5$' o'  Like Conor's, prints:  o o o o o o o  $ is J's shape operator, so we are creating a 3 x 5 grid, using the fill chacters o. When fill runs out, \$ repeats them cyclically by default.

Try it online!

• I really like this one :D – Conor O'Brien Jul 18 '17 at 0:48
• Another approach for 11 bytes: 2":__,i.3 4 – Conor O'Brien Jul 18 '17 at 1:14

# Mathematica, 4 bytes

∞&


I think this answer covers all the criteria

# Mathematica, 17 bytes

Graphics@Text@∞


@ovs's opinion is that the right answer is...

# Mathematica, 2 bytes

8&


and I agree!

• Strictly speaking, I believe that's a snippet, not a program or function (but you can make it a function by putting & at the end). – Not a tree Jul 18 '17 at 8:04
• Strictly speaking this is a very broad question...Why not? I'll edit! – J42161217 Jul 18 '17 at 8:08
• I think an 8 matches all criteria as well. So 8& for 2 bytes – ovs Jul 18 '17 at 17:51
• @ovs I agree! posted! – J42161217 Jul 18 '17 at 17:56
• Neither single character answers fit the criteria that "every non-whitespace character must be touching [at least] two other non-whitespace characters diagonally or orthogonally" – Jonathan Allan Jul 19 '17 at 1:40

# Mathematica - 49 bytes

ParametricPlot[{ReIm[Sin[t+I Sin[t]]]},{t,0,2Pi}]


Result:

• Is this acceptable? To answer your own challenge? – sergiol Jul 18 '17 at 0:24
• Ps: The downvote was not me. – sergiol Jul 18 '17 at 0:25
• Can I compete in my own challenge? – sergiol Jul 18 '17 at 0:27
• Can you give a screenshot of the output? – Pavel Jul 18 '17 at 0:46
• You can golf this down a bit, using @ and the fact you don't need a list for the first parameter: ReIm@Sin[t+I Sin@t]~ParametricPlot~{t,0,2Pi} for 44 bytes. – numbermaniac Jul 18 '17 at 7:37

# ///, 13 bytes

/z/ o o
/zozz


Try it online! Outputs:

 o o
o o o
o o


I think this is the smallest valid "lemniscate" allowed by the rules.

# Python 2, 21 19 bytes

print"o o\nooo\n"*3


Try it online!

This prints:

o o
ooo
o o
ooo
o o
ooo


It may not look like a lemnescate but it has two enclosed spaces (marked with x)

o o
ooo
oxo
ooo
oxo
ooo


And every o is connected to at least two other os. Thus despite not looking anything like what it is supposed to this fulfills the bare-minimum requirements.

• heh, I was just going to say o o, ooo :) – Jonathan Allan Jul 18 '17 at 1:14
• @JonathanAllan It looks like you pointing out an error helped me save a byte. So double thanks for that. :) – Wheat Wizard Jul 18 '17 at 1:15
• I don't understand how you can ask why the question was voted "Too Broad" and also post this answer. The fact that you think you can argue that this meets the spec is exhibit A. And if this is valid, then surely 8 is a valid answer in CJam, GolfScript, etc.? – Peter Taylor Jul 18 '17 at 7:12
• you can golf this down to 10 bytes: print"∞" – Uriel Jul 18 '17 at 8:31
• @PeterTaylor I don't see what you are saying. The original post pretty clearly lays out specific requirements for answers, and this fits those requirements. Just because this looks like an 8 does not mean that this is the same as printing an 8. An 8 on its own meets none of the requirements. – Wheat Wizard Jul 18 '17 at 13:30

# Jelly,  8  7 bytes

8RKḊs5Y


As a full program prints:

 2 3
4 5 6
7 8


Which seems to adhere to the specification.

Try it online!

### How?

8RKḊs5Y - Main link: no arguments
8R      - range of 8 -> [1,2,3,4,5,6,7,8]
K     - join with spaces -> [1,' ',2,' ',3,' ',4,' ',5,' ',6,' ',7,' ',8]
Ḋ    - dequeue -> [' ',2,' ',3,' ',4,' ',5,' ',6,' ',7,' ',8]
s5  - split into chunks of length 5 -> [[' ',2,' ',3,' '],[4,' ',5,' ',6],[' ',7,' ',8]]
Y - join with newlines -> [' ',2,' ',3,' ',\n,4,' ',5,' ',6,'\n',' ',7,' ',8]
- implicit print


# Charcoal, 9 bytes

o↘ooo‖Ｂ¬←


Draws the actual last example. 10-byte version that takes a size parameter as input:

Ｇ→↘↘Ｎo‖Ｂ¬←


Try it online! Link is to verbose version of code.

# Charcoal, 7 bytes (ASCII-art version)

ＧＨX²o‖Ｂ


Try it online!

The first part (ＧＨX²o) prints a hollow polygon of size 2 in the X direction using the o char as border, that results in this:

 o
o o
o


Then I only have to reflect the canvas horizontally (skipping the middle column), to get this:

 o o
o o o
o o


• 6 bytes: ↙oo‖ＢT. – Neil Jul 18 '17 at 21:27
• @Neil whawhawhat??? You can use complex directions with ReflectButterfly?? – Charlie Jul 18 '17 at 21:30
• You can use any sequence of directions. It just happens that :T expands to :Right, :Down, :Left which is exactly what's needed to reflect the two os to give the hexagon. – Neil Jul 18 '17 at 21:33
• In fact you're using the same trick with your PolygonHollow - :X expands to the four diagonals, so PolygonHollow just draws a diamond shape. – Neil Jul 18 '17 at 21:34
i;f(){while(i++<18)putchar(i%6?(i/6+i)%2?32:'o':'\n');}