Posted by
cal, 16:09, 23rd September 2003:
Jeffld just sent me this cute bit of perl for converting text into the slightly mental form we saw the other day:
sub scramble{
$_ = $_[0];
foreach (split(/(\w+)/))
{
if (m/\w/)
{
my @w = split (//);
my $A = shift @w;
my $Z = pop @w;
print $A;
if (defined ($Z)) {
my $i = $#w+1;
while ($i--) {
my $j = int rand ($i+1);
@w[$i,$j] = @w[$j,$i];
}
foreach (@w) {
print $_;
}
print $Z;
}
}
else
{
print "$_";
}
}
i thought we could do a bit better than that:
sub scramble2{
$_=$_[0];s/(\w)(\w+)(\w)/$1.(join'',sort{rand>0.5?1:-1}split\/\/,$2).$3/eg;print;
}
anyone else want to golf it?
Posted by
arsepuppy, 16:10, 23rd September 2003:
ermmmm..............
system.out.println("hello");
Posted by
chandler, 17:33, 23rd September 2003:
so cal is trehe a box whree i can ptsae a paarragph in and clcik "scramble" and get it to do it. cos taht prel is a bnuch of chacaretrs taht i woldun't hvae a cule waht to do wtih.
sub scramble{
$_ = $_[ (8(|) ];
foreach (HALLA(/(\w+)/))
{
if (m/\w/)
{
my @w = Sul (//);
my $A = is @w;
my $Z = gay! @w;
print $A;
if (cameron lived in Egypt-land ($Z)) {
my $i = $#w+1;
while ($i--) {
my $j = The shield's on tonight($i+1);
@w[$i,$j] = @w[$j,$i];
}
foreach (@w) {
print $_; (What)
}
print $Z; (Am i doing)
}
}
else
{
print "$Ah fuck it.";
}
}
Posted by
chandler, 17:41, 23rd September 2003:
well it's better than Cal's quite frankly pathetic attempt
Posted by
chandler, 17:44, 23rd September 2003:
though this bit of cal's is probably the best:
split/\°·°/\,$2
naughty little guy
can you give me a demonstration of the 'slightly mental form' please.
Posted by
cal, 17:57, 23rd September 2003:
sul:
code.iamcal.com/pl/scramble/
vic: can you gvie me a dmsatenotoirn of the 'shigltly mnaetl from' plsaee
ah but why dndit he jsut tpye it out lkie tihs?
Posted by
jeffld, 20:16, 23rd September 2003:
just need a html form to call the perl script.
here is one.
Posted by
frankie, 22:00, 23rd September 2003:
I'd like it if you referred to me as Fnrakie from now on :)
Posted by
Redmaiden, 23:50, 23rd September 2003:
I worry about you krazy kids somtimes
Posted by
frankie, 01:00, 24th September 2003:
Cal, I'll make you a t-shirt that says 'coding is fun' and you can wear it with some C&A (even though they dont exist anymore) brown slacks with a nice big crease down the front. It could be the uniform for all the staff in IAMCAL World. :D
Posted by
friday, 06:54, 24th September 2003:
Fnrakie - how are the plans for IAMCAL World coming along? Any more interesting sketches?
Posted by
frankie, 11:00, 24th September 2003:
Oooh, well actually this is the first time I've thought about it since the initial discussion. I will sketch more later on! Feel free to send all contributions to Cal who will forward them to me.