Re: CSSCGC 2005 Update and Reminder



On Thu, 2005-06-30 at 11:04 +0100, Chris Young wrote:
> On Wed, 29 Jun 2005 16:18:58 GMT da kidz on comp.sys.sinclair were rappin'
> to MC Paul F. Johnson:
>
> > Soduko - well, it would be nice if it ever generated a puzzle instead of
> > getting to 99% and saying "Impossible solution". I'd actually be
> > interested in seeing the listing for this, but I can't get Fuse to
> > interupt it!
>
> Believe me, the code for the geenration routine is 100% genuine - it
> doesn't just print a progress bar and then say "impossible solution",
> unless it really is impossible.
>
> Unfortunately I've not seen it actually generate one yet, so the game
> code is untested.

Let's look at the logic...

Create a couple of loops, set a random value into t and a counter.
Create a new loop to text the first number of the array - the loop goes
as far as the x parameter(n = 1 to 1 to start)
Test if the random number = anything in the array. If it does, generate
again without increasing x.
Do again for the second parameter. The problem here though is that the
first test is performed again even though it originally passed. D'oh!

Okay, let's assume that somehow we've managed to get past that bit of
spaghetti

Set two vars to be the value of the original loop - 1 / 3. So if x = 1,
i = (1 - 1) / 3 and j = (1 - 1) / 3. The loops go from these values + 1
to these values * 3. Okay that's fine for the first loop.
Quick test to see if the random value occurs anywhere in the first 9 x 9
grid. If it does, let's regenerate the entire bloody grid again.

If, somehow, these tests have been passed, actually put the value of the
random number into the grid array and increment x and y (the original
loops).

It's little wonder the grid never gets generated!

TTFN

Paul
--
"The city of Washington was built on a stagnant swamp some 200 years ago
and very little has changed; it stank then and it stinks now. Only
today, it is the fetid stench of corruption that hangs in the air" -
Simpson, L. Mr Lisa Goes to Washington (1991) Fox. 8F01 (Sep).

.



Relevant Pages

  • Re: Help needed with arrays
    ... int main ... >> Really good idea to let Paul solve his problem himself. ... > The problem I have now is writing a loop statement to fill the array ...
    (microsoft.public.vc.language)
  • Re: Factoring iteration
    ... Now it's cool that the double-nested loop turns into just the one line ... grid iterator class, where the actual per-item action is a method, ... a single 1D loop is covering the complete array. ... All masks with only one bit set represent a solution for that field. ...
    (comp.lang.forth)
  • Re: In search for a better algorithm
    ... Paul E. Black wrote: ... You could move the array ... indexing out of the loop for a little speed, ... You can change the other two loop similarly. ...
    (comp.programming.contests)
  • Referencing an object from a string within an array
    ... string) by referring to it with a string. ... I have a 9x9 grid that I have created strings to represent the data. ... I create an array for each object within the grid. ... Then I can then create a loop to parse each of the arrays and run the ...
    (microsoft.public.vb.syntax)
  • Re: Replace value in Arraylist
    ... > I have an arraylist and I want to loop through the array and replace all the ... > parameter old value cannot be of zero length in line 1". ... Paul ...
    (microsoft.public.dotnet.languages.csharp)