[Tutor] Set changing order of items?

Adam Cripps kabads at gmail.com
Sun Jan 21 15:32:30 CET 2007


On 1/20/07, Kent Johnson <kent37 at tds.net> wrote:
> Adam Cripps wrote:
> > Many thanks all - I've got there in the end, using a tuple inside a
> > set, ditching the question number and then rendering the sum for
> > output in my main gui module.
> >
> > However, this does raise another issue now (which I had thought would
> > happen, but was putting it off until I'd solved the original problem).
> >
> > Basically, the user can choose how many problems are set - i. They can
> > also choose the highest and lowest possible numbers - highest and
> > lowest. With these values, they can now create a scenario which will
> > lock the application - they can choose values with a narrow margin
> > (lowest = 5, highest = 6) and then choose to have 100 of these
> > problems (i=100). Of course, this will mean that my app will now go
> > through that loop trying to find a new combination that no longer is
> > possible.
>
> This is a pretty easy condition to test for - maybe check that the
> number of possible problems in the given range is at least double (or
> some multiple) of the number of problems desired. If not, print an error
> message and have them enter new values.
> >
> > Anyone have any guidance or tips here? How will I create a flag which
> > is raised once the loop becomes infinite?
>
> You could also restrict the loop to, say, twice the number of problems
> desired and give up if after that many loops you don't have the desired
> number.

Kent - completed the check through the former method - by checking the
possibly number of permutations wasn't exceeded.

Many thanks.
-- 
http://www.monkeez.org
PGP key: 0x7111B833


More information about the Tutor mailing list