<table><tr><td style="">poboiko created this revision.<br />poboiko added a project: Plasma.<br />Restricted Application added a subscriber: plasma-devel.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D5913" rel="noreferrer">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>Thus fixes <a href="https://bugs.kde.org/show_bug.cgi?id=358940" class="remarkup-link" target="_blank" rel="noreferrer">bug 358940</a>: fifteen puzzle often appears unsolveable.<br />
There were two issues.</p>

<ol class="remarkup-list">
<li class="remarkup-list-item">Floating point division when determining the row with blank tile (blankRow = 2.75 seems weird).</li>
<li class="remarkup-list-item">Even after fixing the first issue, applet didn't want to confirm that I've solved the puzzle. Seems like corresponding check was wrong: indeed, if one has solved 4x4 board (size=16, so pieces[i] = {1,2,...,15,0}), comparison with i=15 corresponds to 15>0, which is always true.</li>
</ol>

<p>Clearly, to check if 15 numbers are ordered, one needs 14 (size-2) comparison operations.</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>Played puzzle ~10 times with sizes 2x2, 3x3 and 4x4. <br />
Not a single one appeared unsolveable, and after solving it applet confirmed I've done it correctly.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R114 Plasma Addons</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D5913" rel="noreferrer">https://phabricator.kde.org/D5913</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>applets/fifteenPuzzle/package/contents/ui/FifteenPuzzle.qml</div></div></div><br /><div><strong>To: </strong>poboiko, Plasma<br /><strong>Cc: </strong>plasma-devel, davidedmundson, ZrenBot, spstarr, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, lukas<br /></div>