On Sat, Apr 22, 2006 at 12:24:06AM +0900, Matthew Moss wrote:
} One line?
} Hmmm.... Methinks I need to go back and reexamine my own solution.
Heh. I decided against making it a single line for readability purposes.
Yeah, it can be done in a single line, but it will be less readable and
less efficient.
--Greg
} On 4/21/06, Yoann Guillot <john-rubytalk@ofjj.net> wrote:
} > On Fri, Apr 21, 2006 at 11:27:08PM +0900, Gregory Seidman wrote:
} > > On Fri, Apr 21, 2006 at 11:16:38PM +0900, Dirk Meijer wrote:
} > > } this quiz is probably easier than usually, as, for the first time
} > > } ever, i felt up to it, and created a solution in not so much time.
} > > } i'll be posting it in 48 hrs
} > >
} >
} > Mmh, for my first participation, i get a quizz solved by a one-liner.
} > And still i discover things
} >
} > Yoann
} >
} >
}
}
One of the easiest ones we have ever done, yes, and I think that's a good thing.
Programmers of all skill levels follow the quiz and it's a common complaint that all the problems are "advanced" material. I'm trying to get better about that.
May I suggest smthng to make it more challenging?
1. Vowel can be exchanged with vowel only,
consonant can be exchanged with consonant only;
2. Parameterize the solution, so that set of exchangeable characters classes
can be specified (optionally);
The Ruby Quizzes are ideas. If you need to add this to challenge yourself, go for it. We won't come and take your keyboard away, I promise.
James Edward Gray II
···
On Apr 21, 2006, at 12:26 PM, Sergey Volkov wrote:
James (being the host) can put forth his own comments on the goals of
the quiz. But I think there's plenty of room for both simple and
mildly complex problems; the simpler ones especially give newbies some
fun.
Feel free to add more to your own code if you like. Since I'll be
writing the summary, I'll be looking at all the solutions and will
comment on extras as I find them interesting, appropriate, etc.
···
On 4/21/06, Sergey Volkov <gm.vlkv@gmail.com> wrote:
Looks like this Quiz is too easy.
May I suggest smthng to make it more challenging?
1. Vowel can be exchanged with vowel only,
consonant can be exchanged with consonant only;
2. Parameterize the solution, so that set of exchangeable characters classes
can be specified (optionally);
Sorry, if I'm breaking the Quiz rules.
I've been able to condense mine to about 15 lines - I'm always impressed
that you guys can shrink stuff down so far... I just wish I could understand
them after they're posted to the group!
-M
···
Working on my short version. 62 chars long and works for your
example, but still trying to get <70 with it working
correctly with digits.
(Sorry for the noise) - the test text used there doesn't go too well
with my solution, which limits how much of a word is rearranged. This is
a better example:
[rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
La viiosn euroénepne strégiatque
[rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
La vioisn eurpeénone strgaéitque
[rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
La vioisn eurenopéne strtagiéque
[rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
La vision eurpeéonne stréigatque
[rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
La vision euréonpene strgtéiaque
[rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
La visoin eureéonpne striagtéque
(from La vision européenne stratégique)
···
On Sat, 2006-04-22 at 19:28 +0900, Ross Bamford wrote:
On Sat, 2006-04-22 at 06:09 +0900, James Edward Gray II wrote:
> On Apr 21, 2006, at 3:34 PM, Bill Kelly wrote:
>
> > From: "Andrew Johnson" <ajohnson@cpan.org>
> >>
> >> As a script, my one-liner is down to 70 chars including
> >> the newline. It can be shortened a bit as a command-liner.
> >>
> >
> > Wow, nice. Does that include the restriction in the quiz rules that
> > numbers have to be left alone? Or does your solution rearrange
> > both numbers and letters?
>
> I'm still waiting for someone to show off their solution properly
> handling the trivial (multi-byte) example I showed earlier...
$ ./munger.rb test.txt
Attehcaed is my résmué.
$ ./munger.rb test.txt
Atthaceed is my réumsé.
$ ./munger.rb test.txt
Attacheed is my rémsué.
$ ./munger.rb test.txt
Attcaehed is my rémusé.
$ ./munger.rb test.txt
Attecahed is my rémsué.
Aye, usually I'd agree with you. But in this case the two examples are
almost exactly the same. Just changing it to work with input instead of
a string.
The first one I posted was in reply to a post about one-liners. Not
intended as a seperate submission.
My solution scrambles only part of the inside of the word, depending on
the word length, and favours keeping more from the start of the word. So
with this example it's taking the six letter 'rémsué' and deciding to
scramble 3 letters, 'msu' (remains after we take two from the start, one
from the end). So with that input, the e's wouldn't be touched.
I just didn't think about that before I posted - the second output I
posted showed some longer accented words with the e's moving around
properly :).
···
On Sat, 2006-04-22 at 23:31 +0900, James Edward Gray II wrote:
On Apr 22, 2006, at 5:28 AM, Ross Bamford wrote:
> $ ./munger.rb test.txt
> Attehcaed is my résmué.
> $ ./munger.rb test.txt
> Atthaceed is my réumsé.
> $ ./munger.rb test.txt
> Attacheed is my rémsué.
> $ ./munger.rb test.txt
> Attcaehed is my rémusé.
> $ ./munger.rb test.txt
> Attecahed is my rémsué.
Well, that's a question of more random, or more readable. A good point
was raised about longer words becoming unrecognisable when just randomly
scrambled...
OTOH If we're doing random scrambling, leaving only first and last
letter I think I can get back down to two lines...
What's everyone else doing?
···
On Sun, 2006-04-23 at 00:56 +0900, Ray Baxter wrote:
Ross Bamford wrote:
> This is a better example:
>
> [rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
> La viiosn euroénepne strégiatque
> [rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
> La vioisn eurpeénone strgaéitque
> [rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
> La vioisn eurenopéne strtagiéque
> [rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
> La vision eurpeéonne stréigatque
> [rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
> La vision euréonpene strgtéiaque
> [rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
> La visoin eureéonpne striagtéque
>
> (from La vision européenne stratégique)
>
The pattern, "eu???ne str???que" is constant in your results.
"text".gsub(/\B(\w{2,})\B/) { |s| s.length.times { |i| r = rand(s.length);
s[i], s[r] = s[r], s[i] }; s }
It is one line, but it does have a couple of semi-colons.
···
On 22/04/06, Ross Bamford <rossrt@roscopeco.co.uk> wrote:
On Sun, 2006-04-23 at 00:56 +0900, Ray Baxter wrote:
> Ross Bamford wrote:
>
> > This is a better example:
> >
> > [rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
> > La viiosn euroénepne strégiatque
> > [rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
> > La vioisn eurpeénone strgaéitque
> > [rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
> > La vioisn eurenopéne strtagiéque
> > [rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
> > La vision eurpeéonne stréigatque
> > [rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
> > La vision euréonpene strgtéiaque
> > [rosco@jukebox text-munger-76]$ ./munger.rb test2.txt
> > La visoin eureéonpne striagtéque
> >
> > (from La vision européenne stratégique)
> >
>
> The pattern, "eu???ne str???que" is constant in your results.
>
Well, that's a question of more random, or more readable. A good point
was raised about longer words becoming unrecognisable when just randomly
scrambled...
OTOH If we're doing random scrambling, leaving only first and last
letter I think I can get back down to two lines...