Skip to content

Commit 03a25bd

Browse files
committed
Minor code cleanup
1 parent 03045c9 commit 03a25bd

File tree

3 files changed

+15
-79
lines changed

3 files changed

+15
-79
lines changed

Puzzle.js

Lines changed: 9 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,14 @@ function Puzzle(givens) {
507507
guessCell = cells[i];
508508
} else {
509509
currentCell = cells[i];
510-
510+
511+
// Choose the cell with the least candidates:
511512
if (currentCell.value === 0 && currentCell.candidates.length < guessCell.candidates.length) {
512513
guessCell = currentCell;
513514
}
515+
516+
// Choose the first empty cell.
517+
// break;
514518
}
515519
}
516520

@@ -557,10 +561,9 @@ function Puzzle(givens) {
557561
return solution;
558562
};
559563

560-
/**
561-
* Returns the solution that occurs first in lexicographical order to the puzzle if firstSolution is true.
562-
* Otherwise returns the solution that occurs last in lexicographical order.
563-
**/
564+
565+
// Returns the solution that occurs first in lexicographical order to the puzzle if firstSolution is true.
566+
// Otherwise returns the solution that occurs last in lexicographical order.
564567
var solve = function solve(givens) {
565568
var stack = [];
566569
var values;
@@ -590,75 +593,4 @@ function Puzzle(givens) {
590593
};
591594

592595
solution = solve(givens);
593-
}
594-
595-
// window.onload = function() {
596-
597-
598-
// var a = [].concat;
599-
// var objWindow = a();
600-
601-
// document.getElementById("hi").innerText = (objWindow) + "";
602-
603-
// alert("Hello World!");
604-
605-
606-
/* _=+!![],$=_+_;$_=[][(![]+'')[$+_]+({}+'')[_]+(!![]+'')[_]+(!![]+'')[+[]]]+'';$$=[]
607-
[({}+'')[$+_+$]+(''+{})[_]+$_[$]+({}+'')[$+_+$]+(![]+'')[_]+(!![]+'')[+[]]];_$=(![
608-
]+'')[_+$+_]+$_[$+''+(_+$)]+(![]+'')[_]+(![]+'')[$];___=(($$()[+[]][_$]("'\\"+_+_+
609-
(+[])+"'"))+(![]+'')[$+$]+(![]+'')[$]+(![]+'')[$]+(''+{})[_]+(''+{})[$+_+$+$]+($$(
610-
)+"")[$*$*$]+(''+{})[_]+(!![]+'')[_]+(![]+'')[$]+$_[$*(_+$+_+$+_)*$]+'!');$$()[+[]
611-
][_$]((![]+'')[_]+(![]+'')[$]+(![]+'')[$+$]+(!![]+'')[_]+(!![]+'')[+[]]+'(___);');
612-
*/
613-
// console.log(a());
614-
// console.log(objWindow);
615-
// var p = [];
616-
// p.push(new Puzzle("530070000600195000098000060800060003400803001700020006060000280000419005000080079")); // singles only
617-
// p.push(new Puzzle("000000000000003085001020000000507000004000100090000000500000073002010000000040009")); // singles and hidden singles only
618-
// p.push(new Puzzle("100920000524010000000000070050008102000000000402700090060000000000030945000071006")); // no guesses
619-
// p.push(new Puzzle("120400300300010050006000100700090000040603000003002000500080700007000005000000098")); // this one needs guesses
620-
// p.push(new Puzzle("000000000000000000000000000000000000000000000000000000000000000000000000000000000")); // blank
621-
622-
// for (var i = 0; i < p.length; i++) {
623-
624-
// console.log("The solution is: " + p[i].toString());
625-
// if(p[i].hasSolution()) {
626-
// console.log("Solved puzzle "+ i + ".");
627-
// } else {
628-
// console.log("Puzzle is unsolved.");
629-
// }
630-
// }
631-
// }
632-
633-
/* function Puzzle(values) {
634-
var cells[];
635-
var guessCell;
636-
var guessCellCandidates;
637-
var solution; // String
638-
639-
this.Cell = function Cell(index, value) {
640-
this.neighbors = [];
641-
this.rowNeighbors = [];
642-
this.columnNeighbors = [];
643-
this.blockNeighbors = [];
644-
this.candidates = [];
645-
this.setValue = function() {}; // Set value. If value equals zero, reset candidates.
646-
this.toString = function() {};
647-
}
648-
649-
var process = function(values) {
650-
// Perform function of grid.
651-
// Reset cells to values.
652-
// Process singles, hidden singles.
653-
// Set guessCell to the index of the cell with the least number of candidates; set guessCellCandidates.
654-
// Return each cell's value concatenated in a string.
655-
};
656-
657-
var isValid = function(values) {}; // Don't count on cell values being accurate (neighbors OK). Use values from parameter.
658-
var isFilled = function(values) { return values.indexOf("0") === -1; };
659-
660-
var solve = function() {
661-
// For each string in stack push the string created by replacing the char at index guessCell.index with the candidates in guessCellCandidates. See solve above.
662-
}
663-
// Initialize cells.
664-
} */
596+
}

Sudoku.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,11 @@ window.onload = function() {
536536

537537
currentInput = currentCell.element.appendChild(document.createElement("input"));
538538
currentInput.type = "text";
539+
540+
if (/android|webos|iphone|ipad|ipod|blackberry/i.test(navigator.userAgent.toLowerCase())) {
541+
currentInput.type = "tel";
542+
}
543+
539544
currentInput.tabIndex = tabIndex;
540545
tabIndex++;
541546

help.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<html>
22
<head>
3-
<title>Sudoku Help</title>
43
<style type="text/css">
54
body {
65
margin: 25px;
@@ -166,4 +165,4 @@ <h2>Button/link descriptions:</h2>
166165
<li><strong>Hint</strong>: Gives a hint for cell that was last selected, up to three hints. Hints are based on the solution.</li>
167166
</ul>
168167
</body>
169-
</html>
168+
</html>

0 commit comments

Comments
 (0)