Re: Semcarlbd letrtes sepur! (Scrambled letters super!)

2003-09-19 Thread Etienne Grossmann

  Hi all,


On Thu, Sep 18, 2003 at 05:54:15PM +0200, Xavier Noria wrote:
[snip]
# 
# My current favourite is
# 
# -p s!\B\w+\B!join,sort{rand 2}$=~/./g!ge
# 
[snip]

  This is very nice (I didn't know about \B either); how randomly does
that scramble? I'm sure there's a thread somewhere on that.

  Cheers,

  Etienne

-- 
Etienne Grossmann -- http://www.isr.ist.utl.pt/~etienne


Re: Semcarlbd letrtes sepur! (Scrambled letters super!)

2003-09-19 Thread Xavier Noria
On Thursday 18 September 2003 17:27, Xavier Noria wrote:

 My current favourite is

 -p s!\B\w+\B!join,sort{rand 2}$=~/./g!ge

 but I am sure any serious golfer can shorten that substantially.

I am sorry for the duplicate, this was sent yesterday from an address 
which is not subscribed to the list.

-- fxn



RE: Semcarlbd letrtes sepur! (Scrambled letters super!)

2003-09-19 Thread Allen, Greg
In which case I can beat:

-pX s#\B\w+\B#join,map chop,sort map{rand.$_}$=~/./g#eg

With:

-p s#\B\w+\B#join,values%{{map{rand,$_}$=~/./g}}#eg

Greg

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 19, 2003 2:11 PM
To: [EMAIL PROTECTED]
Subject: Re: Semcarlbd letrtes sepur! (Scrambled letters super!)


In article [EMAIL PROTECTED],
Etienne Grossmann [EMAIL PROTECTED] writes:
   Hi all,
 
 On Thu, Sep 18, 2003 at 05:54:15PM +0200, Xavier Noria wrote: [snip]
 # 
 # My current favourite is
 # 
 # -p s!\B\w+\B!join,sort{rand 2}$=~/./g!ge
 # 
 [snip]
 
   This is very nice (I didn't know about \B either); how randomly does 
 that scramble? I'm sure there's a thread somewhere on that.
 
Not very. The sort{rand 2} trick has been rejected in golfs before.

--
This message is intended only for the personal and confidential use of the
designated recipient(s) named above.  If you are not the intended recipient of
this message you are hereby notified that any review, dissemination,
distribution or copying of this message is strictly prohibited.  This
communication is for information purposes only and should not be regarded as
an offer to sell or as a solicitation of an offer to buy any financial
product, an official confirmation of any transaction, or as an official
statement of Lehman Brothers.  Email transmission cannot be guaranteed to be
secure or error-free.  Therefore, we do not represent that this information is
complete or accurate and it should not be relied upon as such.  All
information is subject to change without notice.



Re: Semcarlbd letrtes sepur! (Scrambled letters super!)

2003-09-19 Thread Randal L. Schwartz
 Ton == Ton Hospel [EMAIL PROTECTED] writes:

 This is very nice (I didn't know about \B either); how randomly does
 that scramble? I'm sure there's a thread somewhere on that.
 
Ton Not very. The sort{rand 2} trick has been rejected in golfs before.

I don't know about current perl versions, but in older perl versions,
that'd lose elements, double up on elements, or even coredump.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


Semcarlbd letrtes sepur! (Scrambled letters super!)

2003-09-18 Thread Etienne Grossmann

  Hi all,

did you know taht it is psbloise to raed text eevn if the lteters
-ecpxet for the fsirt and lsat- of ecah wrdos are seclarbmd?  I hared
a sutdy has been dnoe on taht scjebut in an Eigslnh urtiivesny, but I
coannt get hold of it. Any ionirmtfoan on that sceujbt is welomce.

  Has the sbuejct adelary been aeressddd on this lsit?

  In the menatmie, I cmae up wtih tihs one-liner taht smelracbs the
lrttees apilraptpoery. How srhot can such a sicrpt get?

prel -pe 'sub r{join,map cohp,sort 
map{rand().$_}sfhit=~/(.)/g};s/\b(\w)(\w*)(\w)\b/$1.r($2).$3/eg'

  Crehes,

  Enneite

PS : Ok, ok, the ublmaecsrnd sprict is :

perl -pe 'sub r{join,map chop,sort 
map{rand().$_}shift=~/(.)/g};s/\b(\w)(\w*)(\w)\b/$1.r($2).$3/eg'


-- 
Etienne Grossmann -- http://www.isr.ist.utl.pt/~etienne


Re: Semcarlbd letrtes sepur! (Scrambled letters super!)

2003-09-18 Thread A. Pagaltzis
* Etienne Grossmann [EMAIL PROTECTED] [2003-09-18 09:29]:
 I hared a sutdy has been dnoe on taht scjebut in an Eigslnh
 urtiivesny, but I coannt get hold of it. Any ionirmtfoan on
 that sceujbt is welomce.

http://www.bisso.com/ujg_archives/000224.html

 perl -pe 'sub r{join,map chop,sort 
 map{rand().$_}shift=~/(.)/g};s/\b(\w)(\w*)(\w)\b/$1.r($2).$3/eg'

perl -pe's/(?=[a-z])([a-z]+)(?=[a-z])/join,map chop, sort map 
rand().$_,$1=~m[.]g/ige'
perl -MList::Util=shuffle 
-pe's/(?=[a-z])([a-z]+)(?=[a-z])/join,shuffle$1=~m[.]g/ige'

-- 
Regards,
Aristotle
 
If you can't laugh at yourself, you don't take life seriously enough.


Re: Semcarlbd letrtes sepur! (Scrambled letters super!)

2003-09-18 Thread Etienne Grossmann

  Thanks for the link, it has a nice discussion. And for the
one-liner; I didn't quite realize one could put all that in a s///e.

  Cheers,

  Etienne


On Thu, Sep 18, 2003 at 12:00:18PM +0200, A. Pagaltzis wrote:
# * Etienne Grossmann [EMAIL PROTECTED] [2003-09-18 09:29]:
#  I hared a sutdy has been dnoe on taht scjebut in an Eigslnh
#  urtiivesny, but I coannt get hold of it. Any ionirmtfoan on
#  that sceujbt is welomce.
# 
# http://www.bisso.com/ujg_archives/000224.html
# 
#  perl -pe 'sub r{join,map chop,sort 
map{rand().$_}shift=~/(.)/g};s/\b(\w)(\w*)(\w)\b/$1.r($2).$3/eg'
# 
# perl -pe's/(?=[a-z])([a-z]+)(?=[a-z])/join,map chop, sort map 
rand().$_,$1=~m[.]g/ige'
# perl -MList::Util=shuffle 
-pe's/(?=[a-z])([a-z]+)(?=[a-z])/join,shuffle$1=~m[.]g/ige'
# 
# -- 
# Regards,
# Aristotle
#  
# If you can't laugh at yourself, you don't take life seriously enough.

-- 
Etienne Grossmann -- http://www.isr.ist.utl.pt/~etienne


Re: Semcarlbd letrtes sepur! (Scrambled letters super!)

2003-09-18 Thread Kripa Sundar
Bart writes:

= Especially the idea of using the /\B/ anchor appeals to me.
=  Hmm... let's try it:
= 
= : perl -pe 'sub r{join,map chop,sort 
map{rand.$_}shift=~/(.)/g};s/\B(\w+)\B/r$1/eg' 

Thanks to Etienne for the map chop,sort map.  That was
neat.  At long last, we are having some FWP on this list.  :-)

Bart's \B is great, too.

Now we can inline r, and save some chars.

  || perl -pe 's/\B(\w+)\B/join,map chop,sort map{rand().$_}split,$1/eg'

I have brought back Etienne's parens for rand(), to avoid
the warning.  I've also replaced the /(.)/g in r with a
split().  It is just as long, and is aesthetically pleasing
(to me), because I don't have a m// in the RHS of an s///.


The only trouble with map chop,sort map is that it doesn't
*guarantee* that the new string is different from the old.

The following does guarantee re-ordering., but it is much
less elegant.  It is just two chars more than Bart's
solution, but it is 14 chars longer than inlining r unchanged
(as above).

  || perl -pe 's/\B(\w*)(\w)(\w)\B/$3.$2.join,map chop,sort 
map{rand().$_}split,$1/eg'

peace,  || Rescuing good ideas: Micro venture capital:
--{kr.pA}   || http://tinyurl.com/gjpd
-- 
I promise you I will listen to what has been said here, even though \
I wasn't here. -- George W. Bush [http://slate.msn.com/?id=76886]


Re: Semcarlbd letrtes sepur! (Scrambled letters super!)

2003-09-18 Thread Kripa Sundar
Following up to myself embarassed grin:

My previous no guarantee of scrambling code was:

  || perl -pe 's/\B(\w+)\B/join,map chop,sort map{rand().$_}split,$1/eg'

We can drop the parens on the LHS, and change $1 to $:

  || perl -pe 's/\B\w+\B/join,map chop,sort map{rand().$_}split,$/eg'

I am still keeping the parens for rand().  Dropping them
doesn't seem to hurt the results, except for the apparently
incorrect warning about ambiguity.  How could rand.$_ be
amiguous?

peace,  || Rescuing good ideas: Micro venture capital:
--{kr.pA}   || http://tinyurl.com/gjpd
-- 
I promise you I will listen to what has been said here, even though \
I wasn't here. -- George W. Bush [http://slate.msn.com/?id=76886]


Re: Semcarlbd letrtes sepur! (Scrambled letters super!)

2003-09-18 Thread Jasper McCrea
Kripa Sundar wrote:
 
 Bart writes:
 
 = Especially the idea of using the /\B/ anchor appeals to me.
 =  Hmm... let's try it:
 =
 = : perl -pe 'sub r{join,map chop,sort 
 map{rand.$_}shift=~/(.)/g};s/\B(\w+)\B/r$1/eg'
 
 Thanks to Etienne for the map chop,sort map.  That was
 neat.  At long last, we are having some FWP on this list.  :-)
 
 Bart's \B is great, too.
 
 Now we can inline r, and save some chars.
 
   || perl -pe 's/\B(\w+)\B/join,map chop,sort map{rand().$_}split,$1/eg'
 
 I have brought back Etienne's parens for rand(), to avoid
 the warning.  I've also replaced the /(.)/g in r with a
 split().  It is just as long, and is aesthetically pleasing
 (to me), because I don't have a m// in the RHS of an s///.

Never mind aesthetics. This is golf. An alternative is:

  perl -pe 's#\B\w+\B#join,sort{5-rand 10}$=~/./g#eg'

uses a different rand sort. '.5-rand' unfortunately doesn't work. I guess
the sort is looking for  -1, then -1  x  1, then  1, and not simply
-ves and +ves. Whatever, this is only two characters longer.

By the way, the error message from rand.$_ can be eliminated in one less
character using -X instead of ().

Jasper


Re: Semcarlbd letrtes sepur! (Scrambled letters super!)

2003-09-18 Thread A. Pagaltzis
* Kripa Sundar [EMAIL PROTECTED] [2003-09-18 15:41]:
 The following does guarantee re-ordering.

How does it reorder loop? :-)

-- 
Regards,
Aristotle
 
If you can't laugh at yourself, you don't take life seriously enough.