Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Q: Junctions & send+more=money
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Markus Laire  
View profile  
 More options Feb 26 2005, 4:59 am
Newsgroups: perl.perl6.language
From: mar...@laire.info (Markus Laire)
Date: Sat, 26 Feb 2005 11:59:52 +0200
Local: Sat, Feb 26 2005 4:59 am
Subject: Q: Junctions & send+more=money
I have two questions about this example code
(taken from http://svn.openfoundry.org/pugs/examples/sendmoremoney.p6)

(btw, a really nice example of how to use junctions - just try to write
this in perl5 :)

I think these should be any(0..9).

How would the if (...) {...} work if there were more than one possible
match to this equation?

How would I rewrite this example to be more general, so that given 3
strings (in this case 'send', 'more', 'money'), the program would give
all possible results for the equation <first string> + <second string> =
<third string>.

--
Markus Laire
<Jam. 1:5-6>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rod Adams  
View profile  
 More options Feb 26 2005, 12:58 pm
Newsgroups: perl.perl6.language
From: r...@rodadams.net (Rod Adams)
Date: Sat, 26 Feb 2005 11:58:43 -0600
Local: Sat, Feb 26 2005 12:58 pm
Subject: Re: Q: Junctions & send+more=money

Markus Laire wrote:
> I have two questions about this example code
> (taken from http://svn.openfoundry.org/pugs/examples/sendmoremoney.p6)

I have a few issues with this code. Or at least observations of how it
differs from the classic "SEND + MORE = MONEY" problem. see below.

Indeed they should. I will assume they are written as such in my
discussion below.

As written, this generates a rather large number of solutions. I do not
see any test to make sure that the individual letters are different. Nor
is there any check to see if all the "e"'s assume the same value.

So what you reach the:

    if ($send + $more == $money) {...}

stage is $send being something equivalent to  any(0000..9999) &
none(0000..0999), only no where near as simplified. Similar values can
be found in $more and $money. Therefore, you're asking something like:
"Are there any two numbers between 1000 and 9999 that together total
between 10000..99999?" The answer is yes, and then you get an error as
you attempt to print a raw junction, if you're lucky, or 9000 "send"
lines, followed by 9000 "more" lines, followed by 90000 "money" lines.

Junctions are _not_ the same as unbound variables in Prolog. They do not
"widdle away" inconsistent values as those inconsistencies are found.
Most of them (all except all()) do not have to use the same value each
time they are evaluated.

If I'm wrong about this interpretation of this code, I apologize. But it
certainly fits my understanding of junctions, which has grown by leaps
and bounds over the last few weeks.

HTH,

-- Rod Adams


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »