poboiko created this revision.
poboiko added a project: Plasma.
Restricted Application added a subscriber: plasma-devel.

REVISION SUMMARY
  Thus fixes bug 358940 <https://bugs.kde.org/show_bug.cgi?id=358940>: fifteen 
puzzle often appears unsolveable.
  There were two issues.
  
  1. Floating point division when determining the row with blank tile (blankRow 
= 2.75 seems weird).
  2. 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.
  
  Clearly, to check if 15 numbers are ordered, one needs 14 (size-2) comparison 
operations.

TEST PLAN
  Played puzzle ~10 times with sizes 2x2, 3x3 and 4x4. 
  Not a single one appeared unsolveable, and after solving it applet confirmed 
I've done it correctly.

REPOSITORY
  R114 Plasma Addons

REVISION DETAIL
  https://phabricator.kde.org/D5913

AFFECTED FILES
  applets/fifteenPuzzle/package/contents/ui/FifteenPuzzle.qml

To: poboiko, #plasma
Cc: plasma-devel, davidedmundson, ZrenBot, spstarr, progwolff, lesliezhai, 
ali-mohamed, jensreuterberg, abetts, sebas, apol, lukas

Reply via email to