Re: seeking golfing advice

2012-05-16 Thread Ronald J Kimball
On Wed, May 16, 2012 at 04:40:40AM -0700, John Douglas Porter wrote: > And of course, use grep, as others have said. > > @list[ grep !$_%2, 0..$#list ]; > > that gets you every other element, beginning with the first. ! has higher precedence than %, so this actually gets you just the first eleme

Re: decimal -> Binary

2011-11-16 Thread Ronald J Kimball
On Wed, Nov 16, 2011 at 09:34:58PM +0100, Olof Johansson wrote: > On 2011-11-16 14:14 -0500, Ronald J Kimball wrote: > > It's working as expected for me, so I'm not sure what needs to be fixed. > > Hum, now I'm ashamed. Sorry. But why is that not greedy? (I got

Re: decimal -> Binary

2011-11-16 Thread Ronald J Kimball
On Wed, Nov 16, 2011 at 07:49:14PM +0100, Olof Johansson wrote: > On 2011-11-16 11:57 -0500, Ronald J Kimball wrote: > > No, you are wrong. s/0*// is sufficient, because /0*/ will always match at > > the start of the string anyway. > > You're clearly an expert. I yield.

Re: decimal -> Binary

2011-11-16 Thread Ronald J Kimball
On Wed, Nov 16, 2011 at 04:14:57PM +0100, Olof Johansson wrote: > On 2011-11-16 09:57 -0500, Ronald J Kimball wrote: > > That should be s/0*//, otherwise you'll get the wrong result for numbers > > above 2147483647. > > That should be s/^0*//, otherwise you'll get

Re: decimal -> Binary

2011-11-16 Thread Ronald J Kimball
On Wed, Nov 16, 2011 at 03:32:03PM +0100, Georg Moritz wrote: > golfed down a bit, just for fun... > > #!/usr/bin/perl -l > @ARGV or die "No args"; > print"$_: ",($_=unpack"B*",pack"N",$_)=~s/0+//?$_:$_ for@ARGV; That should be s/0*//, otherwise you'll get the wrong result for numbers above 21474

Re: code line of the day

2006-09-07 Thread Ronald J Kimball
On Thu, Sep 07, 2006 at 07:21:07AM -0700, Randal L. Schwartz wrote: > > "Uri" == Uri Guttman <[EMAIL PROTECTED]> writes: > > Uri> @{$self->{templates}}{ keys %{$tmpls} } = > Uri> map ref $_ eq 'SCALAR' ? \"${$_}" : \"$_", values %{$tmpls} ; > > Uri> discuss amongst yourselves. topic

Re: /$sudoku/

2006-05-17 Thread Ronald J Kimball
I presented Ilmari's /$sudoku/ scripts at the Boston.pm meeting last week. During the discussion, we thought of a further optimization. Ilmari's first version uses a generic regular expression. The second version hardcodes the known values into the negative-lookahead assertions. The optimization

Re: Interesting little regex

2006-02-24 Thread Ronald J Kimball
On Fri, Feb 24, 2006 at 03:20:27PM -0700, Alan Young wrote: > > I'm afraid I'm not getting what you mean by "unique occurrence"... Why is > > there only one unique occurrence of 'abc', when the string contains 'abc' > > four times? Why are there two unique occurrences of 'de', but only one of > >

Re: Interesting little regex

2006-02-24 Thread Ronald J Kimball
On Fri, Feb 24, 2006 at 01:40:15PM -0700, Alan Young wrote: > > Yes, what are the unique occurrences of text in that string? I've run the > > code and I'm still not exactly sure what it's supposed to do. > > > > use Data::Dump qw/ dump /; > > > > $a="abcde"x4; > > $a=~s{((\w+?)(??{!$b{$^N}++?"(?=)

Re: Interesting little regex

2006-02-24 Thread Ronald J Kimball
On Fri, Feb 24, 2006 at 11:46:37AM -0700, Alan Young wrote: > Yeah, that's what I said. We realized we didn't need it for the > unique words. What we were doing originally though was pulling the > unique occurrences out of a string of text: > > $a = 'abcde' x 200; > > What are the unique occurr

Re: A curious logic

2005-03-08 Thread Ronald J Kimball
On Tue, Mar 08, 2005 at 08:50:11AM -0500, Perl Diety wrote: > "...are easy and IMO, not interesting..." > > juxtapositioned with > > ", but I never found one..." > > Vern or Vernette, doesn't this imply that either: > > (a) You didn't look very hard, since being easy, they shoul

Re: "Secret" operators

2005-02-01 Thread Ronald J Kimball
On Tue, Feb 01, 2005 at 11:15:46AM -0600, [EMAIL PROTECTED] wrote: > Can I get that just a little slower? > > $b = () = /u/g; > > is the same as: > >@a = /u/g; >$b = @a; > > I understand what happens, but it appears to be assigning to an empty list > - is that filling up the list, so

Re: Shortening a script, but aiming for efficiency

2004-10-01 Thread Ronald J Kimball
On Fri, Oct 01, 2004 at 09:23:14AM -0600, Alan Young wrote: > > a\tb\t > > a\t\t > > \tb\t > > \t\t\t > > > > The output for all these should be: > > > > a|b > > a|\s > > |b > > |\s > > > > This means that I could start by replacing all tabs with pipes, but then > > I would always have to rem

Re: Load-Bearing Warnings

2004-08-03 Thread Ronald J Kimball
On Tue, Aug 03, 2004 at 06:12:25PM +, Smylers wrote: > I turned warnings off in a script[*0] but made no other changes to it. > This broke the script, in that it would no longer run correctly[*1]. In > other circumstances[*2] I might've regarded this as fun. > > Presuming that this isn't a we

Re: Another regexp conundrum

2004-06-01 Thread Ronald J Kimball
On Tue, Jun 01, 2004 at 05:22:01PM -0400, [EMAIL PROTECTED] wrote: > >/(anything)*/ can always match a zero length substring at the beginning of >the string, and as soon as the regex engine finds a match, it stops. The >(?!) forces the regex engine to backtrack through all possible ma

Re: Another regexp conundrum

2004-06-01 Thread Ronald J Kimball
On Tue, Jun 01, 2004 at 02:11:56PM -0400, [EMAIL PROTECTED] wrote: > 13 '__pqrxyz__pqr___abc___' =~ /(($re).*?)*(?!)/; > Of course, this is incomplete, but it is a start. One thing that > puzzles me is that the (?!) is absolutely required on line 13. > Without it, @seen doesn't get init

Re: fractional cents

2004-04-25 Thread Ronald J Kimball
On Mon, Apr 26, 2004 at 06:49:52AM +0200, Pense, Joachim wrote: > A. Pagaltzis [mailto:[EMAIL PROTECTED] wrote: > > > When you're dealing with money, it's better to use cents (or > > tenths or hundredths of cents) as a unit, rather than dollars. > > You can then use integer math. This gets you aro

Re: lwall snippet

2004-04-10 Thread Ronald J Kimball
On Sun, Apr 11, 2004 at 12:06:17AM -0400, [EMAIL PROTECTED] wrote: > I see. But I think you meant > >$_ x= /(..:..)...(.*)/ && 'foo' ge $1 && 'foo' lt $2; > > since the shell's $2 is never used, as far as I can tell. I still > have no clue what the shell's $1 would be in this case, oth

Re: pattern finding problem

2004-03-09 Thread Ronald J Kimball
On Tue, Mar 09, 2004 at 01:43:05PM -0500, Ronald J Kimball wrote: > > I think I've got almost what you want. It correctly limits the length and > number of repetitions (example 1) and handles overlapping occurrences of > the pattern (example 2). > > The one flaw is that

Re: pattern finding problem

2004-03-09 Thread Ronald J Kimball
Let's try this one more time... I originally sent this reply last Tuesday, but it seems a problem with the message headers kept it from being delivered. On Tue, Mar 02, 2004 at 08:01:07AM -0500, Aaron J. Mackey wrote: > > On the BioPerl mailing list we often get requests like the following: >

Re: lvalue hash slice

2003-09-30 Thread Ronald J Kimball
On Tue, Sep 30, 2003 at 11:07:24PM +0300, Gaal Yahas wrote: > I like hash slices: > > ($one, $two, $three) = @hash{ qw/aaa bbb ccc/ }; > > Sadly, this doesn't work as an lvalue: > > @hash{ qw/aaa bbb ccc/ } = ($one, $two, $three);# WRONG That actually does work. Ronald

Re: Fun - Each character at most once

2003-07-17 Thread Ronald J Kimball
On Thu, Jul 17, 2003 at 05:24:17PM +0200, Steffen M?ller wrote: > Richard Proctor wrote: > >What is the most "interesting" program that is restricted to > >use each ASCII character at most once? > > Anybody who can do a JAPH like that? s{}[k:'Ej2Z-G8R*a0F9Nc?D5&)+|],$_^=q;print Enjoy! Ronald

Re: I know this is not fun.

2003-07-17 Thread Ronald J Kimball
On Thu, Jul 17, 2003 at 09:31:31AM +0100, Moran, Matthew wrote: > Gareth wrote: > > > How about a perl filter to strip all non-fwp posts to this list? > > Depends on one's definition of fun I guess - some might say it's perl > programs that are whimsical in some way like the Camel script, or a >

Re: merlyn smeared by Python Johnnies' description of Schwartzian transform

2003-07-16 Thread Ronald J Kimball
On Wed, Jul 16, 2003 at 06:14:25AM -0700, John Douglas Porter wrote: > > Abigail wrote: > > Andrew Savige wrote: > > > I was just wondering if it would be more > > > accurate to describe this Python decorate-sort-undecorate (DSU) > > > thingy as a Guttman-Rosler transform? > > > My understanding i

Re: my if?

2003-07-01 Thread Ronald J Kimball
On Tue, Jul 01, 2003 at 05:15:09PM +0300, Vladi Belperchinov-Shabanski wrote: > my $id = 1 if $_ == 3; my has a compile time behavior and a runtime behavior. At compile time, my allocates memory for the variable and adds it to the pad. At run time, my resets the value of the variable. If you

Re: reencoding ampersands for html, longhand

2003-04-02 Thread Ronald J Kimball
On Wed, Apr 02, 2003 at 10:25:05PM -0600, [EMAIL PROTECTED] wrote: > Anyway, I got all the named entities (the numbered ones aren't a problem), > created a hash: > %html_entities = ( > "quot" => 1, > "amp" => 1, > "lt" => 1, > "gt" => 1, > "nbsp" => 1, > ... [ 200 more entities ] > > and came up

Re: golf tee puzzle

2003-03-13 Thread Ronald J Kimball
On Thu, Mar 13, 2003 at 01:22:26PM -0800, Quantum Mechanic wrote: > I came at it from another direction, starting out > caching the board state (equivalent to @state) for > each board seen. [In most cases, there are several > "paths" to a given board state.] > > I also used some other speedups, l

Re: my in conditionals

2002-11-27 Thread Ronald J Kimball
On Wed, Nov 27, 2002 at 04:41:13AM +, Paul Makepeace wrote: > $ perl -Mstrict -le 'print "one" if (my $d = "1") && $d' > > [or indeed if ((my $d = "1") && $d) {...} ] > > perl apparently doesn't consider $d exists by the second $d and issues > an error. Can someone explain this? (Esp. in ligh

Re: correctly rebuilding a whitespace-split string

2002-10-15 Thread Ronald J Kimball
On Tue, Oct 15, 2002 at 04:08:41AM +, Ton Hospel wrote: > In article <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] writes: > > En op 15 oktober 2002 sprak Aaron Mackey: > >> @d = splice(split, -4); # I always know that the last 4 fields > > > > This won't compile (first argument to splice mu

Re: NPL Puzzler for 6 Oct

2002-10-11 Thread Ronald J Kimball
On Fri, Oct 11, 2002 at 02:54:20PM -0400, Bernie Cosell wrote: > The NPL puzzle for 6 oct was an interesting little Perl exercise [I'm not > sure how to solve it analytically --- I played with it some to little > avail --- but it was certainly subject to brute force, and it turned out > to be a

Re: Perl Challenges, Anywhere?

2002-08-30 Thread Ronald J Kimball
On Fri, Aug 30, 2002 at 12:31:19PM -0500, James Edward Gray II wrote: > Forgive my ignorance, but what is the Perl Death Bowl or "TCP 3", for > that matter? TPC 3 was The Perl Conference 3.0. (This year's conference was TPC 6.0.) One of the events at TPC 3 was a sort of competitive programming

Re: Perl Challenges, Anywhere?

2002-08-30 Thread Ronald J Kimball
On Fri, Aug 30, 2002 at 11:58:03AM -0500, James Edward Gray II wrote: > Could anyone point me in the direction of a Perl challenge/contest > that's not Obfuscation or Golf? I've done some heavy searching but come > up empty handed. Are you looking for an ongoing contest to participate in, or a

Re: removing extra empty lines

2002-08-12 Thread Ronald J Kimball
On Mon, Aug 12, 2002 at 01:28:19PM -0400, Selector, Lev Y wrote: > Folks, > > I have a long file which has many "empty" lines > with nothing but may be spaces or tabs (/^\s*$/). > > These lines tend to group together creating chunks > of empty vertical space on the printout. > > I want to r

Re: Non-head, non-tail recursion???

2002-08-02 Thread Ronald J Kimball
On Fri, Aug 02, 2002 at 02:28:01PM -0500, [EMAIL PROTECTED] wrote: > "To understand recursion, we must first understand recursion." > > Thereby demonstrating tail recursion quite nicely, as distinct from "GNU's > Not Unix" which demonstrates (presumably) head recursion. Can you think of > an ac

Re: a little shorter please?

2002-07-22 Thread Ronald J Kimball
On Mon, Jul 22, 2002 at 02:41:25PM -0400, Aaron J Mackey wrote: > > I can't seem to get this any shorter: I want the second through the > next-to-last elements of @F joined by " ", and then the last item of @F. > > perl -ape '$,=" ";s//>@F[1..$#F-1]\n$F[$#F]/' > > or (no join, but same general

Re: weird oneline - who can explain it to me?

2002-06-25 Thread Ronald J Kimball
On Tue, Jun 25, 2002 at 09:48:55PM +0200, Kim Schulz wrote: > hi > a friend of mine just gave me this: > perl -e 's$$7=78)1~61\@A6*:\@?~$*y+A~@%-?B+\-" a-z*+/s^^$_^ee' > > can anyone explain it to me? > I know that it deletes all files and folders not starting with a dot > (.), but how does it

Re: reading lines backwards

2002-06-11 Thread Ronald J Kimball
On Tue, Jun 11, 2002 at 12:18:42PM -0400, Selector, Lev Y wrote: > Folks, > > Problem: > need to read a very big text file starting from the end and moving > backwards to its beginning. This is similar to a diamond ( ) operator > functionality - but in the opposite direction. Need to do it wit

Re: shortest test for truth & false assignment

2002-05-22 Thread Ronald J Kimball
On Wed, May 22, 2002 at 09:54:52PM -0400, Yanick wrote: > On Wed, May 22, 2002 at 10:06:39PM -0400, Josh Goldberg wrote: > > I came up with another one. This also works for values of true other > > than 1. > > > > if ($a=~tr/.[^0]+/0/c) { do_something(); } > > s/tr/s/, maybe ? > >

Re: shortest test for truth & false assignment

2002-05-22 Thread Ronald J Kimball
On Wed, May 22, 2002 at 10:55:52PM +0100, Simon Cozens wrote: > Ronald J Kimball: > > > > if( $a%2 .. $a-- ) { > > Here's what I understand the goal to be: > > If $a is true, set $a to false and execute some code > > But the code above doesn't do t

Re: shortest test for truth & false assignment

2002-05-22 Thread Ronald J Kimball
On Wed, May 22, 2002 at 10:45:39PM +0100, Simon Cozens wrote: > Scott Wiersdorf: > > if( $a%2 .. $a-- ) { > > I don't understand this. You see, if $a-- leaves $a as false, then: > if ($a--) > is the shortest way of solving the problem. But that will change $a to true if it was false. H

Re: FW: shortest test for truth & false assignment

2002-05-22 Thread Ronald J Kimball
On Wed, May 22, 2002 at 03:58:05PM -0400, Patrick Gaskill wrote: > > >$a&&($a=0)||do{do_something()}; > Anyway, the second bit of code there will short-circut after > the first expression if $a is false, so everything after > "$a&&" won't get executed, leaving $a alone. But && has higher

Re: First differing char in two strings

2002-04-25 Thread Ronald J Kimball
On Thu, Apr 25, 2002 at 12:51:33PM -0500, Craig S. Cottingham wrote: > A: craigc@samantha craigc $ perl -e '$a = 1; print +(--$a + > $a++) . "\t$a\n"' >1 1 > B: craigc@samantha craigc $ perl -e '$a = 1; print +($a + > $a++) . "\t$a\n"' >3 2 > C: craigc@samantha craigc $ perl

Re: First differing char in two strings

2002-04-11 Thread Ronald J Kimball
On Thu, Apr 11, 2002 at 05:06:28PM -0400, Prakash Kailasa wrote: > On Thu, Apr 11, 2002 at 05:03:53PM -0400, Jeff 'japhy' Pinyan wrote: > > On Apr 11, Prakash Kailasa said: > > > > >On Thu, Apr 11, 2002 at 08:06:14AM -0700, Paul Makepeace wrote: > > >> The task is to find the first differing char

Re: Why bother with separate lists?

2002-03-25 Thread Ronald J Kimball
On Mon, Mar 25, 2002 at 11:19:37PM +0100, Philippe 'BooK' Bruhat wrote: > On Mon, 25 Mar 2002 [EMAIL PROTECTED] wrote: > > > But is this the "official" perl-golf mailing list? > > Or is Ronald or someone else going to create a new > > [EMAIL PROTECTED] and change the charter of [EMAIL PROTECTED]?

Re: Why bother with separate lists?

2002-03-19 Thread Ronald J Kimball
On Tue, Mar 19, 2002 at 10:27:47PM -0500, Bernie Cosell wrote: > Oh, please. If it took a minute to download *all* "143" messages I'd be > surprised. Yes, I know that some folk do pay by the byte but minimizing- > bytes has hardly been a hallmark of the postings to the list... > [thinking her

A Perl-Golf mailing list

2002-03-18 Thread Ronald J Kimball
I suggest that further discussion of how to manage a golf list be moved to a new golf list. FWP shouldn't be a forum for administering other mailing lists. :) Ronald

Re: Golf contests and naive solutions?

2002-03-17 Thread Ronald J Kimball
On Sun, Mar 17, 2002 at 10:00:47AM +0100, Jerome Quelin wrote: > Hi folks, > > We were wondering if the referees were to provide a naive solution for > perlgolf contests? This way, beginners could really see what the script > is to do (remember Ton's Christmas tournament where only one beginner >

Re: Perl Golf as a sport

2002-03-10 Thread Ronald J Kimball
On Mon, Mar 11, 2002 at 12:31:25PM +1100, [EMAIL PROTECTED] wrote: > > I know, from bitter experience with Acme::EyeDrops, just how flaky > the (?{}) construct is; normally you cannot use regular expressions > inside it at all "because Perl's regex engine is not reentrant". > And yet, mysteriousl

Re: TPR1 post-mortem

2002-03-08 Thread Ronald J Kimball
On Fri, Mar 08, 2002 at 03:16:10PM +0100, Marcelo E. Magallon wrote: > A question of my own: why doesn't > > s/\B.\B/$&$&/g > > work as I expect, namely abcd -> abbccd. I really can't figure it out > by reading the docs. It works as expected in perl5.005_3 and perl5.7.2. There are man

Re: TPR1 post-mortem

2002-03-08 Thread Ronald J Kimball
On Fri, Mar 08, 2002 at 12:04:15PM +0100, F.Xavier Noria wrote: > On Fri, 08 Mar 2002 11:41:31 +0100 > cizaire_liste <[EMAIL PROTECTED]> wrote: > > : Can someone explains me why > : > : my $c = '($a="www")=~s{}{z}g;print "$a\n";die'; > : eval $c; > : $^O=~s{.}{$c}ee; > : > : output two lines t

Re: TPR1 post-mortem

2002-03-08 Thread Ronald J Kimball
On Fri, Mar 08, 2002 at 10:33:26AM +, Piers Cawley wrote: > Stephen Turner <[EMAIL PROTECTED]> writes: > > > On Fri, 8 Mar 2002 [EMAIL PROTECTED] wrote: > >> > >> Here are some statistics from the current series of games: > >> > >> fwp Santa (head, tail, ...):35 players on scoreboard >

Re: interesting typo I couldn't see

2002-02-17 Thread Ronald J Kimball
On Sun, Feb 17, 2002 at 12:02:49PM -0500, Bill -OSX- Jones wrote: > > >Vicki writes: > > > >> if (...) { > >>my @item_parts = split(/\n/, $item); > >>printf ORDER ("\n%4d %-50s %3.2f %3.2f\n", > >> $quantity, $item_par

Re: TPR0 Final Results

2002-02-15 Thread Ronald J Kimball
On Sat, Feb 16, 2002 at 11:10:41AM +1100, [EMAIL PROTECTED] wrote: > Stephen Turner wrote: > > Can someone explain to me why > > > > -l use POSIX;print strtol pop,36 > > > > doesn't work? Where does the extra 0 come from? > > To quote myself to Dave and Jerome: > > BTW, because I felt you were a

Re: Longest Common Substring

2002-02-15 Thread Ronald J Kimball
On Fri, Feb 15, 2002 at 07:27:03AM -0600, Tim Ayers wrote: > > "A" == Andrew Pimlott <[EMAIL PROTECTED]> writes: > A> On Fri, Feb 15, 2002 at 01:37:15AM -0500, Jeff 'japhy' Pinyan wrote: > >> Except that you are forced to find a 2-character match, which means you > >> end up skipping a POTENTI

Re: Finding Holidays

2002-02-06 Thread Ronald J Kimball
On Thu, Feb 07, 2002 at 12:19:01AM -0500, Bill -OSX- Jones wrote: > Hi :) > > I was asked recently if I could write a Perl program that > would find out when the next time Christmas day would > actually be on a Sunday. #!perl use Date::Christmas qw/ christmasday /; for my $year (1900 .. 2100)

Re: More Wacky Solutions

2002-01-31 Thread Ronald J Kimball
On Thu, Jan 31, 2002 at 05:28:15PM +0100, [EMAIL PROTECTED] wrote: > One can get as close to 0.833 as one wants, by writing something like: > > $&&=s&s&&&; > > and adding as many 's&'s after the = as needed to obtain the desired > ratio. $& is readonly; how about $&&&s&s&&&; Ro

Re: Better ?

2002-01-25 Thread Ronald J Kimball
On Fri, Jan 25, 2002 at 12:50:54PM -0500, Bill -OSX- Jones wrote: > > So, to come back, allow me to ask: > > $_ = "a planet of Perl Fun"; > for $y(qw/a e f l n o p r t u/){$x||=y/$y//%2; print " $y $x \n"} > > What is $x being set to and why ? 0, because "a planet of Perl Fun" does not contain

Re: A present ...

2002-01-24 Thread Ronald J Kimball
On Thu, Jan 24, 2002 at 12:31:51PM -0500, Bill -OSX- Jones wrote: > 69 strokes - > > #!perl -n > next if(($.%2)||(((length)-1)%2));!((tr/aeiouy//)%2) and print"$_"; > > >#!perl -n > >next if(($.%2)||(((length)-1)%2));print"$_" unless((tr/aeiouy//)%2); > > But ... Still prints even sets of vowel

Re: FORE! Get Even Golf Game Tees Off

2002-01-24 Thread Ronald J Kimball
On Thu, Jan 24, 2002 at 04:41:13PM +0100, Joerg Ziefle wrote: > Is it intended that users of a command line switch switch have to pay for one more >space? > > E.g.: > > #!perl > > -> 0 strokes for first line > > #!perl -whatever > > -> 1 stroke for space between '#!perl' and '-' + strokes fo

Re: match URI and nothing more?

2002-01-22 Thread Ronald J Kimball
On Tue, Jan 22, 2002 at 08:59:51AM -0800, Big D wrote: > Bill, > > This is commonly referred to as 'leaning toothpick syndrome' (LTS). > The problem is that you're using / as your regex delimiter AND you're not > escaping it in your regex. Change your delimiter to something NOT in your regex, > l

Re: match URI and nothing more?

2002-01-22 Thread Ronald J Kimball
On Tue, Jan 22, 2002 at 11:37:50AM -0500, Bill Jones wrote: > Hmmm, on Abigail's "protocol matcher" I get: > > File "TRJ:Users:sneex:Desktop:HellMatch"; > Line 24: /:http://(/: unmatched () in regexp > > Could it be too complex for BBEdit (651 on OSX) ? > > Nope, I tried the debugger and it sa

Re: Regex puzzle

2002-01-19 Thread Ronald J Kimball
On Sat, Jan 19, 2002 at 02:52:15PM +, Robin Houston wrote: > Consider this subroutine: > > sub shrinkable ($) { > my $str = shift; > for my $i (1..length($str)) { > return 1 if substr($str, $i) . substr($str, 0, $i) lt $str; > } > return 0; > } > > So "foo" is not shr

Re: make a 24(another practical problem)

2002-01-18 Thread Ronald J Kimball
On Fri, Jan 18, 2002 at 11:35:23AM -0500, Ronald J Kimball wrote: > Each operator position can hold one of four operators, which means you have > 4**4 different arrangements of operators for each of the four operator > layouts. Three operator positions, not four. Oops. :) Ronald

Re: make a 24(another practical problem)

2002-01-18 Thread Ronald J Kimball
On Fri, Jan 18, 2002 at 10:27:14AM -0600, Greg Bacon wrote: > In message <[EMAIL PROTECTED] > one.net>, > user who writes: > > Enumerating the possible operator layouts: > > - # # o # o # o > - # # o # # o o > - # # # o o # o > - # # # # o o o > > where '#' represents a number and '

Re: Practical Perl Problem

2002-01-14 Thread Ronald J Kimball
On Mon, Jan 14, 2002 at 10:54:28PM -0500, Ronald J Kimball wrote: > #!perl -nl > s/^ ?-- ?//;push@a,[s/:$//?"--== $_ ==--":/^ *(\S+)\s+(\S+)\s*(\S*)/]; > $;=$:if($:=length$1)>$;}{*b=$_,$#b?($b[2]=~s/.+/_vector($& downto 0)/, > $b[2]=~s/^/ std_logic/,printf"

Re: Practical Perl Problem

2002-01-14 Thread Ronald J Kimball
On Mon, Jan 14, 2002 at 11:01:57PM -0500, Aaron D. Marasco wrote: > At 22:54 14 01 2002, Ronald J Kimball wrote: > >On Mon, Jan 14, 2002 at 07:32:15PM -0500, Aaron D. Marasco wrote: > >> > >> The double hyphen in front of the incoming text is optional and could have &g

Re: Practical Perl Problem

2002-01-14 Thread Ronald J Kimball
On Mon, Jan 14, 2002 at 07:32:15PM -0500, Aaron D. Marasco wrote: > > Please explain if you are doing anything "complicated" so we can all learn. > ;) Well, that's no fun! ;) > The double hyphen in front of the incoming text is optional and could have > spaces on either side of it. The space

Re: Golf challenge: decode CETI message

2002-01-12 Thread Ronald J Kimball
On Sun, Jan 13, 2002 at 03:41:40AM +0200, Ilmari Karonen wrote: > > On Fri, 11 Jan 2002, Philip Newton wrote: > > On Wed, 9 Jan 2002 20:34:30 -0500, [EMAIL PROTECTED] (Keith C. Ivey) > > wrote: > > > > > But s'\x0\xff' @' to make it shorter and more visible on my system. > > > > y(s))y) ? > >

Re: Interactive golf hole

2002-01-08 Thread Ronald J Kimball
On Tue, Jan 08, 2002 at 08:20:10PM -0800, Yitzchak Scott-Thoennes wrote: > Now that someone has braved removing the quotes in the regex (which > I was hoping would happen) I'll post my solution that does it the > long way: That's the way I went as well, although it makes some complications for th

Re: Interactive golf hole

2002-01-08 Thread Ronald J Kimball
On Tue, Jan 08, 2002 at 01:30:12PM -0800, Yitzchak Scott-Thoennes wrote: > >On Tue, Jan 08, 2002 at 11:50:44AM -0800, Yitzchak Scott-Thoennes wrote: > > -n $,=':';$\=$/;print grep$_,/\G\s*(?:"([^"]*)"(?:\s|$)|([^\s#]+))/g; > > (but what a poor score it gives... :/ ) > > It gets worse: > W

Re: Interactive golf hole

2002-01-08 Thread Ronald J Kimball
On Tue, Jan 08, 2002 at 11:50:44AM -0800, Yitzchak Scott-Thoennes wrote: > > Also, I said: "Fields are separated by 1 or more whitespace characters", > so "x"x is one 4 character field, not two 1 character fields. Woops, I got that part wrong. Gotta go rework my solution... Ronald

Re: Interactive golf hole

2002-01-08 Thread Ronald J Kimball
On Tue, Jan 08, 2002 at 02:50:16PM -0500, Jeff 'japhy' Pinyan wrote: > On Jan 8, Yitzchak Scott-Thoennes said: > > >A file has 0 or more fields on each line. > >Fields are separated by 1 or more whitespace characters. > >Leading and trailing whitespace should be ignored. > >Comments (starting wit

Re: Perl and majordomo

2001-12-26 Thread Ronald J Kimball
On Wed, Dec 26, 2001 at 04:46:11PM -0500, Michael G Schwern wrote: > On Wed, Dec 26, 2001 at 01:24:20PM -0800, Sir Not-appearing-in-this-film wrote: > > Someone should write a working 'unsubscribe' function > > in Perl for Majordomo mailing lists. The current > > system does not seem to work. > >

Re: test a password string for correctness

2001-12-20 Thread Ronald J Kimball
On Thu, Dec 20, 2001 at 07:00:30PM +0100, Philip Newton wrote: > On Thu, 13 Dec 2001 10:50:11 -0500, [EMAIL PROTECTED] > (Ronald J Kimball) wrote: > > > (y/a-zA-Z// > 2) & (y/0-9// > 1) > > > > Each numeric comparison will return either 1 or 0. > > In

Re: test a password string for correctness

2001-12-13 Thread Ronald J Kimball
On Thu, Dec 13, 2001 at 07:11:09PM -0500, Ryan Fischer wrote: > I guess it simply wasn't good that the guy asked a question on an FWP > list where TMTOWTDI and so many people think the short ways are better. > If he was simply looking for an answer, any other list would have worked > fine. I gues

Re: test a password string for correctness

2001-12-13 Thread Ronald J Kimball
On Thu, Dec 13, 2001 at 10:41:57AM -0500, Jeff 'japhy' Pinyan wrote: > I probably would have thought about y/// after a while, but I can't pass > up a good regex. ;) > > y/a-zA-Z//>2&&y/0-9//>1 > > is probably where I'd get to. I think RJK's attempt to cheat the system > fails: > > y/a-zA-

Re: test a password string for correctness

2001-12-13 Thread Ronald J Kimball
On Thu, Dec 13, 2001 at 08:36:03AM -0600, [EMAIL PROTECTED] wrote: > If you are prepared to change $_: > > if (y/a-zA-Z//>2&&y/0-9//>1) {# 24 chars for the test > print "not valid"; > } That does not change $_. > > If you can't change $_, you need the c opt on the y's, he

Re: test a password string for correctness

2001-12-13 Thread Ronald J Kimball
On Thu, Dec 13, 2001 at 03:24:14PM +0100, Sven Neuhaus wrote: > On Thu, Dec 13, 2001 at 03:01:43PM +, Mohit Agarwal wrote: > > On Thu, Dec 13, 2001 at 02:49:05PM +0100, Sven Neuhaus wrote: > > > y/A-Za-z/A-Za-z/>2&&y/0-9/0-9/>1 > > > or the shorter > > > $a=$_;y/A-Za-z//>2&&y/0

Re: Possible improvements for the next golf apocalypse

2001-12-12 Thread Ronald J Kimball
On Wed, Dec 12, 2001 at 05:19:39PM +1100, [EMAIL PROTECTED] wrote: > Eugene van der Pijll wrote: > > The word 'apocalypse' is already in use for a type of Perl Golf > > tournament, so it is perhaps not the right name. I'm open to > > suggestions. > Bernie Cosell wrote: > > What type of tournament

Re: Possible improvements for the next golf apocalypse

2001-12-10 Thread Ronald J Kimball
On Mon, Dec 10, 2001 at 04:39:52PM +, Simon Cozens wrote: > On Mon, Dec 10, 2001 at 10:07:15AM -0600, Nicholson, Dale wrote: > > Santa is nothing more than a perversion added later. > > Or a shortened name for "Saint Nicholas", a Saint of the Catholic church. > The choice is yours. Or off-to

Re: Possible improvements for the next golf apocalypse

2001-12-10 Thread Ronald J Kimball
On Mon, Dec 10, 2001 at 10:57:06AM -0500, Ronald J Kimball wrote: > On Mon, Dec 10, 2001 at 04:36:26PM +0100, BooK wrote: > > You mean (supposing the code is in $_, and $score is in $s): > > > > $o="\xff";for(split//){$s++if($_>$o);$o=$_};print$s > > >

Re: Possible improvements for the next golf apocalypse

2001-12-10 Thread Ronald J Kimball
On Mon, Dec 10, 2001 at 04:36:26PM +0100, BooK wrote: > En réponse à [EMAIL PROTECTED]: > > > IMHO a solution to a good hole should be in the 50-70 char region. That way > > there's more scope for "styling" the response. Such styling could > > include: > > - the least number of /a-z/i chars. >

Re: Possible improvements for the next golf apocalypse

2001-12-10 Thread Ronald J Kimball
On Sun, Dec 09, 2001 at 12:31:06PM +1100, [EMAIL PROTECTED] wrote: > However, I suggest that in future games the Arbiter should reveal > the leading scores for each hole about 4-8 hours from the end. > This should make the final hours quite exciting. > I think that 4-8 hours is too short, consid

Re: The Santa Claus Golf Apocalypse

2001-12-03 Thread Ronald J Kimball
On Mon, Dec 03, 2001 at 08:49:33PM +, Piers Cawley wrote: > Ronald J Kimball <[EMAIL PROTECTED]> writes: > > > Why would printing to STDERR warrant a penalty anyway? It should > > disqualify the entry entirely. > > On what grounds? Nothing was mentioned when

Re: The Santa Claus Golf Apocalypse

2001-12-03 Thread Ronald J Kimball
On Mon, Dec 03, 2001 at 08:17:33PM +, Piers Cawley wrote: > [EMAIL PROTECTED] writes: > > > * I always chortle at Piers creative-in-the-extreme > > entries. He may claim a lower score. > > Too bloody right he will. You've just moved the goalposts again. All > of a sudden printing to stderr

Re: middle line, redux

2001-12-03 Thread Ronald J Kimball
On Mon, Dec 03, 2001 at 08:54:06PM +0100, Philip Newton wrote: > On Sun, 2 Dec 2001 13:49:04 + (GMT), [EMAIL PROTECTED] > (Jonathan e. paton) wrote: > > > I honestly think I've found the only true solution, which > > is: > > > > perl -p > > Hm? How does this print only the middle line of a

Re: middle line, redux

2001-12-02 Thread Ronald J Kimball
On Sun, Dec 02, 2001 at 08:14:00AM -0500, Bernie Cosell wrote: > Would someone take a step back from the Perl intricacies and tell me if > they even have an *algorithm* [much less a Perl program] that meets the > problem's criteria. I as got it: >1) you can only read the file once, from beg

Re: middle line (was Re: Daily Perl FAQ...)

2001-11-29 Thread Ronald J Kimball
On Thu, Nov 29, 2001 at 11:34:24AM -0800, Chris Thorpe wrote: > > On Thu, 29 Nov 2001, Yanick wrote: > > > On Thu, Nov 29, 2001 at 01:34:02PM -0500, Michael G Schwern wrote: > > > >>> Yesterday, I saw an interesting related exercise. Write a program that > >>> reads the lines from a file and ou

Re: Daily Perl FAQ - How do I select a random line from a file? (fwd)

2001-11-29 Thread Ronald J Kimball
On Thu, Nov 29, 2001 at 06:36:06AM +0100, Philip Newton wrote: > On Wed, 28 Nov 2001 12:46:06 -0600, [EMAIL PROTECTED] (Andy Bach) > wrote: > > > Thanks much. I thought there might be related technique for getting a > > rand element from an array, but we know the array length so ... this > > (

Re: Gift Giving... in Perl?

2001-11-27 Thread Ronald J Kimball
On Tue, Nov 27, 2001 at 02:56:16PM -0800, Jeremy Zawodny wrote: > Since it's the holiday season, someone recently asked me if I could > hack out a quick script to setup a "scecret santa" system. The basic > idea was this: > > Feed a script a bunch of e-mail addresses. The script will assign

Re: Daily Perl FAQ - How do I select a random line from a file? (fwd)

2001-11-27 Thread Ronald J Kimball
On Tue, Nov 27, 2001 at 11:31:39AM -0600, Andy Bach wrote: > Hi. > > Okay, would the maths folk like to offer a helpful explanation? > > a > > -- Forwarded message -- > > Question: > How do I select a random line from a file? > > Here's an algorithm from the Camel Book: >

Re: Practical Perl Golf

2001-11-15 Thread Ronald J Kimball
On Thu, Nov 15, 2001 at 07:42:41AM -0500, Keith C. Ivey wrote: > Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> wrote: > > > perl > > -pe's/^\s*#(?!\s*((ifn?|un)def|(el|end)?if|define|include|else)\ > > b).*//s' > > > > Note that without the /s modifier, . will NOT match the trailing > > \n, so I'd hav

Re: Practical Perl Golf

2001-11-14 Thread Ronald J Kimball
On Wed, Nov 14, 2001 at 11:08:25PM -0500, Keith C. Ivey wrote: > Michael G Schwern <[EMAIL PROTECTED]> wrote: > > > perl -ne "$saw_bang++ if /^#!.*(perl|PERL)/; print if $saw_bang && (!/^\s*#/ || > > /^\s*#\s*(include|define|if|ifdef|ifndef|else|elif|undef|endif)/)" your_file > > How about this?

Re: World's Largest JAPH

2001-09-12 Thread Ronald J Kimball
On Thu, Sep 13, 2001 at 12:12:09PM +1000, [EMAIL PROTECTED] wrote: > The step 2 program uses a conversion module called Filth. > I have no CPAN experience, and am open to suggestion, but > this module might eventually become CPAN Convert::Filth (??). I'd suggest Acme::Filth, to go with Acme::Blea

Re: World's Largest JAPH

2001-09-09 Thread Ronald J Kimball
On Sun, Sep 09, 2001 at 12:18:22PM +1000, [EMAIL PROTECTED] wrote: > The JAPH below is generated from this program: > open 0; > $/ = undef; > $x = <0>; > close 0; > $x =~ tr/!-~/#/; > print $x; > I noticed this "zero file handle trick" in Acme::Bleach, > but it does not seem to be ment

Re: evaluating assigning to a list in if( ) statement

2001-09-03 Thread Ronald J Kimball
On Mon, Sep 03, 2001 at 09:35:13PM -0400, Lev Selector wrote: > # Folks, just a note. > # I thought that the > #if (EXPR) > # is supposed to evaluate the EXPR in scalar context, right? > # Well, it does so in most cases > # Except when you do an assignment to a list, when > # instead of

Re: World's First JAPH

2001-08-23 Thread Ronald J Kimball
On Thu, Aug 23, 2001 at 02:18:07PM +1000, [EMAIL PROTECTED] wrote: > [EMAIL PROTECTED] wrote: > >> Embedding newlines inside quotes is controversial; > >> doubtless, some golfers and japhers would seek to > >> ban this perhaps shady practice. > > John Porter wrote: > > Absolutely not. Amongst C

Re: World's Largest JAPH

2001-08-20 Thread Ronald J Kimball
On Mon, Aug 20, 2001 at 10:19:30AM +0100, Ian Phillipps wrote: > On Mon, 20 Aug 2001 at 09:55:34 +0100, Matthew Byng-Maddick wrote: > > On Mon, Aug 20, 2001 at 06:53:01PM +1000, [EMAIL PROTECTED] wrote: > > > Does a leading '.' have a special meaning in some mailers?? > > > Does anyone else have '

Re: JAPHs with no unsightly letters or numbers

2001-08-16 Thread Ronald J Kimball
On Thu, Aug 16, 2001 at 12:25:42PM -0400, Selector, Lev Y wrote: > Ronald, > Thank you. > This was good. > Here how it was done, right? > == > > $s1 = '}_).} "*}_} }./}(}_ }}_, (}_+}_,*"'; > $s2 = '/- + *,+ < + :- /:- << :- @'; > $s3

Re: JAPHs with no unsightly letters or numbers

2001-08-16 Thread Ronald J Kimball
Please disregard the previous message. This one contains the correct code. (Damn KDE clipboard!) On Thu, Aug 16, 2001 at 11:10:09AM +1000, [EMAIL PROTECTED] wrote: > I have found all the JAPHs with no alphanumeric > characters both interesting and instructive. > However, none of them write to

  1   2   >