This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Place N queens on the chessboard. As a result, no two queens are attacking each other. | |
enum QueenPuzzleSolverError: Error { | |
case negativeSize | |
} | |
class QueenPuzzleSolver { | |
private var route: [Int] = [] | |
private var solutionList: [[Int]] = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Sliding Puzzle | |
*/ | |
class Node<T> { | |
let value: T | |
var next: Node<T>? | |
init(with value: T, next: Node<T>? = nil) { | |
self.value = value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import UIKit | |
class Node<T>: CustomStringConvertible { | |
let value: T | |
var next: Node<T>? | |
init(value: T, next: Node<T>? = nil) { | |
self.value = value | |
self.next = next |