The infinity symbol is also called a lemnescate. Your program must draw a lemnescate 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.

share|improve this question
4  
"Your program must draw a lemnescate with text". OK: Print["∞"] – Not a tree 7 hours ago
3  
@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) – Phoenix 7 hours ago
5  
Gotta have a winning criterion, or people'll bury your question. ;) Are you asking for the shortest code possible? – totallyhuman 7 hours ago
2  
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 6 hours ago
1  
@AdamMendenhall - Note for the future, there is a sandbox for preparing your questions for the main site; also it's good to be around for some time after you post a question (even if sandboxed) for the almost inevitable question or two regarding specifics. – Jonathan Allan 6 hours ago

10 Answers 10

Desmos, 22 bytes

r=\sqrt{\sin 2\theta }

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

r = sqrt[sin 2 theta]

which draws a lemniscate shape.

share|improve this answer
    
Where is "Desgos" and 4 bytes s½2Θ? :p – Jonathan Allan 6 hours ago
1  
@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 6 hours ago

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!

share|improve this answer
1  
I really like this one :D – Conor O'Brien 7 hours ago
    
Another approach for 11 bytes: 2":__,i.3 4 – Conor O'Brien 6 hours ago

///, 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.

share|improve this answer

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.

share|improve this answer
    
heh, I was just going to say o o, ooo :) – Jonathan Allan 6 hours ago
    
@JonathanAllan It looks like you pointing out an error helped me save a byte. So double thanks for that. :) – Wheat Wizard 6 hours ago
    
I think you can remove one of the o's: "o o\noo\n" – xnor 5 hours ago
    
@xnor You can not, the top right o is only touching one other o in that case. – Wheat Wizard 5 hours ago
1  
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 53 mins ago

Mathematica, 3 bytes

I think this answer covers all the criteria

Mathematica, 17 bytes

Graphics@Text@∞
share|improve this answer
    
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 1 min ago

Mathematica - 49 bytes

ParametricPlot[{ReIm[Sin[t+I Sin[t]]]},{t,0,2Pi}]
share
    
Is this acceptable? To answer your own challenge? – sergiol 7 hours ago
    
Ps: The downvote was not me. – sergiol 7 hours ago
1  
    
Can you give a screenshot of the output? – Phoenix 7 hours ago
    
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 28 mins ago

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
share|improve this answer

Pyth, 16 bytes

K" o o"K++tKdeKK

Output:

 o o
o o o
 o o

Try it online!


Pyth, 18 bytes

K"o "+d*K2*3K+d*K2

Try it online!

Output:

 o o 
o o o 
 o o 
share|improve this answer

Charcoal, 1 byte

Try it online!

This just prints the character.

Charcoal, 7 bytes (ASCII-art version)

GHX²o‖B

Try it online!

The first part (GHX²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

Link to the verbose version.

share|improve this answer

Python 3, 28 bytes

print(''' o o
o o o
 o o''')

Try it online!

share|improve this answer
3  
Didn't downvote, but just printing a string is boring. It doesn't show any effort or thought. The question is bad, but that doesn't make the answer any good. – Wheat Wizard 7 hours ago
1  
@WheatWizard I have to disagree. In what world is the most readable AND the shortest solution to a problem bad? The name of the game is code golf, not "needlessly complex code challenge". – rosslh 7 hours ago
    
Its not the shortest python solution any longer ;) – Wheat Wizard 7 hours ago
    
@WheatWizard 👍 nice – rosslh 7 hours ago
    
A single quoted string is shorter: print(' o o\no o o\n o o') – ovs 3 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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