Duck images

E

Eirikur Hallgrimsson

I am having the worst time getting these cute little things to work.
Pasting into irb is almost working for me. I think it's a problem
with line wrapping inside code which is pretty hard for me to read
to begin with. Is there some way to cast these into a canonical form
that will survive their trip through email and cut and paste?

Eirikur


# Franks original Version: 186 Bytes
s="\033[2J\033[0;0H _\n Quack! >(')____,\n (`
=~~/\nv^v^v^v^v^`---'v^v^v^v^";(1..(1/0.0)).each{|i|s[23,6]=(i%
2)==0?"Quack!":"
"*6;s.tr!('>v^^v<','<^vv^>');puts s;sleep 1}

# Shortened and enhanced: 178 Bytes
s="\e[2J\e[0;0H _\n Quack! >(*)____,\n (`
=~~/\nv^v^v^v^v^`---'v^v^v^v^";i=0;loop{s[23,6]=(i+=1)%2==0?'Quack!':'
'*6;s.tr!(t="*.>v^<,°",t.reverse);puts s;sleep 1}

# Packed (RLE): 205 Bytes
s="\e[2J\e[0;0H"+" 30_\n 21Quack! >(*)_4,\n 29(` =~2/\nw15`-3'w15\n
w33".gsub(/(.)(\d+)/){$1*$2.to_i}.gsub('w','v^');i=0;loop{s[63,6]=(i
+=1)%2==0?
'Quack!':' '*6;s.tr!(t="*.>v^<,°",t.reverse);puts s;sleep 1}
 
D

Dave Burt

Eirikur Hallgrimsson said:
I am having the worst time getting these cute little things to work.
Pasting into irb is almost working for me. I think it's a problem
with line wrapping inside code which is pretty hard for me to read
to begin with. Is there some way to cast these into a canonical form
that will survive their trip through email and cut and paste?

Eirikur

# Franks original Version: 186 Bytes
# Shortened and enhanced: 178 Bytes

The problem is indeed line-wrapping. All the duck sigs posted to date have
been one-liners. The lines probably broke on a single space. Check out the
attachment to Florian's original duck sig post, duck.rb - that should arrive
intact.

Now, I've done some golfing myself - 145 characters (delete the newlines):

i=1;loop{w=i&1==1?'v^':'^v';$><<"\e[2J\e[0;0H#{' '*10}_\n #{
i&1==1?' '*7+'<':'Quack! >'}(*)____,\n#{' '*9}(` =~~/\n#{w*5
}`---'#{w*4}";i+=sleep 1}

If that doesn't work:
http://www.dave.burt.id.au/ruby/duck_golf.rb

3 more characters, and it'll fit on 2 72-char lines. Who's teeing off next?

Cheers!
Dave
 
T

trans. (T. Onoma)

On Wednesday 08 December 2004 02:52 am, Dave Burt wrote:
| |
| >I am having the worst time getting these cute little things to work.
| > Pasting into irb is almost working for me. I think it's a problem
| > with line wrapping inside code which is pretty hard for me to read
| > to begin with. Is there some way to cast these into a canonical form
| > that will survive their trip through email and cut and paste?
| >
| > Eirikur
| >
| > # Franks original Version: 186 Bytes
| > # Shortened and enhanced: 178 Bytes
|
| The problem is indeed line-wrapping. All the duck sigs posted to date have
| been one-liners. The lines probably broke on a single space. Check out the
| attachment to Florian's original duck sig post, duck.rb - that should
| arrive intact.
|
| Now, I've done some golfing myself - 145 characters (delete the newlines):
|
| i=1;loop{w=i&1==1?'v^':'^v';$><<"\e[2J\e[0;0H#{' '*10}_\n #{
| i&1==1?' '*7+'<':'Quack! >'}(*)____,\n#{' '*9}(` =~~/\n#{w*5
| }`---'#{w*4}";i+=sleep 1}
|
| If that doesn't work:
| http://www.dave.burt.id.au/ruby/duck_golf.rb
|
| 3 more characters, and it'll fit on 2 72-char lines. Who's teeing off next?

142

i=1;loop{w='v^v'[i%2,2];$><<"\e[2J\e[0;0H#{' '*10}_\n #{i&1==1?'
'*7+'<':'Quack! >'}(*)____,\n#{' '*9}(`=~~/\n#{w*5}`---'#{w*4}\n";i+=sleep 1}

I had to add \n at the end to get the water to appear :(.

T.
 
B

Brian Schröder

I am having the worst time getting these cute little things to work.
Pasting into irb is almost working for me. I think it's a problem
with line wrapping inside code which is pretty hard for me to read
to begin with. Is there some way to cast these into a canonical form
that will survive their trip through email and cut and paste?

Eirikur

After some further golfing borrowing heavily from Dave and T. Onoma. I have on
your demand line broken versions that you should be able to cut and paste into
irb. For me it does work only in a standard xterm, uxterm is failing because it
does interpret the "°" wrongly. Exchange this against another symbol, e.g. " to
make it work.

regards,

Brian


# Franks Original Version: 186 Bytes
s="\033[2J\033[0;0H _\n Quack! >(')____,\n (`
=~~/\nv^v^v^v^v^`---'v^v^v^v^";(1..(1/0.0)).each{|i|s[23,6]=(i%2)==0?"Quack!":"
"*6;s.tr!('>v^^v<','<^vv^>');puts s;sleep 1}

# Packed (RLE) and enhanced: 203 Bytes
# Remove newlines
s="\e[2J\e[0;0H"+" 30_\n 21Quack! >(*)_4,\n 29(` =~2/\nw15`-3'w15\n
w33\n".gsub(/(.)(\d+)/){$1*$2.to_i}.gsub('w','v^');i=0;loop{s[63,6]=i&1>0?'Qua
ck!':' '*6;s.tr!(t='*.>v^<,°',t.reverse);$><<s;i+=sleep 1}

# Line-Broken Packed (RLE) and enhanced: 203 Bytes
s="\e[2J\e[0;0H"+" 30_\n 21Quack! >(*)_4,\n 29(` =~2/\nw15`-3'w15\n w33
".gsub(/(.)(\d+)/){$1*$2.to_i}.gsub('w','v^');i=0;loop{s[63,6]=i&1>0?
'Quack!':' '*6;s.tr!(t='*.>v^<,°',t.reverse);$><<s;i+=sleep 1}

# Shortened and enhanced: 172 Bytes
# Remove newlines
s="\e[2J\e[0;0H _\nQuack! >(*)____,\n (`
=~~/\n^v^v^v^v^`---'v^v^v^v^\n";i=0;loop{s[21,6]=i&1>0?'Quack!':'
'*6;s.tr!(t='*.>v^<,°',t.reverse);$><<s;i+=sleep 1}

# Line-Broken shortened and enhanced (Attention meaningfull newlines):
# 170 Charakters including Newlines
s="\e[2J\e[0;0H _\nQuack! >(*)____,\n (` =~~/
^v^v^v^v^`---'v^v^v^v^\n";i=0;loop{s[21,6]=i&1>0?'Quack!':' '*6;s.tr!(t=
'*.>v^<,°',t.reverse);$><<s;i+=sleep 1}

# Line-Broken shortened and enhanced (Attention meaningfull newlines):
# 170 Charakters including Newlines
# Works also in a uxterm
s="\e[2J\e[0;0H _\nQuack! >(*)____,\n (` =~~/
^v^v^v^v^`---'v^v^v^v^\n";i=0;loop{s[21,6]=i&1>0?'Quack!':' '*6;s.tr!(t=
'*.>v^<,"',t.reverse);$><<s;i+=sleep 1}
 
W

why the lucky stiff

Brian said:
# Franks Original Version: 186 Bytes
...
# Packed (RLE) and enhanced: 203 Bytes
# Remove newlines
...
# Line-Broken Packed (RLE) and enhanced: 203 Bytes
...
# Shortened and enhanced: 172 Bytes
# Remove newlines
...
# Line-Broken shortened and enhanced (Attention meaningfull newlines):
# 170 Charakters including Newlines
...
# Line-Broken shortened and enhanced (Attention meaningfull newlines):
# 170 Charakters including Newlines
# Works also in a uxterm
...
Great work everyone. Now, on to phase two. Here's my vision.

We need to break the buck up into 3-dimensional cross sections. Then,
each of us will generate ASCII images of the duck at that point. Then,
we'll have our wizards here compress the cross-sections into code and
animate them. In the end, we should have an ASCII equivalent of
Quicktime VR.

This would go a long way toward helping people accept Ruby. And making
the world a better place. And having more duck images.

I think we have our first CodeFest.

_why
 
M

Michael DeHaan

In the end, we should have an ASCII equivalent of
Quicktime VR.

Have you ever seen "bb", which is an aalib demo? If not, you need to.

"apt-get install bb" on debian.

a Pure-Ruby aalib-type library would be interesting as heck!
 
T

trans. (T. Onoma)

On Wednesday 08 December 2004 07:06 am, Brian Schröder wrote:
| After some further golfing borrowing heavily from Dave and T. Onoma. I have
| on your demand line broken versions that you should be able to cut and
| paste into irb. For me it does work only in a standard xterm, uxterm is
| failing because it does interpret the "°" wrongly. Exchange this against
| another symbol, e.g. " to make it work.
|
| regards,
|
| Brian
|
| # Franks Original Version: 186 Bytes
| s="\033[2J\033[0;0H _\n Quack! >(')____,\n (`
| =~~/\nv^v^v^v^v^`---'v^v^v^v^";(1..(1/0.0)).each{|i|s[23,6]=(i%2)==0?"Quack
|!":" "*6;s.tr!('>v^^v<','<^vv^>');puts s;sleep 1}
|
| # Packed (RLE) and enhanced: 203 Bytes
| # Remove newlines
| s="\e[2J\e[0;0H"+" 30_\n 21Quack! >(*)_4,\n 29(` =~2/\nw15`-3'w15\n
| w33\n".gsub(/(.)(\d+)/){$1*$2.to_i}.gsub('w','v^');i=0;loop{s[63,6]=i&1>0?'
|Qua ck!':' '*6;s.tr!(t='*.>v^<,°',t.reverse);$><<s;i+=sleep 1}
|
| # Line-Broken Packed (RLE) and enhanced: 203 Bytes
| s="\e[2J\e[0;0H"+" 30_\n 21Quack! >(*)_4,\n 29(` =~2/\nw15`-3'w15\n w33
| ".gsub(/(.)(\d+)/){$1*$2.to_i}.gsub('w','v^');i=0;loop{s[63,6]=i&1>0?
| 'Quack!':' '*6;s.tr!(t='*.>v^<,°',t.reverse);$><<s;i+=sleep 1}
|
| # Shortened and enhanced: 172 Bytes
| # Remove newlines
| s="\e[2J\e[0;0H _\nQuack! >(*)____,\n (`
| =~~/\n^v^v^v^v^`---'v^v^v^v^\n";i=0;loop{s[21,6]=i&1>0?'Quack!':'
| '*6;s.tr!(t='*.>v^<,°',t.reverse);$><<s;i+=sleep 1}
|
| # Line-Broken shortened and enhanced (Attention meaningfull newlines):
| # 170 Charakters including Newlines
| s="\e[2J\e[0;0H _\nQuack! >(*)____,\n (` =~~/
| ^v^v^v^v^`---'v^v^v^v^\n";i=0;loop{s[21,6]=i&1>0?'Quack!':' '*6;s.tr!(t=
| '*.>v^<,°',t.reverse);$><<s;i+=sleep 1}
|
| # Line-Broken shortened and enhanced (Attention meaningfull newlines):
| # 170 Charakters including Newlines
| # Works also in a uxterm
| s="\e[2J\e[0;0H _\nQuack! >(*)____,\n (` =~~/
| ^v^v^v^v^`---'v^v^v^v^\n";i=0;loop{s[21,6]=i&1>0?'Quack!':' '*6;s.tr!(t=
| '*.>v^<,"',t.reverse);$><<s;i+=sleep 1}

144

q,w='Quack! >','~^'*11;t="\e[2J\e[0;0H _\n%8s(')____,\n (`
=^^/\n%20s \n";i=0;loop{s=t%[i&1>0?q:'<',w[i%2,20]];$><<s;i+=sleep 1}

I left out the eye and tail changing (the eye would be about +3, not sure
about the tail), they seemed a bit much IMHO. BTW: What happend to the
feather flapping? Well, I thought that also looked a bit odd so I didn't put
it back in either. Shorter is sweeter.

T.
 
D

Dave Burt

trans. (T. Onoma) said:
144

q,w='Quack! >','~^'*11;t="\e[2J\e[0;0H _\n%8s(')____,\n (`
=^^/\n%20s \n";i=0;loop{s=t%[i&1>0?q:'<',w[i%2,20]];$><<s;i+=sleep 1}

122
i=1;loop{puts"\e[2J\e[0;0H#{' '*10}_\n %8s(*)____,\n#{' '*9
}(` =~~/\n#{'~^~'[i%2,2]*9}"%(i&1>0?'<':'Quack! >');i+=sleep 1}
 
T

trans. (T. Onoma)

On Wednesday 08 December 2004 08:57 pm, Dave Burt wrote:
| > 144
| >
| > q,w='Quack! >','~^'*11;t="\e[2J\e[0;0H _\n%8s(')____,\n (`
| > =^^/\n%20s \n";i=0;loop{s=t%[i&1>0?q:'<',w[i%2,20]];$><<s;i+=sleep 1}
|
| 122
| i=1;loop{puts"\e[2J\e[0;0H#{' '*10}_\n %8s(*)____,\n#{' '*9
| }(` =~~/\n#{'~^~'[i%2,2]*9}"%(i&1>0?'<':'Quack! >');i+=sleep 1}

Holy smokes! This has to be the tap out. Look how dense that thing is! Nice
job, Dave!

Now if we could only get the little ducky to swim back and forth. ;)

T.
 
B

Bill Kelly

From: "trans. (T. Onoma) said:
On Wednesday 08 December 2004 08:57 pm, Dave Burt wrote:
|
| 122
| i=1;loop{puts"\e[2J\e[0;0H#{' '*10}_\n %8s(*)____,\n#{' '*9
| }(` =~~/\n#{'~^~'[i%2,2]*9}"%(i&1>0?'<':'Quack! >');i+=sleep 1}

Holy smokes! This has to be the tap out. Look how dense that thing is! Nice
job, Dave!

A minor tweak to the ANSI/VT100 codes... the 0;0 is surpufluous...

119
i=1;loop{puts"\e[2J\e[H#{' '*10}_\n %8s(*)____,\n#{' '*9
}(` =~~/\n#{'~^~'[i%2,2]*9}"%(i&1>0?'<':'Quack! >');i+=sleep 1}



Regards,

Bill
 
W

why the lucky stiff

Dave said:
144

q,w='Quack! >','~^'*11;t="\e[2J\e[0;0H _\n%8s(')____,\n (`
=^^/\n%20s \n";i=0;loop{s=t%[i&1>0?q:'<',w[i%2,20]];$><<s;i+=sleep 1}

122
i=1;loop{puts"\e[2J\e[0;0H#{' '*10}_\n %8s(*)____,\n#{' '*9
}(` =~~/\n#{'~^~'[i%2,2]*9}"%(i&1>0?'<':'Quack! >');i+=sleep 1}
Yes. The water is looking a lot more realistic. And less choppy.
Guys, we want the duck to have a smooth ride here. The implications of
having choppy water in this animation would certainly reflect poorly on
Ruby and its many echelons.

_why
 
P

pat eyler

i=1;loop{puts"\e[2J\e[H%11s\n %8s(*)____,\n%10s`
=~~/\n#{'~^~'[i%2,2]*9}"%['_',i&1>0?'<':'Quack! >','('];i+=sleep 1}

which wc says is 116 characters

-pate

From: "trans. (T. Onoma) said:
On Wednesday 08 December 2004 08:57 pm, Dave Burt wrote:
|
| 122
| i=1;loop{puts"\e[2J\e[0;0H#{' '*10}_\n %8s(*)____,\n#{' '*9
| }(` =~~/\n#{'~^~'[i%2,2]*9}"%(i&1>0?'<':'Quack! >');i+=sleep 1}

Holy smokes! This has to be the tap out. Look how dense that thing is! Nice
job, Dave!

A minor tweak to the ANSI/VT100 codes... the 0;0 is surpufluous...

119
i=1;loop{puts"\e[2J\e[H#{' '*10}_\n %8s(*)____,\n#{' '*9
}(` =~~/\n#{'~^~'[i%2,2]*9}"%(i&1>0?'<':'Quack! >');i+=sleep 1}


Regards,

Bill
 
G

Gavin Sinclair

i=1;loop{puts"\e[2J\e[H%11s\n %8s(*)____,\n%10s`
=~~/\n#{'~^~'[i%2,2]*9}"%['_',i&1>0?'<':'Quack! >','('];i+=sleep 1}
which wc says is 116 characters

The picture is bung:

_
<(*)____,
(`
=~~/
^~^~^~^~^~^~^~^~^~


And I'm getting screen flicker. How about some double buffering? :>

Gavin
 
B

Brian Schröder

i=1;loop{puts"\e[2J\e[H%11s\n %8s(*)____,\n%10s`
=~~/\n#{'~^~'[i%2,2]*9}"%['_',i&1>0?'<':'Quack! >','('];i+=sleep 1}
which wc says is 116 characters

The picture is bung:

_
<(*)____,
(`
=~~/
^~^~^~^~^~^~^~^~^~


And I'm getting screen flicker. How about some double buffering? :>

Gavin

I think that if you put everything onto one line, the picture should be ok.

Regards,

Brian
 
J

Jannis Harder

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I think the escape code "\e[;11H" is valid(works with xterm and
Terminal.app(mac os x panther)) but I'm not sure.
Replace it with "\e[0;11H" if it doesn't work.

108 byte (with newline)

i=1;loop{puts"\e[2J\e[;11H_\n%9s(*)____,\n%9s(` =~~/
#{'~^~'[i%=2,2]*9}"%[i>0?'<':'Quack! >',''];i+=sleep 1}

109 byte (without newline)

i=1;loop{puts"\e[2J\e[;11H_\n%9s(*)____,\n%9s(`
=~~/\n#{'~^~'[i%=2,2]*9}"%[i>0?'<':'Quack! >',''];i+=sleep 1}




my new sig : (200byte)
"jp6iSZmkLp5ISZlEiW5C".unpack("m")[0].unpack("C*").map{|x|x.chr}.join.
unpack("B*")[0].scan(/.{24}/){i=7;$&.scan(/..../){print\
"\e[3#{i-=1};1;40m ";$&.each_byte{|z|print" #"[z-?0,1]*2}};puts"\e[0m"}
(200 byte)


Jannis Harder

"jp6iSZmkLp5ISZlEiW5C".unpack("m")[0].unpack("C*").map{|x|x.chr}.join.
unpack("B*")[0].scan(/.{24}/){i=7;$&.scan(/..../){print\
"\e[3#{i-=1};1;40m ";$&.each_byte{|z|print" #"[z-?0,1]*2}};puts"\e[0m"}
(200 byte)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (Darwin)

iD8DBQFBucmi5YRWfc27RzQRAujoAKDoBGlLtJwrqYfnkx4yiRDKziDyygCg2VoZ
77qbjdCxIbIWEJWBt/G9CfI=
=xd6s
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,164
Messages
2,570,901
Members
47,439
Latest member
elif2sghost

Latest Threads

Top