<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/">
  <channel rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss">
    <title>gmane.comp.lang.perl.qotw.discuss</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss</link>
    <description/>
    <syn:updatePeriod>hourly</syn:updatePeriod>
    <syn:updateFrequency>1</syn:updateFrequency>
    <syn:updateBase>1901-01-01T00:00+00:00</syn:updateBase>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2655"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2654"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2653"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2652"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2651"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2650"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2649"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2648"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2647"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2646"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2645"/>
      </rdf:Seq>
    </items>
    <image rdf:resource="http://gmane.org/img/gmane-25t.png"/>
    <textinput rdf:resource=""/>
  </channel>
  <image rdf:about="http://gmane.org/img/gmane-25t.png">
    <title>Gmane</title>
    <url>http://gmane.org/img/gmane-25t.png</url>
    <link>http://gmane.org</link>
  </image>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2655">
    <title>Perl QOTW #2010-02-22 - Freecell Scans with Short Solutions</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2655</link>
    <description>&lt;pre&gt;IMPORTANT: Please do not post solutions, hints, or other spoilers
until at least 60 hours after the date of this message.  Thanks.

Requests for clarifications and other discussion would be OK.

---------------

Today I'm borrowing the collective wisdom of the Perl Quiz-of-the-Whatever
forum for an algorithmic task I need to accomplish for my own project.
The project in question is Freecell Solver ( http://fc-solve.berlios.de/ ),
which is an automated solver for http://en.wikipedia.org/wiki/FreeCell and 
several other types of card solitaire. 

fc-solve starts from the initial layout of the solitaire game and recurses
into more and more positions, which are counted by the solver's iterations,
until it reaches the final, solved state where all cards were moved to the
foundations.

After a certain number of iterations (which are roughly indicative of 
how long it took it to run), it yields a solution of a certain length ,which 
is desired to be as short as possible. Note that it may also report that it
is unab&lt;/pre&gt;</description>
    <dc:creator>Shlomi Fish</dc:creator>
    <dc:date>2010-02-22T15:31:32</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2654">
    <title>Re: Perl 'Medium' Quiz-of-the-Whatever for 2009-08-11 : Plusified Equations</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2654</link>
    <description>&lt;pre&gt;My last submission was more for clarity than efficiency.  This one is 
a bit more efficient, in generating the list for one side in advance, 
but a bit less clear:

use strict;
use warnings;

my ($left, $right) = &amp;lt; at &amp;gt;ARGV;

my &amp;lt; at &amp;gt;left;
iter( $left,  sub { push &amp;lt; at &amp;gt;left, shift                                     } );
iter( $right, sub { eval == eval $_[0] and print "$_ = $_[0]\n" for &amp;lt; at &amp;gt;left } );

sub iter
{
   my ($side, $cb) = &amp;lt; at &amp;gt;_;

   my $count = length($side) - 1;
   for my $num ( 0 .. 2**$count - 1)
   {
     my $i = $count;
     (my $side = $side) =~ s/(.)(?=.)/$1 . ($num &amp;amp; 1 &amp;lt;&amp;lt; --$i ? '+' : '')/ge;
     $cb-&amp;gt;( $side );
   }
}

&lt;/pre&gt;</description>
    <dc:creator>Peter Scott</dc:creator>
    <dc:date>2009-10-13T04:40:37</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2653">
    <title>Re: Perl 'Medium' Quiz-of-the-Whatever for 2009-08-11 :  Plusified Equations</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2653</link>
    <description>&lt;pre&gt;Here's my solution, which also uses binary number counting to decide 
where to put the + signs.  I have been unable to remove the duplicated 
code without making it much less clear and no shorter.

use strict;
use warnings;

my ($left, $right) = &amp;lt; at &amp;gt;ARGV;

my ($count_left, $count_right) = map { length() - 1 } ($left, $right);

for my $left_num ( 0 .. 2**$count_left - 1)
{
   my $left = $left;
   my $i = $count_left;
   $left =~ s/(.)(?=.)/$1 . ($left_num &amp;amp; 1 &amp;lt;&amp;lt; --$i ? '+' : '')/ge;

   for my $right_num ( 0 .. 2**$count_right - 1 )
   {
     my $right = $right;
     my $i = $count_right;
     $right =~ s/(.)(?=.)/$1 . ($right_num &amp;amp; 1 &amp;lt;&amp;lt; --$i ? '+' : '')/ge;
     print "$left == $right\n" if eval $left == eval $right;
   }
}
&lt;/pre&gt;</description>
    <dc:creator>Peter Scott</dc:creator>
    <dc:date>2009-10-12T19:54:23</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2652">
    <title>Re: Perl 'Medium' Quiz-of-the-Whatever for 2009-08-11 : PlusifiedEquations</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2652</link>
    <description>&lt;pre&gt;http://www.flowersofpeace.com/telephone_code.html

Since I, by default, use +, - * and / I also make sure not to divide by zero :)



On Wed, Oct 7, 2009 at 1:50 PM, Jeff Yoak &amp;lt;jeff-orzAD85Mt8U&amp;lt; at &amp;gt;public.gmane.org&amp;gt; wrote:

&lt;/pre&gt;</description>
    <dc:creator>Josh Narins</dc:creator>
    <dc:date>2009-10-08T00:04:21</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2651">
    <title>Re: Perl 'Medium' Quiz-of-the-Whatever for 2009-08-11 : Plusified Equations</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2651</link>
    <description>&lt;pre&gt;Somehow I missed the original statement of the problem, but these  
solutions, perhaps with a slight mod in some cases, could be used to  
solve the current problem at http://mathfactor.uark.edu/ .  As the  
poster of that particular problem, I can say that anyone who wanted to  
share code with a solution would be welcome.

Cheers,
Jeff

On Oct 7, 2009, at 9:55 AM, Ronald J Kimball wrote:



&lt;/pre&gt;</description>
    <dc:creator>Jeff Yoak</dc:creator>
    <dc:date>2009-10-07T17:50:52</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2650">
    <title>Re: Perl 'Medium' Quiz-of-the-Whatever for 2009-08-11 : Plusified Equations</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2650</link>
    <description>&lt;pre&gt;Yay, the list is back.  Here's my solution.  I generate the plusified
expressions iteratively by doing repeated increments, treating the
expression itself as a binary string with '+' and '' representing 1 and 0:

  s/(.*\d)(\d.*)/my $x = $2; $x =~ tr!+!!d; "$1+$x"/e

To be more efficient, I don't store both sets of results.  First, I
calculate and store the results for the second expression only.  Then, I
generate results one at a time for the first expression, print any matches
immediately, and throw away the result.  This gives the correct order of
output without any sorting.

#!perl

use strict;
use warnings;

&amp;lt; at &amp;gt;ARGV == 2
  or die usage();

foreach (&amp;lt; at &amp;gt;ARGV) {
  /^\d+\z/
    or die usage();
}

my %p2;

my ($p1, $p2) = &amp;lt; at &amp;gt;ARGV;

do {
  push &amp;lt; at &amp;gt;{ $p2{do_eval($p2)} }, $p2;
} while ($p2 = next_plusify($p2));

do {
  if (my $match = $p2{do_eval($p1)}) {
    print "$p1 = $_\n" for &amp;lt; at &amp;gt;$match;
  }
} while ($p1 = next_plusify($p1));

sub next_plusify {
  my ($exp) = &amp;lt; at &amp;gt;_;
  $exp =~ s/(.*\d)(\d.*)/my $x = $2; $x =~ tr!+!!d; "&lt;/pre&gt;</description>
    <dc:creator>Ronald J Kimball</dc:creator>
    <dc:date>2009-10-07T16:55:00</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2649">
    <title>Re: Perl 'Medium' Quiz-of-the-Whatever for 2009-08-11 : Plusified Equations</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2649</link>
    <description>&lt;pre&gt;
I have a few solutions. The first one I wrote in Perl using Moose and a lot of 
stuff that will be suitable for C++. I later translated it to C++ because the 
kid who asked me for a solution doesn't know Perl. Then I wrote a different 
Perl implementation without using Moose, but with using eval. The first Perl 
solution was kinda slow , the C++ version was very fast, and the third Perl 
implementation was somewhere in between.

Moose version:

[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
#!/usr/bin/perl 

package State::Side;

use strict;
use warnings;

use Moose;

has 'last_digits' =&amp;gt; (is =&amp;gt; "rw", isa =&amp;gt; "Str");
has 'last_sum' =&amp;gt; (is =&amp;gt; "rw", isa =&amp;gt; "Int");
has 'next_digits' =&amp;gt; (is =&amp;gt; "rw", isa =&amp;gt; "Str");
has 'terminator_cb' =&amp;gt; (is =&amp;gt; "rw", isa =&amp;gt; "CodeRef");
has 'formula' =&amp;gt; (is =&amp;gt; "rw", isa =&amp;gt; "Str");

sub recurse
{
    my $self = shift;

    my $num_left = length($self-&amp;gt;next_digits()) ;

    if ($num_left == 0)
    {
        $self-&amp;gt;last_sum(
            $self-&amp;gt;last_sum() + $self-&amp;gt;last_digits()
        );
  &lt;/pre&gt;</description>
    <dc:creator>Shlomi Fish</dc:creator>
    <dc:date>2009-10-07T13:20:15</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2648">
    <title>Re: Perl 'Medium' Quiz-of-the-Whatever for 2009-08-11 : PlusifiedEquations</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2648</link>
    <description>&lt;pre&gt;I'll put the code up online after I get home from work today at
http://www.flowersofpeace.com/telephone_code.html

On Wed, Oct 7, 2009 at 6:36 AM, Josh Narins &amp;lt;josh.narins-Re5JQEeQqe8AvxtiuMwx3w&amp;lt; at &amp;gt;public.gmane.org&amp;gt; wrote:

&lt;/pre&gt;</description>
    <dc:creator>Josh Narins</dc:creator>
    <dc:date>2009-10-07T10:37:29</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2647">
    <title>Re: Perl 'Medium' Quiz-of-the-Whatever for 2009-08-11 : PlusifiedEquations</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2647</link>
    <description>&lt;pre&gt;I set up my solution about a half year before the contest was
announced, although I would prefer if no one requests any answers to
future contests at this time.

Mine started when I noticed that my telephone number was a true
equation. Someone mentioned at work that the current calendar day was
a perfect square, or something quite like that, I mentioned my
telephone number, and someone asked for a programmatic solution.

My solution allows up to eight operators, +, -, *, /, **, ^, &amp;amp; and I,
but as a party trick, the first four are the default. It's also a
recursive solution around the number of digits, so you can blow out
your memory if you could think of some more operators.

Like the previous answer, I use eval. I also skip all numbers that
begin with 0 but basically because this is designed as a party trick,
and some people simply don't appreciate being told 1+01=2. I also
eliminate 0.

I also didn't care where the = was, so I try it at all meaningful locations.

Since it is recursive, I currently limit it&lt;/pre&gt;</description>
    <dc:creator>Josh Narins</dc:creator>
    <dc:date>2009-10-07T10:36:37</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2646">
    <title>Re: Perl 'Medium' Quiz-of-the-Whatever for 2009-08-11 : Plusified Equations</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2646</link>
    <description>&lt;pre&gt;Hello Shlomi,

I have heard that 'a thousand monkeys at a thousand
typewriters will eventually type out the entire works
of Shakespeare'. So, I put my best team of monkeys
on this problem and it resulted in the program below.  :-)

This was a good exercise. My solution saw that
the '+' signs distributed between the numbers
as a power set.

For example, for the number 7637, I first
modified it to be '7 6 3 7', (with 3 spaces as placeholders).
The power set distributing '+'s for this number would be:
000
001
010
011
100
101
110
111

There are 8, (2**3), ways the plus sign could be
distributed. To generate the 8 expressions, I
tested the binary representation (above). If the bit was 1,
I replaced the space with a '+' and if not, removed
the space (placeholder). The results are:
7637
763+7
76+37
76+3+7
7+637
7+63+7
7+6+37
7+6+3+7

Then, I used string 'eval' to get the sum and placed
it and the expression in the %sums hash.

 $sums{$number}{$sum}{$expr} = ();

After calculating all the sums, I found a match If
a &lt;/pre&gt;</description>
    <dc:creator>Chris Charley</dc:creator>
    <dc:date>2009-10-07T02:31:03</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2645">
    <title>Perl 'Medium' Quiz-of-the-Whatever for 2009-08-11 : Plusified Equations</title>
    <link>http://permalink.gmane.org/gmane.comp.lang.perl.qotw.discuss/2645</link>
    <description>&lt;pre&gt;IMPORTANT: Please do not post solutions, hints, or other spoilers
until at least 60 hours after the date of this message.  Thanks.

---------------

We are given two positive integers $L and $R we need to find Plusified 
expressions of both for which Eval($E_L) == Eval($E_R). So what is a plusified 
expression? It is an expression where we can choose whether to add a single 
"+" between any consecutive digit. So for example the number 123 has the 
following plusified expression:

* 123
* 12+3
* 1+23
* 1+2+3


So if we are given 123 and 96 we can form the following plusified equation:

* 12+3 == 9+6

Your mission is to write a Perl program (or an equivalent program in any 
programming language) that will find all solutions to the plusified equation 
of two numbers given as input. To normalise the output we'll rule that:

1. The equations should be given one at each line.

2. They will be sorted so consecutive digits will take precedence over "+"'s.

3. A "+" has no surrounding spaces.

4. The = sign does have&lt;/pre&gt;</description>
    <dc:creator>Shlomi Fish</dc:creator>
    <dc:date>2009-08-11T14:55:06</dc:date>
  </item>
  <textinput rdf:about="http://search.gmane.org/?group=$group=gmane.comp.lang.perl.qotw.discuss">
    <title>Search Engine</title>
    <description>Search the mailing list at Gmane</description>
    <name>query</name>
    <link>http://search.gmane.org/?group=$group=gmane.comp.lang.perl.qotw.discuss</link>
  </textinput>
</rdf:RDF>

