San Diego Perl Mongers

Garrett Casey canetguy at home.com
Thu Dec 28 19:17:36 CST 2000


~sdpm~
During last month's meeting we discussed the need to increase the activity on the mailing list.  One suggestion was simply to post little code challenge.  The idea is that some "thing" is presented to the group and everyone could write their own code and post it to the mailing list.  Perl, of course, will allow an individual to solve a single problem many ways.  This means, as a group, we will most likely have the exact same coding solution presented by two or more people.  Therefore, do not post a solution or code that has already been disseminated to the group. 

Ok, let's start.

I am currently reading "The Pleasure of Finding Things Out."  It is the best short works of Richard P. Feynman.  In chapter 2, Computer Machines in the Future, he talks about reducing the size of computers.  He talks about a NAND gate (meaning NOT-AND).   We can illustrate a NAND gate via Perl with something like $c = !($a and $b); 
 
A problem that he states is that this "gate" is irreversible.  If you only know the output, you cannot recover the input.  For instance, if we know that the output is now 1, we don't know whether it came from A=0, B=1, or A=1, B=0, or A=0, B=0.

He then talks about a reversible gate, where no information is lost


"It has three inputs and three outputs.  Of the outputs, two, A` and B`, are the same as two of the inputs, A and B, but the third input works this way. C' is the same as C unless A and B are both 1, in which case it changes whatever C is.  For instance, if C is 1 it is changed to 0, if C is 0 it is changed to 1 - but these changes only happen if both A and B are 1."

The reversible gate is very easy to code in Perl, so everyone can participate.  The first challenge will be to create a function that takes in 3 values and performs the logic of this reversible gate.  When you are done, email the group with your solution.  Let's see how many different coding solutions the San Diego Perl Mongers can come up with.  REMEMBER, do not provide a solution that has already been posted earlier to the group.


~sdpm~

The posting address is: san-diego-pm-list at hfb.pm.org

List requests should be sent to: majordomo at hfb.pm.org

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.




More information about the San-Diego-pm mailing list