Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Sudoku puzzles solved using Regular Expressions

by GrandFather (Sage)
on Jun 30, 2005 at 05:36 UTC ( #471224=note: print w/replies, xml ) Need Help??


in reply to Re^2: Sudoku puzzles solved using Regular Expressions
in thread Sudoku puzzles solved using Regular Expressions

I had a play with your code to try and fix the problem, but headed off in a much less elegant direction than you did by adding a $grid_c vector and another nested loop.

It got rather messy rather quickly. :-(


Perl is Huffman encoded by design.
  • Comment on Re^3: Sudoku puzzles solved using Regular Expressions

Replies are listed 'Best First'.
Re^4: Sudoku puzzles solved using Regular Expressions
by ikegami (Pope) on Jun 30, 2005 at 05:42 UTC

    Yeah, there are diminishing returns to adding more shortcuts.

    Technically, $grid_v is not needed at all.

    return if index(substr($grid_v, $x*$size, $size), $n) >= 0;

    can be written as

    foreach my $y_ (0 .. $size-1) { return if substr($grid_h, $y_*$size+$x, 1) eq $n; }

    I just thought the former would be faster, even though we must constantly make copies of $grid_v in addition to $grid_h.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://471224]
help
Chatterbox?
[Discipulus]: my last linux experience was with redhad 5.6 and occasionally with partedmagic.. i need to relearn everything.. :=(
[choroba]: command line FTW!
[marto]: good morning all, sane dots all round

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2016-12-07 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (125 votes). Check out past polls.