Duck images

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}

Think of it. In time, we could amass ducks to use them as currency on
the global markets. I think we can take Switzerland.

Don't be silly! Who would want to use ducks to take Switzerland ...
we should obviously be targeting Freedonia.

-pate

···

On Tue, 7 Dec 2004 06:10:17 +0900, why the lucky stiff <ruby-talk@whytheluckystiff.net> wrote:

_why

"Eirikur Hallgrimsson" <eh@mad.scientist.com> wrote in message
news:1102475987.9285.5.camel@sal...

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

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}

···

On Wed, 8 Dec 2004 12:22:22 +0900 Eirikur Hallgrimsson <eh@mad.scientist.com> 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

--
Brian Schröder
http://www.brian-schroeder.de/

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.

···

On Wednesday 08 December 2004 02:52 am, Dave Burt wrote:

"Eirikur Hallgrimsson" <eh@mad.scientist.com> wrote in message
news:1102475987.9285.5.camel@sal...

>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?

Brian Schröder wrote:

# 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

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.

···

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}

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!

···

On Thu, 9 Dec 2004 02:10:30 +0900, why the lucky stiff <ruby-talk@whytheluckystiff.net> wrote:

Brian Schröder wrote:

># 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

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}

···

"trans. (T. Onoma)" <transami@runbox.com> 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}

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. :wink:

T.

···

On Wednesday 08 December 2004 08:57 pm, Dave Burt wrote:

"trans. (T. Onoma)" <transami@runbox.com> 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}

Dave Burt wrote:

···

"trans. (T. Onoma)" <transami@runbox.com> 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}

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

>
> 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

···

From: "trans. (T. Onoma)" <transami@runbox.com>

On Wednesday 08 December 2004 08:57 pm, Dave Burt wrote:

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

···

On Thu, 9 Dec 2004 16:35:39 +0900, Bill Kelly <billk@cts.com> wrote:

From: "trans. (T. Onoma)" <transami@runbox.com>
> 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

The picture is bung:

···

On Friday, December 10, 2004, 9:25:19 AM, pat wrote:

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

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

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

···

On Fri, 10 Dec 2004 07:41:13 +0900 Gavin Sinclair <gsinclair@soyabean.com.au> wrote:

On Friday, December 10, 2004, 9:25:19 AM, pat wrote:

> 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

--
Brian Schröder
http://www.brian-schroeder.de/