Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

How could we generate shapes or images using binary?

I got to messing around trying to create something that looked matrix like and got to thinking, wouldn't a great CodeGolf be to see who can make the best shortest code to generate a binary image?

Please advise me of any rules I should add.

Rules:

  • Create a binary image art of a Meme using 40 chars wide by 20 chars tall.
  • Shortest code out of top 3 voted images wins.

Example Output:

00000000000000000000000000000000000000000
00000000000000000000000000000000000000000
00000000000000000000000000000000000000000
00000000000000000000000000000000000000000
00000000000000000000000000000000000000000
00000000000000000000000000000000000000000
00000000000000000000000000000000000000000
00000000000000000000000000000000000000000
00000000001111000000000000011110000000000
00000000111111110000000001111111100000000
00000011110000111100001111000001111000000
00000011110000111100001111000001111000000
00000011110000111100001111000001111000000
00000011110000001111111100000001111000000
00000011110000000011110000000001111000000
00000011110000000000000000000001111000000
00000011110000000000000000000001111000000
00001111000000000000000000000000011110000
00111100000000000000000000000000000111100
11110000000000000000000000000000000001111
share|improve this question
    
Any specifics? Otherwise, I could post an answer like '\n'.join(['0'*20]*40]) in Python and be done. –  beary605 Jun 14 '12 at 5:21
2  
As per the FAQ, a challenge should have an objective winning criterion. "Most upvotes" isn't really on the right side of the line, in the sense that when you're writing the program you can't measure it. However, I can't see an easy fix short of specifying an image and turning this into another [:kolmogorov-complexity] question. –  Peter Taylor Jun 14 '12 at 7:36
    
@PeterTaylor I made the image more specific, shortest code with most upvoted image that matches a meme wins. If you think it should be even more specific than that I'm willing to take suggestions. –  Event_Horizon Jun 14 '12 at 13:10
1  
What is a meme? –  agent-j Jun 16 '12 at 18:52
    
@agent-j knowyourmeme.com etc –  Event_Horizon Jun 18 '12 at 13:14
add comment

6 Answers

YO DAWG, I HERD YOU LIKE ... (Python - 151)

a,b,c,d,e=9663681096,78383190025,559419527177,9663713289,628289966664
print'%040o\n'*20%tuple(map(lambda x:(x|x<<48|x<<96)>>21,[0,a,b,c]+[d]*5+[e])*2)

Output:

0000000000000000000000000000000000000000
0001100000111100000110000011110000011000
0011100001100110001110000110011000111000
0101100001100110010110000110011001011000
0001100001100110000110000110011000011000
0001100001100110000110000110011000011000
0001100001100110000110000110011000011000
0001100001100110000110000110011000011000
0001100001100110000110000110011000011000
0111111000111100011111100011110001111110
0000000000000000000000000000000000000000
0001100000111100000110000011110000011000
0011100001100110001110000110011000111000
0101100001100110010110000110011001011000
0001100001100110000110000110011000011000
0001100001100110000110000110011000011000
0001100001100110000110000110011000011000
0001100001100110000110000110011000011000
0001100001100110000110000110011000011000
0111111000111100011111100011110001111110
share|improve this answer
add comment

QBASIC - 1157 Characters

Ok, this one isn't that short, but definitely qualifies for the meme factor.

CLS
l$="1"
FOR i=1 TO 20
s$=""
FOR j=1 TO 40
s$=s$+"0"
NEXT
?s$
NEXT
A=20
C=16
D=12
E=27
FOR i=2 TO 6
        b=ABS(4-i)
        LOCATE i,8-i:?1$
        LOCATE i,4+i:?1$
        LOCATE 4,b+5:?1$
        LOCATE i,22:?1$
        LOCATE i,13:?1$
        LOCATE 6,11+i:?1$
        LOCATE 6,A+i:?1$
        LOCATE 10-b,3+i:?1$
        LOCATE D-b,7:?1$
        LOCATE 6+i,13:?1$
        LOCATE 8,11+i:?1$
        LOCATE 6+i,17:?1$
        LOCATE D,11+i:?1$
        LOCATE 6+i,22:?1$
        LOCATE 6+i,26:?1$
        LOCATE D,A+i:?1$
        LOCATE 6+i,29:?1$
        LOCATE 8,E+i:?1$
        LOCATE 10,E+i:?1$
        LOCATE 9,34:?1$
        LOCATE 6+i,E+i:?1$
        LOCATE D+i,5:?1$
        LOCATE 14,b+6:?1$
        LOCATE C,b+6:?1$
        LOCATE 18,b+6:?1$
        LOCATE 15+b,9:?1$
        LOCATE D+i,17-i:?1$
        LOCATE D+i,13+i:?1$
        LOCATE C,b+14:?1$
        LOCATE 14,A+i:?1$
        LOCATE C,A+i:?1$
        LOCATE 18,A+i:?1$
        LOCATE C-b,22:?1$
        LOCATE C+b,26:?1$
        LOCATE 14,E+i:?1$
        LOCATE C,30+b:?1$
        LOCATE 18,E+i:?1$
        LOCATE D+i,29:?1$
NEXT

Here's a screen shot for the odd person who doesn't have QBasic installed.

enter image description here

share|improve this answer
    
+1 memories.... –  luser droog Oct 29 '12 at 17:39
add comment

The Weight Lifter or The Keyboard Player or ... (188 characters)

Not really too sure if this fits the meme requirement, but it is not too long I hope...

from math import*;r=range;q=r(20)
s=[["1"for x in q*2]for x in q];s[14][2:38]=["0"]*36
for j in r(18,21):
 for i in q:v=int(j+7*sin(i/7.0*pi));s[i][v]=s[i][40-v]="0"
for l in s:print''.join(l)

Output:

The weight lifter

share|improve this answer
add comment

New*** Can't Triforce (Perl, 85 chars)

map{$j=$_<10;$_=sprintf"%010d",1x($_%10+1);s/1(.*)/$&$1$`0/;say$_.($j?0 x20:$_)}0..19

output:

0000000001000000000000000000000000000000
0000000011100000000000000000000000000000
0000000111110000000000000000000000000000
0000001111111000000000000000000000000000
0000011111111100000000000000000000000000
0000111111111110000000000000000000000000
0001111111111111000000000000000000000000
0011111111111111100000000000000000000000
0111111111111111110000000000000000000000
1111111111111111111000000000000000000000
0000000001000000000000000000010000000000
0000000011100000000000000000111000000000
0000000111110000000000000001111100000000
0000001111111000000000000011111110000000
0000011111111100000000000111111111000000
0000111111111110000000001111111111100000
0001111111111111000000011111111111110000
0011111111111111100000111111111111111000
0111111111111111110001111111111111111100
1111111111111111111011111111111111111110
share|improve this answer
add comment

The Mandelbrot set written in 194 characters of coffeescript on node.js:

ascii_mandel.png

m=(x,y)->
 a=x
 b=y
 z=0
 for i in [0..9]
  return 0 if z > 4
  l=y*y
  z=x*x+l
  y=2*x*y+b
  x=x*x-l+a
 1
console.log (m x,y for x in [-1.5..0.5] by 2/39).join '' for y in [-1.3..1.3] by 2.6/19
share|improve this answer
add comment

I could make no sense out of that knowyourmeme site. So here's a riff on your first reference: something matrix like.

Postscript (287) (310)

Edit: Better output (more 'ones', less apparent waves).

Run with gs -dNODISPLAY -q -- matrix.ps 60. Replace 60 with the number of columns to generate.

%!
<<
0{(1)print}
1{(0)print}
10{()=}
/#{load exec}
/rho ARGUMENTS 0 get cvi
/enn 0
/set{[rho{rand rand 30 mod 2 idiv 3 mul neg bitshift}repeat]}
/lin{[exch{dup 2 idiv exch 2 mod #}forall]10 #}
/zer{/enn enn 1 add def enn 6 mod 0 eq{dup 0 exch{add}forall rho 1.1 exp lt{pop set}if}if}
>>begin
set{lin zer}loop

It generates infinite output like this, mostly ones with vertical zero "signals":

011001110110110001100101111110011111001101101111110111011101
010011111101100011110110110111010101001101111111111110011101
111111110111110001111100010110110011011101111111110110011101
110110111111110011111011110110111110111111101111110111111101
010101111111110101101100011100100110001101101111111110011101
110101111111101101101010011110101111001101111111110111111111
011111111111101001100111011100000011111101101111110111011011
010111111111111101101100111110100001101111111111111110011101
010100111111101001111011011111011001111111111111111110111001
011111111111101011110100011101001101101111111111110110111111
111100111111111101111100011111110001101111101111111111011011
111100111111101011110001011101111101101111111111111111111101
111101111111111001111001011111010101111101101111111110111111
011110111111111001100101011111011101111111101111111111111101
011101111111111101110001111111011101111111111111111111011101
111101111111111111110111111111111111111111111111110110011111
011101111111101011100111011111110101111111101111111111111111
011100111111111101111011111111111111111101101111110111011101
011111111111101111110111111111010111111111111111111111111111
011100111111111011110101111111111101111111111111111111011111
011101111111111111110101111111110111111111111111111111011111
111111111111111101111111111111111111111111111111111111011111
111111111111101101111101111111111111111111111111111111011111
111111111111101111111111111111111111111111111111111111011111
111111111111101111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111011111
010011010111011111001101111111011001011011011011111010111111
110011011111001111001111011100111011111011110011111101100110
110101111111111011111011111000110101110011011010111111110110
010111111111001111111001111000110001111111011111111110101110
010001111111111111110001011100110001100011110111101010111101
011011111011001011111001011100111111110111110110111011100110
011001011111101111110111011100110111100111111110111111111100
011101111011101111110001111110111111111111110111111010111111
011101111011101011111101111110110011011111010111101110101111
111101111011111011110001011101110001111011011111111000111100
111101011111011111111011111110111001101111111111111101111111
111101111111001111111111111110110011000011111111111100100111
11010101111110^C
Command terminated
share|improve this answer
add comment

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.