105
votes
\$\begingroup\$

Challenge

Draw the Olympic Games logo...

Olympic Games logo

...as character (e.g. ASCII) art!

Sample Output

      * * *               * * *               * * *
  *           *       *           *       *           *
*               *   *               *   *               *
*               * * *               * * *               *
*           *   *   *   *       *   *   *   *           *
  *       *   *       *   *   *   *       *   *       *
      * * *               * * *               * * *
          *               *   *               *
            *           *       *           *
                * * *               * * *

Your art doesn't have to look exactly like mine, but it has to represent the Olympic rings well enough that it's recognizable.

Rules

  • The program must write the art to the console.
  • Shortest code (in bytes, any language) wins.
  • A solution that prints rings in their respective colors (or a close representation) will be awarded a minus-twenty-point bonus.

The winner will be chosen on February 23rd at the end of the 2014 Winter Olympics.


Winners

\$\endgroup\$
18
  • 7
    \$\begingroup\$ 20 bonus points. Um, why would I want +20 to my score? \$\endgroup\$
    – Justin
    Commented Jan 21, 2014 at 7:21
  • 21
    \$\begingroup\$ Hum, this is a trademark… \$\endgroup\$
    – moala
    Commented Jan 21, 2014 at 9:56
  • 4
    \$\begingroup\$ @moala I think this falls under fair use policy. \$\endgroup\$
    – Nzall
    Commented Jan 21, 2014 at 14:23
  • 11
    \$\begingroup\$ In color, it's evident that they are interlocking rings, not merely overlapping. Few of the entries so far have accounted for that. \$\endgroup\$ Commented Jan 21, 2014 at 17:53
  • 6
    \$\begingroup\$ Totally IANAL: ok to write the sofware which draws the O******ic R**gs, not ok to execute it. :-) \$\endgroup\$ Commented Jan 21, 2014 at 18:53

51 Answers 51

164
votes
\$\begingroup\$

Commodore 64 BASIC

Writing directly in the screen and color memory.

Program

Output:

Output


Here's how you do this with sprites.

\$\endgroup\$
8
  • 1
    \$\begingroup\$ That's fantastic. +1. Can we get a byte count? \$\endgroup\$
    – Adam Maras
    Commented Jan 21, 2014 at 17:44
  • 2
    \$\begingroup\$ Remember that you can abbreviate commands and line numbers too on C64 BASIC if you want to golf. \$\endgroup\$
    – friol
    Commented Jan 21, 2014 at 18:36
  • 15
    \$\begingroup\$ The only thing that bothers me about this answer is: How is this ascii art? \$\endgroup\$
    – Justin
    Commented Jan 21, 2014 at 23:43
  • 10
    \$\begingroup\$ this is PETSCII-art \$\endgroup\$
    – friol
    Commented Jan 22, 2014 at 6:55
  • 7
    \$\begingroup\$ @Quincunx: Since PETSCII is also known as CBM ASCII, this might qualify. If you want a different character to be used for drawing (to make it look more like classic ASCII art), replacing 160 (inverted space) with 42 (asterisk) in line 100 should do the trick. \$\endgroup\$
    – Heinzi
    Commented Jan 22, 2014 at 6:58
86
votes
\$\begingroup\$

HTML Fiddle - 48, 35, 33 characters (Thanks @Dom and @cnst!)

OOO<p style="margin:-15px 6px">OO

Output:

enter image description here

\$\endgroup\$
8
  • 2
    \$\begingroup\$ You can save more chars using: OOO<div style="margin:-10px 5px">OO instead... (I think it needs to be a block though, hence the <div/>) \$\endgroup\$ Commented Jan 22, 2014 at 6:54
  • \$\begingroup\$ As this is not console output, you are better of at the free-style olympics contest: codegolf.stackexchange.com/q/19050/15168 \$\endgroup\$ Commented Jan 22, 2014 at 8:55
  • \$\begingroup\$ @DomHastings: Good call! Answer updated :) \$\endgroup\$
    – Briguy37
    Commented Jan 22, 2014 at 14:19
  • 3
    \$\begingroup\$ Then why bother with div, can just use p instead! \$\endgroup\$
    – cnst
    Commented Jan 22, 2014 at 18:48
  • 2
    \$\begingroup\$ @PygameNerd: It depends on your definition of "ASCII art": Yes if your definition is "ASCII characters arranged to form a picture"; no if your definition is "ASCII characters in a fixed-width text editor to form a picture". As for whether it is output to the console as CousinCocaine said, if the definition is "The control or monitoring unit of a computer, containing the keyboard or keys, switches, etc.", then the web browser output is part of the monitor and thus the console (though this is probably not what the OP intended). \$\endgroup\$
    – Briguy37
    Commented Jan 22, 2014 at 21:57
76
votes
\$\begingroup\$

BASH in color - 271 - 20 = 251 – With entangled rings ;P

o='_4mGA  _0mGA  _1mG\n _4m/A \A _0m/A \\_1mA /A \\\n_4mD_3m---_0mD_2m---_1mD\n _4m\A_3m/_4m/A_0m\\_3m\\A_2m/_0m/A_1m\\_2m\A _1m/\n_4mG_3mD_0m---_2mD_1m---\n_3m   A\A /A _2m\A /_1m\n _3mA G  A_2mG\n';o=${o//D/|A   |};o=${o//A/    };o=${o//G/   ---};printf "${o//_/\\e[3}"

Result:

enter image description here


And the for fun of it one: 61 - 20 = 41.

x='_4mO_3m^_0m0_2m^_1mO\n_3m V _2mV\n';printf "${x//_/\\e[3}"

enter image description here


LZ77 version:

echo H4sIALOY5VIAA12QwRXAIAhD767ghQV8CnYbXYENOnw1YqX1xk8wQGz1UiJKKRFebLX8ARsIs7g0g/djN7CdRAYC7Pf6h+5RVR3foMdTMcqHWlS3jKr5RKO/g25doJdXZ+ii75CseU2zNkGzH6HYCPKhPGmA2Wh3+7mEDHMgb/2cUPYJH2gPhtZxAQAA|base64 -d|zcat
\$\endgroup\$
9
  • 13
    \$\begingroup\$ Not many answers so far get the alternating overlap of the rings right, so this is worth an upvote even if the score is a bit higher. \$\endgroup\$ Commented Jan 21, 2014 at 18:41
  • 1
    \$\begingroup\$ bash: !/\\e[3}": event not found :( \$\endgroup\$ Commented Jan 22, 2014 at 18:42
  • \$\begingroup\$ I think your bash version is valid -- nowhere in the OP does it specify the size of the graphic -- but you need to fix the "V" shape rings. Maybe a tilde (~) for the bottom of the rings? \$\endgroup\$
    – AmeliaBR
    Commented Jan 22, 2014 at 19:04
  • \$\begingroup\$ @AlterLagos: You might find update works? \$\endgroup\$
    – Runium
    Commented Jan 22, 2014 at 19:30
  • \$\begingroup\$ @AmeliaBR: Yes, That one was more for the fun of it, and not that seriously meant. Tried with various. Perhaps this is more to the liking? x='54mO53m_50m052m_51mO\n53m U 52mU\n';printf "${x//5/\\e[3}" – (I'm a bit evil with the 5 here.) Or even this might be better, with overlap in mind: x='54mO53mA50m052mA51mO\n53m U 52mU\n';printf "${x//5/\\e[3}" – though it might look more messy then the others. \$\endgroup\$
    – Runium
    Commented Jan 22, 2014 at 19:32
76
votes
\$\begingroup\$

Sinclair BASIC on the ZX Spectrum 48K (261 bytes)

BASIC listing:

BASIC listing

Final result:

Result

Program running and code measuring:

Program running

BASIC listing in text format:

5 INK VAL "7": CLS 
10 LET a=VAL "42": LET b=VAL "131": LET c=VAL "40": CIRCLE INK SGN PI;a,b,c: CIRCLE INK PI-PI;a+a+a,b,c: CIRCLE INK VAL "2";VAL "210",b,c
20 LET a=VAL "84": LET b=VAL "87": CIRCLE INK VAL "6";a,b,c: CIRCLE INK VAL "4";a+a,b,c
30 FOR l=PI-PI TO VAL "21": FOR c=PI-PI TO VAL "31": IF ATTR (l,c)<>VAL "63" THEN PRINT INK VAL "8";AT l,c;"*"
40 NEXT c: NEXT l

TAP file with the program, suitable for emulators or real machine using DivIDE or DivMMC: http://www.zxprojects.com/images/stories/draw_the_olympics_flag.tap

\$\endgroup\$
6
  • 17
    \$\begingroup\$ I like the asciification part :) \$\endgroup\$ Commented Jan 22, 2014 at 14:02
  • 1
    \$\begingroup\$ This is lovely! \$\endgroup\$
    – pcnThird
    Commented Jan 23, 2014 at 2:04
  • \$\begingroup\$ The use of Z80 sprite graphic is simply genial!! PS subtract 20 points for colors. \$\endgroup\$
    – Tomas
    Commented Jan 27, 2014 at 20:32
  • \$\begingroup\$ It feels so dirty to generate regular art and then make ASCII art from it. :) \$\endgroup\$ Commented Feb 24, 2014 at 8:12
  • \$\begingroup\$ Could you include the source code in a copy-able form? \$\endgroup\$ Commented Sep 9, 2015 at 20:20
44
votes
\$\begingroup\$

So I didn't actually read properly, it's ASCII-art, so I guess this is invalid. Oops!


HTML 121 (141 - 20)

<pre style=line-height:3px;letter-spacing:-3px><font color=#06f>O <font color=#000>O <font color=red>O
 <font color=#fa0>O <font color=#193>O

In Chrome:

What is this! An Olympic flag for ants?

PHP 103 (123 - 20)

<pre style=line-height:3px;letter-spacing:-3px><?=($f='<font color=')."#06f>O ${f}#000>O ${f}red>O
 ${f}#fa0>O ${f}#193>O";
\$\endgroup\$
2
  • 2
    \$\begingroup\$ You can get the colours a bit closer with no penalty: blue:#06f, yellow:#fa0, green:#193 \$\endgroup\$
    – r3mainer
    Commented Jan 21, 2014 at 14:10
  • 2
    \$\begingroup\$ As this is not console output, you are better of at the free-style olympics contest: codegolf.stackexchange.com/q/19050/15168 \$\endgroup\$ Commented Jan 22, 2014 at 8:54
38
votes
\$\begingroup\$

Ruby: 198 characters - 20 = 178

a=[*0..9].map{[' ']*35}
d=->c,x,y=0{11.times{|i|7.times{|j|a[y+j][x+i]="^[[3#{c}m#^[[0m"if[248,774,1025,1025,1025,774,248][j]&1<<i!=0}}}
d[4,0]
d[0,12]
d[1,24]
d[3,6,3]
d[2,18,3]
$><<a.map{|r|r*''}*$/

(Note that ^[ are single characters.)

Sample run:

olympic games logo

\$\endgroup\$
37
votes
\$\begingroup\$

Mathematica - 185

c[x_, y_] := 
 Table[Boole[Abs[(i - x)^2 + (j - y)^2 - 16] < 4], {i, 0, 15}, {j, 0, 
   30}]
MatrixForm@
 Replace[Blue c[5, 4] + Black c[5, 14] + Red c[5, 24] + 
   Yellow c[9, 9] + Green c[9, 19], {0 -> "", 
   c_ + _ | c_ :> Style["*", c]}, {2}]

Here is the ouput

enter image description here

Another version, based on rasterization of vector graphics

MatrixForm@
 Replace[ImageData@
   Rasterize[
    Graphics[{Blue, Circle[{4, 9}, 4], Black, Circle[{14, 9}, 4], Red,
       Circle[{24, 9}, 4], Yellow, Circle[{9, 4}, 4], Green, 
      Circle[{19, 4}, 4]}], ImageSize -> {30, 15}], {c_ :> 
    Style["*", RGBColor@c]}, {2}]

enter image description here

\$\endgroup\$
2
  • 2
    \$\begingroup\$ You get points for the prettiest output. \$\endgroup\$ Commented Jan 21, 2014 at 16:41
  • \$\begingroup\$ Nice work. I posted my own version of your code. \$\endgroup\$
    – Mr.Wizard
    Commented Jan 22, 2014 at 20:14
34
votes
\$\begingroup\$

PostScript, 203 (-20 = 183)

%!
/Courier findfont 12 scalefont setfont
/l { setrgbcolor translate 20 { 0 30 moveto (*) show 18 rotate } repeat } def
140 200 0 0 1 l 45 -30 1 1 0 l 45 30 0 0 0 l 45 -30 0 1 0 l 45 30 1 0 0 l
showpage

I maintain that this counts as "ASCII art", though it doesn't write to the console. Output:

Olympic Rings

This could be golfed a little more.

\$\endgroup\$
2
  • 19
    \$\begingroup\$ If this is ASCII art, it surely is the first I've seen using rotated asterisks. \$\endgroup\$ Commented Jan 22, 2014 at 15:56
  • 2
    \$\begingroup\$ I'm sure it won't be the last. \$\endgroup\$
    – Pseudonym
    Commented Jan 23, 2014 at 0:28
25
votes
\$\begingroup\$

Windows Command Script - 112 percent bytes

%1%0 @echo. set
%2.= oooo 
%2,=o    o
%1%.%%.%%.%&%1%,%%,%%,%&%1o  %.%%.%  o&%1%.%%.%%.%&%1   %,%%,%&%1   %.%%.%

100% Olympic rings

And of course, the obligatory cheat'ish version - 4 bytes

%~n0

saved as:

@echo. oooo  oooo  oooo&echo.o    oo    oo    o&echo.o   oooo  oooo   o&echo. oooo  oooo  oooo&echo.   o    oo    o&echo.    oooo  oooo.cmd
\$\endgroup\$
1
  • 10
    \$\begingroup\$ we need more answers in BAT and CMD :) \$\endgroup\$
    – Einacio
    Commented Jan 21, 2014 at 20:18
22
votes
\$\begingroup\$

APL (82) (-20 = 62)

Edit: for a change, this program is simple enough that TryAPL will touch it, so you can run it there (just paste the line in).

Not sure if I can claim the 'color' bit, I'm representing them all differently though.

2/' ▓█░▓▒'[1+(13↑⍉n)⌈¯13↑⍉32↑¯26↑⌈1.1×11↓n←⍉c,0,2×c,0,2×c←(⍳2/10)∊⌈5+5×1 2∘○¨⍳1e4]

The APL console doesn't support color, so I used shaded block characters (assigning any kind of other ASCII art would be as simple as replacing the characters at the beginning of the string.)

They should look like unbroken circles (depending on your font.)

      2/' ▓█░▓▒'[1+(13↑⍉n)⌈¯13↑⍉32↑¯26↑⌈1.1×11↓n←⍉c,0,2×c,0,2×c←(⍳2/10)∊⌈5+5×1 2∘○¨⍳1e4]
    ▓▓▓▓▓▓▓▓▓▓▓▓          ████████████          ▓▓▓▓▓▓▓▓▓▓▓▓    
  ▓▓            ▓▓      ██            ██      ▓▓            ▓▓  
▓▓                ▓▓  ██                ██  ▓▓                ▓▓
▓▓            ░░░░░░░░░░░░          ▒▒▒▒▒▒▒▒▒▒▒▒              ▓▓
▓▓          ░░    ▓▓  ██  ░░      ▒▒    ██  ▓▓  ▒▒            ▓▓
▓▓        ░░      ▓▓  ██    ░░  ▒▒      ██  ▓▓    ▒▒          ▓▓
▓▓        ░░      ▓▓  ██    ░░  ▒▒      ██  ▓▓    ▒▒          ▓▓
▓▓        ░░      ▓▓  ██    ░░  ▒▒      ██  ▓▓    ▒▒          ▓▓
  ▓▓      ░░    ▓▓      ██  ░░  ▒▒    ██      ▓▓  ▒▒        ▓▓  
    ▓▓▓▓▓▓░░▓▓▓▓          ██░░██▒▒████          ▓▓▒▒▓▓▓▓▓▓▓▓    
          ░░                ░░  ▒▒                ▒▒            
            ░░            ░░      ▒▒            ▒▒              
              ░░░░░░░░░░░░          ▒▒▒▒▒▒▒▒▒▒▒▒                

Or:

      2/' bByRg'[1+(13↑⍉n)⌈¯13↑⍉32↑¯26↑⌈1.1×11↓n←⍉c,0,2×c,0,2×c←(⍳2/10)∊⌈5+5×1 2∘○¨⍳1e4]
    bbbbbbbbbbbb          BBBBBBBBBBBB          RRRRRRRRRRRR    
  bb            bb      BB            BB      RR            RR  
bb                bb  BB                BB  RR                RR
bb            yyyyyyyyyyyy          gggggggggggg              RR
bb          yy    bb  BB  yy      gg    BB  RR  gg            RR
bb        yy      bb  BB    yy  gg      BB  RR    gg          RR
bb        yy      bb  BB    yy  gg      BB  RR    gg          RR
bb        yy      bb  BB    yy  gg      BB  RR    gg          RR
  bb      yy    bb      BB  yy  gg    BB      RR  gg        RR  
    bbbbbbyybbbb          BByyBBggBBBB          RRggRRRRRRRR    
          yy                yy  gg                gg            
            yy            yy      gg            gg              
              yyyyyyyyyyyy          gggggggggggg                
\$\endgroup\$
21
votes
\$\begingroup\$

Another attempt in Perl, 130 120

Thanks to manatwork for helping with this

for(qw(15005 40410 802a0 80a28 41414 15005 808 2a0)){$s=sprintf"%20b",hex;$s=~y/01/ #/;print$s.substr(reverse($s),1).$/}

Output:

   # # #         # # #         # # #   
 #       #     #       #     #       # 
#         # # #         # # #         #
#       # #   # #     # #   # #       #
 #     # #     # #   # #     # #     # 
   # # #         # # #         # # #   
        #       #     #       #        
          # # #         # # #          
\$\endgroup\$
2
  • 3
    \$\begingroup\$ You can spare: 4 character by using for instead of foreach; 2 characters by removing () round sprintf()'s arguments; 2 characters by removing hex's parameter; 1 character by using y/// instead of tr///; 1 character by removing the final ;. \$\endgroup\$
    – manatwork
    Commented Jan 21, 2014 at 14:02
  • \$\begingroup\$ @manatwork Thanks! I've never even heard of y/// before. Will go and look it up now. \$\endgroup\$
    – r3mainer
    Commented Jan 21, 2014 at 14:09
20
votes
\$\begingroup\$

Python: 157 140 138 133 122 107 characters

107

(thanks to manatwork)

for o in"jzd360 1zlpwci 3ydgr29 20pzv5u jzd360 149ytc b8n40".split():print bin(int(o,36))[2:].rjust(34,'0')

sample output:

0001001000000001001000000001001000
0100000010000100000010000100000010
1000000001001000000001001000000001
0100000110000110000110000110000010
0001001000000001001000000001001000
0000000100000010000100000010000000
0000000001001000000001001000000000

157

print'\n'.join(['{0:b}'.format(o).rjust(39,'0') for o in [45099909288,137984246274,275230249985,276241138945,137984246274,45099909288,1078001920,352343040]])

122

(just started this one, I will try to improve it)

h=lambda x:bin(int("15bb511iun9aqulod22j8d4 ho8skh  "[x::8],36))[2:].rjust(20)
for x in range(8):print h(x)+h(x)[::-1][1:]

with better output: 120 characters

for o in"jzd360 1zlpwci 3ydgr29 20pzv5u jzd360 149ytc b8n40".split():print bin(int(o,36))[2:].replace('0',' ').rjust(34)

sample output:

   1  1        1  1        1  1   
 1      1    1      1    1      1 
1        1  1        1  1        1
 1     11    11    11    11     1 
   1  1        1  1        1  1   
       1      1    1      1       
         1  1        1  1         
\$\endgroup\$
8
  • 1
    \$\begingroup\$ What about base 36? This has 140 characters: print'\n'.join(['{0:b}'.format(int(o,36)).rjust(39,'0')for o in"kpvbkq0 1re099tu 3ifszg1t 3iwiuayp 1re099tu kpvbkq0 httbls 5trxmo".split()]). Regarding the “better output” version, there you can spare rjust()'s second parameter. (And insert a “t” in this post's heading.) \$\endgroup\$
    – manatwork
    Commented Jan 21, 2014 at 12:20
  • \$\begingroup\$ I was looking for a better solution, yours look great! \$\endgroup\$
    – evuez
    Commented Jan 21, 2014 at 12:26
  • 1
    \$\begingroup\$ Nice improvement with bin(). But why are you using str() around it? bin()'s return value is already str. \$\endgroup\$
    – manatwork
    Commented Jan 21, 2014 at 13:17
  • 3
    \$\begingroup\$ Shouldn't the 5th line be 010000010100000101000101000001010000010? The bottom two rings look a bit broken to me. \$\endgroup\$
    – r3mainer
    Commented Jan 21, 2014 at 13:20
  • \$\begingroup\$ @manatwork indeed, didn't think about that! \$\endgroup\$
    – evuez
    Commented Jan 21, 2014 at 13:25
17
votes
\$\begingroup\$

Perl, 177 163

An improved version thanks to Dom Hastings:

$s=$"x3;print"  .-~-. "x3 .$/." /$s  \\"x3 .$/."|$s$s "x4 ."
 \\$s ./~\\.$s./~\\.$s /
  '-./'$s'\\-/'$s'\\.-'
"."$s |$s"x3 ."
$s "." \\$s  /"x2 ."
$s"."$s'-.-'"x2;

Output:

  .-~-.   .-~-.   .-~-. 
 /     \ /     \ /     \
|       |       |       |       
 \    ./~\.   ./~\.    /
  '-./'   '\-/'   '\.-'
    |       |       |   
     \     / \     /
      '-.-'   '-.-'
\$\endgroup\$
1
  • 2
    \$\begingroup\$ Hooray for Perl! A couple of extra savings: instead of using "\n" as $r, you can use $/ which defaults to "\n", literal newlines might even save you more in a couple of places. You can also save 1 more char using $s=$"x3 rather than $s=" ". Hope that helps! \$\endgroup\$ Commented Jan 21, 2014 at 10:28
15
votes
\$\begingroup\$

C, 257 bytes

#include <stdio.h>
d(i,j){int r=35;float x=r,y=0;while(--r>0){char s[8]={29,(((int)y+j)/32)+32,(((int)y+j)%32)+96,(((int)x+i)/32)+32,(((int)x+i)%32)+64,31,'.',0};puts(s);x-=0.2*y;y+=0.2*x;}}main(){d(140,200);d(185,170);d(230,200);d(275,170);d(320,200);}

This could have been golfed a bit more.

This has to be run on a Tektronix 4010 (or an emulator such as xterm -t). Output:

Ooutput

This is indeed ASCII art, since those are all '.' characters. And it does output to the console, as requested. Some Tektronix emulators support colour. Mine didn't, so I couldn't do that.

\$\endgroup\$
12
votes
\$\begingroup\$

Java, 181 179 161 156 bytes

enum M{M;{System.out.print(new java.math.BigInteger("2b13bp4vx9rreb1742o0tvtpxntx0mgsfw48c4cf",36).toString(2).replaceAll(".{29}","$0\n"));System.exit(1);}}

(Won't compile on jdk 1.7, requires 1.6 or lower)

The output:

11100011111110001111111000111
10111110111011111011101111101
01111111000111111100011111110
10111100111001110011100111101
11100011111110001111111000111
11111101111101110111110111111
11111111000111111100011111111

Definitely not a winner, but come on, it's java.

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Spare 2 characters by not capturing in replaceAll()'s regular expression and putting back the entire matched part: replaceAll(".{29}","$0\n"). (There may be an extra line break at the end of your file, as I count only 181 characters in the posted code.) \$\endgroup\$
    – manatwork
    Commented Jan 22, 2014 at 16:01
  • 1
    \$\begingroup\$ One more thing: remove the import and put the package name directly in the constructor call. That reduces the size to 161 characters. \$\endgroup\$
    – manatwork
    Commented Jan 22, 2014 at 16:05
  • \$\begingroup\$ Spared another 5 bytes by changing class M{static{... to enum M{M;{.... Next big step is getting rid of BigInteger, is that possible? I'm trying to do some magic with String.format but have no results yet. \$\endgroup\$ Commented Jan 23, 2014 at 9:10
12
votes
\$\begingroup\$

Haskell, 200

main=mapM(putStrLn.map(\b->if b then '#' else ' '))$(map.map)(\(x,y)->or$map(\(n,m)->(<2).abs.(18-)$sqrt$(n-x)^2+(m-y*2)^2)$[(20,20),(60,20),(100,20),(40,40),(80,40)])$map(zip[0..120].repeat)[0..30]

Output:

            #################                       #################                       #################            
         ########### ###########                 ########### ###########                 ########### ###########         
      #######               #######           #######               #######           #######               #######      
     #####                     #####         #####                     #####         #####                     #####     
   #####                         #####     #####                         #####     #####                         #####   
  #####                           #####   #####                           #####   #####                           #####  
 #####                             ##### #####                             ##### #####                             ##### 
 ####                               #### ####                               #### ####                               #### 
 ####                               #### ####                               #### ####                               #### 
 ###                                 ### ###                                 ### ###                                 ### 
 ####                           #################                       #################                           #### 
 ####                        ########### ###########                 ########### ###########                        #### 
 #####                    #######  ##### #####  #######           #######  ##### #####  #######                    ##### 
  #####                  #####    #####   #####    #####         #####    #####   #####    #####                  #####  
   #####               #####     #####     #####     #####     #####     #####     #####     #####               #####   
     #####            #####    #####         #####    #####   #####    #####         #####    #####            #####     
      #######        #####  #######           #######  ##### #####  #######           #######  #####        #######      
         ########### ###########                 ########### ###########                 ########### ###########         
            #################                       #################                       #################            
                     ###                                 ### ###                                 ###                     
                     ####                               #### ####                               ####                     
                     ####                               #### ####                               ####                     
                     #####                             ##### #####                             #####                     
                      #####                           #####   #####                           #####                      
                       #####                         #####     #####                         #####                       
                         #####                     #####         #####                     #####                         
                          #######               #######           #######               #######                          
                             ########### ###########                 ########### ###########                             
                                #################                       #################                                

golfed out of:

{-# LANGUAGE NoMonomorphismRestriction #-}

olympMids = [(1,1),(3,1),(5,1),(2,2),(4,2)]
circleRadius = 0.9
circleBorder = 0.1
scaleFactor = 20
verticalScale = 0.5

distance :: Floating a => (a,a) -> (a,a) -> a
distance (x,y) (x2,y2) = sqrt $ (x2-x)^2 + (y2-y)^2

match :: (Floating a, Ord a) => (a,a) -> (a,a) -> Bool
match v v2 = (<circleBorder) . abs . (circleRadius-) $ distance v v2

matchOlymp :: (Floating a, Ord a) => (a,a) -> Bool
matchOlymp v = or $ map (match $ scale v) $ olympMids
  where
    scale (x,y) = (x / scaleFactor, y / scaleFactor / verticalScale)

board :: (Enum a, Num a) => a -> a -> [[(a, a)]]
board lx ly = map (zip [0..lx] . repeat) [0..ly]

printOlymp = mapM (putStrLn . map to) $ (map.map) matchOlymp $ board 120 30

main = printOlymp

to :: Bool -> Char
to True = '#'
to False = ' '
\$\endgroup\$
4
  • 2
    \$\begingroup\$ i still laugh about the map.map because it sounds funny. :D \$\endgroup\$
    – vek
    Commented Jan 22, 2014 at 15:32
  • \$\begingroup\$ It seems kind of bloated ... \$\endgroup\$
    – SamB
    Commented Jan 27, 2014 at 7:50
  • \$\begingroup\$ the rings or the code? \$\endgroup\$
    – vek
    Commented Jan 27, 2014 at 10:30
  • \$\begingroup\$ I mean the rings :-) \$\endgroup\$
    – SamB
    Commented Jan 27, 2014 at 19:22
11
votes
\$\begingroup\$

Ruby, 9

p"\044"*5

#satire

The rules allow for art that does not look exactly like the example, but it must "represent the Olympic rings well enough that it's recognizable".

You may recognize this representation of the Olympic Games logo.

\$\endgroup\$
8
  • \$\begingroup\$ Funny :) As a Chicagoan, I can tell you that's exactly what the mayor saw when he was courting the games ! \$\endgroup\$ Commented Jan 21, 2014 at 17:36
  • \$\begingroup\$ As a Vancouverite (2010 Games), I can also relate. :-) \$\endgroup\$ Commented Jan 21, 2014 at 18:28
  • 8
    \$\begingroup\$ I feel like I'm missing out on an inside joke here :-P \$\endgroup\$
    – Doorknob
    Commented Jan 22, 2014 at 3:23
  • 2
    \$\begingroup\$ @DoorknobofSnow Sorry, I though you were getting confused about character codes. If you don't get the connection between Olympics and dollar signs, I can't help you there. \$\endgroup\$
    – AmeliaBR
    Commented Jan 22, 2014 at 21:38
  • 8
    \$\begingroup\$ output is: $$$$$ \$\endgroup\$
    – Roger
    Commented Jan 22, 2014 at 22:44
11
votes
\$\begingroup\$

Javascript - 170 185 189 Chars

'jzd36071zlpwci73ydgr29720pzv5u7jzd3607149ytc7b8n40'.split(7).map(function(x){a=parseInt(x,36).toString(2);console.log((Array(35-a.length).join(0)+a).replace(/0/g,' '))})

Output:

   1  1        1  1        1  1    
 1      1    1      1    1      1  
1        1  1        1  1        1 
 1     11    11    11    11     1  
   1  1        1  1        1  1    
       1      1    1      1        
         1  1        1  1         

2nd Javascript - 25 Chars

console.log('O O O\n O O')

Output:

O O O 
 O O 

The second is lazy

\$\endgroup\$
7
  • 1
    \$\begingroup\$ You can spare; 2 characters by using “4” as separator instead of “.” and using digit 4 (without quotes) as split()'s parameter; 2 characters by removing the last 2 ;s. \$\endgroup\$
    – manatwork
    Commented Jan 21, 2014 at 16:31
  • \$\begingroup\$ A (currently) Firefox-only version of the above can be reduced even more, to 172 characters: 'kpvbkq041re099tu43ifszg1t43iwiuayp41sdk52824kpvbkq04httbls45trxmo'.split(4).map(x=>{a=parseInt(x,36).toString(2);console.log(' '.repeat(39-a.length)+a.replace(/0/g,' '))}). \$\endgroup\$
    – manatwork
    Commented Jan 21, 2014 at 16:35
  • \$\begingroup\$ Thanks, added your suggestion, I will leave it browser independent for now. \$\endgroup\$ Commented Jan 21, 2014 at 16:40
  • \$\begingroup\$ ◯ is not ascii... \$\endgroup\$
    – njzk2
    Commented Jan 21, 2014 at 20:44
  • \$\begingroup\$ @njzk2 Yup, solved it סּ_סּ \$\endgroup\$ Commented Jan 21, 2014 at 21:11
11
votes
\$\begingroup\$

Binary! (265 CHARS)

0001111100000000111110000000011111000
0100000001000010000000100001000000010
1000000001111100000000011111000000001
0100000011000011000001100001100000010
0001111100000000111110000000011111000
0000000010000001000001000000100000000
0000000001111100000000011111000000000

It is too large to win, but at least it looks cool!

\$\endgroup\$
2
  • \$\begingroup\$ Olympic logo in the Matrix. \$\endgroup\$
    – user13107
    Commented Jan 22, 2014 at 8:27
  • \$\begingroup\$ @user13107 What? \$\endgroup\$
    – Dozer789
    Commented Jan 28, 2014 at 22:12
10
votes
\$\begingroup\$

PHP - 99 (-20?)

 bbbb  ####  rrrr
b    b#    #r    r
b   ybyy  g#gg   r
 bbyb  ##g#  rrrr
   y    yg    g
    yyyy  gggg

That is definitely recognizable. I say that my "colors" count; it's a close representation.

If you don't like that, then here is

GolfScript - 101 (-20?)

' bbbb  ####  rrrr
b    b#    #r    r
b   ybyy  g#gg   r
 bbyb  ##g#  rrrr
   y    yg    g
    yyyy  gggg'
\$\endgroup\$
8
  • 16
    \$\begingroup\$ Where's the code? \$\endgroup\$
    – user11043
    Commented Jan 21, 2014 at 15:11
  • 14
    \$\begingroup\$ @Undo That is the code ;-) \$\endgroup\$
    – Doorknob
    Commented Jan 21, 2014 at 18:08
  • \$\begingroup\$ In truth, I don't know PHP. That is the only PHP program/style I know how to write. (Sure I've gone through a tutorial, but I forgot it). \$\endgroup\$
    – Justin
    Commented Jan 21, 2014 at 21:56
  • 2
    \$\begingroup\$ Wouldn't the PHP one come out as bbbb #### rrrr b b# #r r b ybyy g#gg r bbyb ##g# rrrr y yg g yyyy gggg on the screen? \$\endgroup\$
    – Mr Lister
    Commented Jan 22, 2014 at 7:55
  • 4
    \$\begingroup\$ You need to add header("Content-Type: text/plain"), the default for web servers is text/html \$\endgroup\$
    – Kroltan
    Commented Jan 22, 2014 at 12:27
10
votes
\$\begingroup\$

Bash + ImageMagick: 163 characters

e=ellipse
c=,10,5,0,360
convert -size 70x20 xc:black +antialias -stroke white -fill none -draw "$e 10,5$c$e 34,5$c$e 58,5$c$e 22,10$c$e 46,10$c" xpm:-|tr -dc ' .
'

Sample output:

.

     ...........             ...........             ...........
   ....       ....         ....       ....         ....       ....
 ...             ...     ...             ...     ...             ...
..                 ..   ..                 ..   ..                 ..
..                 ..   ..                 ..   ..                 ..
.                ...........             ...........                .
..             ......   ......         ......   ......             ..
..           ...   ..   ..   ...     ...   ..   ..   ...           ..
 ...        ..   ...     ...   ..   ..   ...     ...   ..        ...
   ....     ......         ......   ......         ......     ....
     ...........             ...........             ...........
            ..                 ..   ..                 ..
            ..                 ..   ..                 ..
             ...             ...     ...             ...
               ....       ....         ....       ....
                 ...........             ...........
\$\endgroup\$
10
votes
\$\begingroup\$

Perl 6: 112 77 56 characters, 75 bytes

say flip .ord.base(2).trans("01"=>" @")for"𜜜𢢢񃣡𦶲𜜜䔐㣠".comb
  • Unicde strings! (above string is "\x1C71C\x228A2\x438E1\x26DB2\x1C71C\x4510\x38E0")
  • .comb gives a List of the separate characters in a String (without argument anyway)
  • .ord gives character code number from character
  • .base(2) returns a string with base-2 encoding of that Int
  • .trans replaces the digits with space and @ for better visibility
  • flip reverses the characters of a string so that missing leading 0's don't mess up the drawing.
  @@@   @@@   @@@
 @   @ @   @ @   @
@    @@@   @@@    @
 @  @@ @@ @@ @@  @
  @@@   @@@   @@@
    @   @ @   @
     @@@   @@@

edit2: newer solution using qwote words and base-36 encoded

say flip :36($_).base(2).trans("01"=>" @")for<2HWC 315U 5XI9 3ESY 2HWC DN4 B8G>
  • <ABC DEF GHI> is a quote-words syntax in perl6, so you get a list of Strings
  • :36($_) creates an Int from a base-36 encoded string in $_ (for loop default variable)

edit: old solution has nicer (copied) drawing but is longer:

  say flip :36($_).base(2).trans("01"=>" o")for<KPVBKQ0 1RE099TU 3IFSZG1T 3IWIUAYP 1SDK5282 KPVBKQ0 HTTBLS 5TRXMO>
   o o o         o o o         o o o
 o       o     o       o     o       o
o         o o o         o o o         o
o       o o   o o     o o   o o       o
 o     o o     o o   o o     o o     o
   o o o         o o o         o o o
        o       o     o       o
          o o o         o o o
\$\endgroup\$
10
votes
\$\begingroup\$

Mathematica 185 175

10 bytes saved by mathe.

The rings below are ASCII 'O's.

The letter "O", slightly translucent, in Century Gothic, printed 5 times at font size=145 printer points.

This is not terminal art. However it fully satisfies Wikipedia's definition of Ascii art: http://en.wikipedia.org/wiki/ASCII_art.

Graphics[{[email protected],Style["O",#]~Text~#2&@@@{{Blue,{-1.5,1}},{Black,{0,1}},{Red,{1.5,1}},{Orange,{-.8,.4}},{Darker@Green,{.8,.4}}}},BaseStyle->{145,FontFamily->"Century Gothic"}]

olympic rings

\$\endgroup\$
5
  • 2
    \$\begingroup\$ As this is not console output, you are better of at the free-style olympics contest: codegolf.stackexchange.com/q/19050/15168 \$\endgroup\$ Commented Jan 22, 2014 at 8:56
  • \$\begingroup\$ FontSize -> can be removed. \$\endgroup\$
    – matrix42
    Commented Sep 13, 2017 at 8:23
  • \$\begingroup\$ @mathe, True. I used the font size merely to make the output a reasonable size. \$\endgroup\$
    – DavidC
    Commented Sep 13, 2017 at 11:25
  • \$\begingroup\$ @DavidC I mean you could replace FontSize -> 145 by 145. \$\endgroup\$
    – matrix42
    Commented Sep 14, 2017 at 2:42
  • \$\begingroup\$ @mathe. Yes! Thanks. \$\endgroup\$
    – DavidC
    Commented Sep 14, 2017 at 19:54
8
votes
\$\begingroup\$

JavaScript: 153 chars

I wanted to see if I could do it any faster using algebra to actually graph the circles:

s="";c=[3,7,11,7,19,7,7,4,15,4];for(y=10;y>0;y--){s+="\n";for(x=0;x<23;x+=.5){t=1;for(i=0;i<9;i+=2){a=x-c[i];b=y-c[i+1];d=a*a+b*b-9;t&=(d<0?-d:d)>3}s+=t}}

(c is an array of five (x,y) pairs, the centers of the circles, flattened to save ten characters.)

output:

1110000000111111111000000011111111100000001111
1000111110001111100011111000111110001111100011
0011111111100111001111111110011100111111111001
0011111111100000001111111110000000111111111001
0011111110000111000011111000011100001111111001
1000111100001111100001110000111110000111100011
1110000000111111111000000011111111100000001111
1111111100111111111001110011111111100111111111
1111111110001111100011111000111110001111111111
1111111111100000001111111110000000111111111111

159 chars is a little more readable:

s="";c=[3,7,11,7,19,7,7,4,15,4];for(y=10;y>0;y--){s+="\n";for(x=0;x<23;x+=.5){t=1;for(i=0;i<9;i+=2){a=x-c[i];b=y-c[i+1];d=a*a+b*b-9;t&=(d<0?-d:d)>3}s+=t?" ":t}}

output:

   0000000         0000000         0000000    
 000     000     000     000     000     000  
00         00   00         00   00         00 
00         0000000         0000000         00 
00       0000   0000     0000   0000       00 
 000    0000     0000   0000     0000    000  
   0000000         0000000         0000000    
        00         00   00         00         
         000     000     000     000          
           0000000         0000000            

In 167 chars we have "colors":

s="";c=[3,7,11,7,19,7,7,4,15,4];for(y=10;y>0;y--){s+="\n";for(x=0;x<23;x+=.5){t=1;for(i=0;i<9;i+=2){a=x-c[i];b=y-c[i+1];d=a*a+b*b-9;t&=(d<0?-d:d)>3;h=t?i:h}s+=t?" ":h}}

output:

   8888888         0000000         2222222    
 888     888     000     000     222     222  
88         88   00         00   22         22 
88         8844400         0066622         22 
88       4444   0044     6600   2266       22 
 888    4444     0004   6000     2226    222  
   8888888         0000000         2222222    
        44         44   66         66         
         444     444     666     666          
           4444444         6666666            

And with 189 chars, I can make the radius r adjustable as well:

r=5;s="";c=[r,0,2*r+1,r,3*r+2,0,4*r+3,r,5*r+4,0];for(y=-r;y<3*r;y++){s+="\n";for(x=0;x<9*r;x+=.5){t=1;for(i=0;i<9;i+=2){a=x-c[i];b=y-c[i+1];d=a*a+b*b-r*r;t&=(d<0?-d:d)>r;h=t?i:h}s+=t?" ":h}}

http://jsfiddle.net/mblase75/5Q6BX/

\$\endgroup\$
0
7
votes
\$\begingroup\$

APL, 8 chars/bytes*

Here's an answer pushing for lowest char count (this is code golf after all)

2 5⍴'○ '

Output:

○ ○ ○
 ○ ○ 

The symbol is ○, APL circle operator. You can put an 'O' instead, in case you want strictly ASCII output. I just thought it fit to use an APL symbol.


Just for kicks, here's a color version (37 chars - 20 = 17 score)

2 20⍴'m',⍨¯2↓3↓∈(⊂'m○ ^[[3'),⍪'40132 '
                      ‾‾ ← single Esc character, type Ctrl+V Esc on the terminal

Output: color rings terminal output ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
*: APL can be written in its own (legacy) single-byte charset that maps APL symbols to the upper 128 byte values. Therefore, for the purpose of scoring, a program of N chars that only uses ASCII characters and APL symbols can be considered to be N bytes long.

\$\endgroup\$
7
votes
\$\begingroup\$

CSS, 1176 922 855 771 bytes, -20 colour bonus = 751

html,head,title,body{display:block; color:transparent; font:bold 1em/1 monospace; height:0}
link,meta,style{display:none}
:before,:after{float:left; color:#000; white-space:pre;
content:'   @@@@@@@\A  @@@     @@@\A@@         @@ \A            @@\A@@         @@\A@@         @@\A  @@@     @@@\A    @@@@  @'}
html:before{color:blue}
title:before,title:after{color:blue; position:absolute; left:0; top:3em; content:'@@'}
title:after{color:red; top:7em; content:'                                   @@'}
head:after{color:red}
body:before{clear:left; content:'     '}
body:after,html:after{position:relative; top:-5em; color:#EC0;
content:'    @  @@@@\A   @@@     @@@\A  @@         @@\A  @@         @@\A  @@\A  @@         @@\A   @@@     @@@\A     @@@@@@@'}
html:after{color:#090}

CSS only, no markup needed. See markupless fiddle here: http://jsfiddle.net/XcBMV/12/

Rings

In colour, and with the correct overlap.

\$\endgroup\$
6
votes
\$\begingroup\$

Perl - 12 characters

say"OOO\nOO"

OK, so it's not an especially artistic rendering. ;-)

Slightly cuter:

perl -MTerm::ANSIColor=:constants -E'say ON_BRIGHT_WHITE,BLUE,O,BLACK,O,RED,O,$/,YELLOW,O,GREEN,O,RESET'
\$\endgroup\$
6
votes
\$\begingroup\$

GAS Assembly 16-bit BIOS OL loader – 617 - 20 = 597

Going crazy on length here, so mere for the fun of it.


It does not load much, but it loads The Olympic Games logo as ASCII with colors ;)

Code:

.code16;S:jmp o;nop;o:mov $1984,%ax;mov %ax,%ds;mov %ax,%es;movw $t,%si;r:lodsb;or %al,%al;jz q;cmp $33,%al;jg k;movb $0,c;call X;inc %dh;mov $0,%dl;call G;jmp r;k:sub $48,%al;mov %al,%cl;add %al,c;lodsb;cmp $32,%al;je v;mov %al,%bl;and $15,%bl;mov $35,%al;v:mov $9,%ah;mov $0,%bh;mov $0,%ch;int $16;call X;mov c,%dl;call G;jmp r;q:ret;G:mov $2,%ah;int $16;X:mov $3,%ah;mov $0,%bh;int $16;ret;c:.byte 0;t:.asciz "3 5A9 5H9 5D!1 1A7 1A5 1H7 1H5 1D7 1D!1A9 1A4N9 1H4B9 1D!1A7 1N1 1A3 1H1 1N5 1B1 1H3 1D1 1B7 1D!1 1A5 1N1 1A5 1H1 1N3 1B1 1H5 1D1 1B5 1D!3 4A1N9 4H1B9 5D!8 1N7 1N5 1B7 1B!9 1 5N9 5B!";.=S+510;.word 0xaa55

(Linux) Build and extract MBR image

as -o olymp.o olymp.S
objcopy -O binary olymp.o olymp.img

Running in emulator

(Have not tested it on my home computer yet ...)

qemu-system-i386 olymp.img

Result

enter image description here

\$\endgroup\$
4
  • 4
    \$\begingroup\$ You sure take the idea of not using external resources to an extreme, don't you? +1 \$\endgroup\$
    – Adam Maras
    Commented Jan 24, 2014 at 1:25
  • \$\begingroup\$ @AdamMaras: Yes, and there's that ;), had to try. Next is to incorporate a real load of OS. O`Loader II. \$\endgroup\$
    – Runium
    Commented Jan 25, 2014 at 2:46
  • \$\begingroup\$ How does it score if you measure the binary, assuming that the disk already had a boot sector so you can skip the 55h AAh at the end (along with any associated padding)? \$\endgroup\$
    – SamB
    Commented Jan 27, 2014 at 19:18
  • \$\begingroup\$ @SamB: That would be 275 bytes, 255 pt where the code part is about 91 bytes and the variable + plot data 184 bytes. \$\endgroup\$
    – Runium
    Commented Jan 27, 2014 at 22:56
5
votes
\$\begingroup\$

TI-Basic (16 bytes)

Note: TI-Basic is tokenized. If I remember correctly, ClrHome and Disp are one-byte tokens.

ClrHome
Disp "O O O"," O O
\$\endgroup\$
4
votes
\$\begingroup\$
#include<iostream.h>
#include<conio.h>
#define tc textcolor

void circle(int x,int y,int k)
{
  tc(k);
  int n;
  for(n=0;n<=6;n++)
  {

    if(n==0||n==6)
    {
      gotoxy(x+3,y+n);
      cprintf("* * *");
    }
    else if(n==1||n==5)
    {
      gotoxy(x+1,y+n);
      cprintf("*");
      gotoxy(x+9,y+n);
      cprintf("*");
    }
    else if(n>1&&n<5)
    {
      gotoxy(x,y+n);
      cprintf("*");
      gotoxy(x+10,y+n);
      cprintf("*");
    }
  }
}

void main()
{
  clrscr();
  circle(1,1,BLUE);
  circle(14,1,WHITE);
  circle(27,1,RED);
  circle(8,4,YELLOW);
  circle(21,4,GREEN);
  _setcursortype(0);
  getch();
}

Made in turbo c++ 3.0 compiler. Tried t make the code as short as possible

\$\endgroup\$
1
  • 7
    \$\begingroup\$ 1) Please use Markdown to mark code block and keep the posted code readable. 2) As this is a code-golf challenge, please try to reduce the size of your code to the strictly necessary. 3) Please add a heading line to your answer (emphasized with some markup up to your preference (usually header 1 or bold)), specifying the used language, the length of the code and the earned score. \$\endgroup\$
    – manatwork
    Commented Jan 21, 2014 at 18:41

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