import Foundation extension Array { mutating func shuffle() { guard count > 1 else { return } for i in 0.. Bool { return inBounds(value:testX, upper:self.x) && inBounds(value:testY, upper:self.y) } private func inBounds(value:Int, upper:Int) -> Bool { return (value >= 0) && (value < upper) } func display() { let cellWidth = 3 for j in 0.. String { var line = "" for direction in Direction.allDirections { if (value & direction.rawValue) != 0 { line += direction.char } } return line } } let x = 20 let y = 10 let maze = MazeGenerator(x, y) maze.display()