[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Since today is October 31...

Hal E. Fulton

10/31/2003 7:18:00 PM

srand 0
puts "pH p!aoHalnyweel".split("").sort {|x,y| rand <=> rand }.join


Cheers,
Hal(loween)9000



19 Answers

James Britt

10/31/2003 7:57:00 PM

0

Hal Fulton wrote:

> srand 0
> puts "pH p!aoHalnyweel".split("").sort {|x,y| rand <=> rand }.join
>

Neat.

When I saw the subject line, I thought you were going to say something
scary, like Matz had decided to drop Ruby and devote his time to Java 1.6.


James

>
> Cheers,
> Hal(loween)9000
>
>
>
>




Wejn

10/31/2003 8:55:00 PM

0

Hello,

> srand 0
> puts "pH p!aoHalnyweel".split("").sort {|x,y| rand <=> rand }.join

hmm, it doesn't work for me :-(

irb(main):001:0> srand 0
0
irb(main):002:0> puts "pH p!aoHalnyweel".split("").sort {|x,y| rand <=> rand }.join
HHypao!new llpea
nil
irb(main):003:0> VERSION
"1.6.7"

M.

PS: It's strange to have Halloween one day after Christmas. :-)
(Clue: 24 dec == 30 oct)
--
Wejn <lists+rubytalk(at)box.cz>
(svamberk.net's Linux section, fi.muni.cz student, linuxfan)
>>> Bored? Want hours of entertainment? <<<
>>> Just set the initdefault to 6! <<<

Hal E. Fulton

10/31/2003 9:15:00 PM

0

Wejn wrote:
> Hello,
>
>
>>srand 0
>>puts "pH p!aoHalnyweel".split("").sort {|x,y| rand <=> rand }.join
>
>
> hmm, it doesn't work for me :-(
>
> irb(main):001:0> srand 0
> 0
> irb(main):002:0> puts "pH p!aoHalnyweel".split("").sort {|x,y| rand <=> rand }.join
> HHypao!new llpea
> nil
> irb(main):003:0> VERSION
> "1.6.7"

No, that's because the PRNG changed with 1.7.x

If you are using 1.6.7, you are missing a few nice features. :)

> PS: It's strange to have Halloween one day after Christmas. :-)
> (Clue: 24 dec == 30 oct)

Yes, I first heard that Halloween was Christmas from Richard
Hamming (of Hamming Code fame). Not directly of course. He wrote
the coding theory textbook I used in college.

Hal


Mark J. Reed

10/31/2003 9:24:00 PM

0

On Sat, Nov 01, 2003 at 05:55:28AM +0900, Wejn wrote:
> hmm, it doesn't work for me :-(

You should upgrade to 1.8. But meanwhile, just for you:

irb(main):001:0> VERSION
"1.6.7"
irb(main):002:0> srand 0
0
irb(main):003:0> puts "paoeH! Hywapllne".split("").sort{rand<=>rand}.join

-Mark

Wejn

10/31/2003 9:41:00 PM

0

Hello,

> If you are using 1.6.7, you are missing a few nice features. :)

yeah, I know ... :-/ But I'm just too lazy to reinstall Ruby on all
the boxes I happen to use. :-)

> Yes, I first heard that Halloween was Christmas from Richard
> Hamming (of Hamming Code fame). Not directly of course. He wrote
> the coding theory textbook I used in college.

Wow ... Hamming code reminds me my Crypto&Coding course I had 2 semesters
ago - quite impressive material (and I must admit it was hard time for me
- trying to learn/understand all the things). Please, is that textbook
available somewhere on the Net?

Sincerely,
M.
--
Wejn <lists+rubytalk(at)box.cz>
(svamberk.net's Linux section, fi.muni.cz student, linuxfan)
>>> Bored? Want hours of entertainment? <<<
>>> Just set the initdefault to 6! <<<

Hal E. Fulton

10/31/2003 9:44:00 PM

0

Wejn wrote:
> Wow ... Hamming code reminds me my Crypto&Coding course I had 2 semesters
> ago - quite impressive material (and I must admit it was hard time for me
> - trying to learn/understand all the things). Please, is that textbook
> available somewhere on the Net?

Hmm, not that I know of.

I still have it on my shelf, though. :) _Coding and Information
Theory_, Richard Hamming.

Great book, interesting topic, and yes, sometimes it's hard to
understand.

Hal



why the lucky stiff

10/31/2003 10:03:00 PM

0

On Friday 31 October 2003 12:17 pm, Hal Fulton wrote:
> srand 0
> puts "pH p!aoHalnyweel".split("").sort {|x,y| rand <=> rand }.join

:) nothing scarier than Enumerable#inject though...

(0..67).inject(3709168338536711372250064398972826945394701253532720163819002017081215416156693026){|i,x|print
"o! _,\\`\n/^.>b<"[i%16,1];i>>4}

_why

Daniel Carrera

10/31/2003 10:06:00 PM

0

On Sat, Nov 01, 2003 at 07:02:57AM +0900, why the lucky stiff wrote:
>
> :) nothing scarier than Enumerable#inject though...
>
> (0..67).inject(3709168338536711372250064398972826945394701253532720163819002017081215416156693026){|i,x|print
> "o! _,\\`\n/^.>b<"[i%16,1];i>>4}
>

Now THAT was cool!


--
Daniel Carrera | OpenPGP KeyID: 9AF77A88
PhD grad student. |
Mathematics Dept. | "To understand recursion, you must first
UMD, College Park | understand recursion".

Hal E. Fulton

10/31/2003 10:10:00 PM

0

Daniel Carrera wrote:
> On Sat, Nov 01, 2003 at 07:02:57AM +0900, why the lucky stiff wrote:
>
>>:) nothing scarier than Enumerable#inject though...
>>
>>(0..67).inject(3709168338536711372250064398972826945394701253532720163819002017081215416156693026){|i,x|print
>>"o! _,\\`\n/^.>b<"[i%16,1];i>>4}
>>
>
>
> Now THAT was cool!
>

I'm sure it is... but it doesn't work for me. (self.wtf?)

I pasted quite carefully, too.

This is ruby 1.8.0 (2003-08-04) [i686-linux-gnu]
All I get is a bunch of nils...

Hmmmm.

Hal



Mark J. Reed

10/31/2003 10:13:00 PM

0

It looks like pre-1.7, Ruby's PRNG was the same as Perl 5.8's. But
apparently their sorting algorithms differ, since the requisite
string for the equivalent Perl code is yet a third: "yHHplelaew!an po".

Python seems to take a 0 argument to rand.srand to mean "randomize
for real, yo!"; but with rand.srand(1), "l Hpw!aHeeoanlpy" yields the
desired result.

ANYway.

-Mark