```On 1/26/07, Robert Dober <robert.dober / gmail.com> wrote:
> On 1/26/07, CHubas <CHubas7 / gmail.com> wrote:
> >
> >
> >
> > On Jan 26, 7:46 am, Ruby Quiz <j... / grayproductions.net> wrote:
> > > The three rules of Ruby Quiz:
> > >
> > > 1.  Please do not post any solutions or spoiler discussion for this quiz
> > until
> > > 48 hours have passed from the time on this message.
> > >
> > > 2.  Support Ruby Quiz by submitting ideas as often as you can:
> > >
> > > http://www.rubyquiz.com/
> > >
> > > 3.  Enjoy!
> > >
> > > Suggestion:  A [QUIZ] in the subject of emails about the problem helps
> > everyone
> > message,
> > > if you can.
> > >
> > >
> > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> > >
> > > This quiz was adapted from an ACM programming challenge at the
> > suggestion of
> > > Gavin Kistner.
> > >
> > > Simple math can be done with toothpicks alone.  Positive integers are
> > just a
> > > count of toothpicks so three becomes |||.  We can use two toothpicks
> > together to
> > > build a plus sign (+) or even tilt those slightly to get a
> > multiplication
> > > operator (x).  Putting all of that together, the expression ||x||||+| is
> > another
> > > way to express the number nine.
> > >
> > > This weeks quiz is to write a program that takes a single command-line
> > argument
> > > which will be a positive integer.  Your code should build a toothpick
> > expression
> > > to calculate the number using as few toothpicks as possible.  For
> > example:
> > >
> > >         \$ruby toothpick.rb 9
> > >         |||x||| = 9 (8 toothpicks)
> > >
> > > Don't forget to count those operators!
> > >
> > > Posting toothpick expressions and/or counts for a given number is not
> > spoiler
> > > material.
> >
> > Is there any specific rule to do group expressions? I mean, something
> > like
> > (( III x III ) + IIIII ) X III
> > is valid?
> >
> > Thanks for the quiz.
>
>
> Ah you spoiled my idea I will try yo have a solution allowing for
> parenthesis, imagine a  toothpick bent  like < and >, so I would assume
> <II+III>x<I+IIII> (which is stupid of course) being 20 toothpicks.
> Actually I feel that it will be easier to do a solution allowing for
> parenthesis, but we will see ;)
>

Last I checked it was very hard to bend toothpicks without breaking
them. So your <parenthesis> would require two toothpicks apiece.

<ll+lll>x<l+llll> = 25 (24 toothpicks)

I think the same applies to the exponentiation operator ^ used in an
earlier post.

However, ou could Ruby syntax that one

lllllxxll = 25 (11 toothpicks)
lllll^ll = 25 (9 toothpicks)

But that doesn't really save any toothpicks at all.

James, can we omit toothpicks to represent zeros  ;-)
l _ _ = 100 (1 toothpick)

Blessings,
TwP

```