I was just messing around with Quantum::Superpositions, which I've read through a few times now. I can't think of anything useful to do with it, so I've been trying to trick it into solving sudoku puzzles. I can't figure out how to chain logic statements though. It was simple enough to build my sudoku memory structure and start comparing rows, cols and cells in a purely looping iterative way, but this isn't really about that. I'm on a simpler step that follows.
use strict; use Quantum::Superpositions; my $s = any( 1 .. 4 ); $s = $s != 1; $s = $s != 2; my @e = eigenstates( $s ); print "Am I on to something? @e\n";

The eigen states are (helpfully) 3 and 4. Now, suppose I have another superposition that's also any 1 through 4 that isn't equal to $t? Then what? I'd expect ...

my $t = any(1 .. 4); $t = $t != $s;
... to give me a super postion of 1 .. 4, but it gives 3 and 4 instead. Sadly, it's also pretty obvious that it doesn't have the capacity to retain all the implications of $t != $s and $s != 1 and $s != 2 — which would make $t 1 through 4 remembering somehow that it's not equal to $s. I tried one more thing before I realized I either didn't know how to approach the problem, or it simply wasn't possible without magic:
$t = $t != $_ for eigenstates( $s );

Unhelpfully, this makes $t the superposition of 1 and 2, which isn't quite what I was going for... But it at least made me realize I didn't have any idea what to do next.

I'd give up and forget the topic completely, but supposedly perl6 will have this sort of stuff (called junctions), so I'd like to learn more about the kinds of problems you can try to (and will never be able to) solve with this stuff.

Is solving sudoku puzzles with QS and/or junctions even remotely possible?

-Paul


In reply to sudoku via superpositions by jettero

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.