Skip to content

Instantly share code, notes, and snippets.

Created December 9, 2022 18:53
What would you like to do?
Function that takes an array of Points (a Type with (x,y) ) and creates an ASCII representation.
func drawPoints(array:[P], width:Int, height:Int) -> String {
var outterArray:[[String]] = []
for _ in (0..<width) {
outterArray.append((Array(repeating: ".", count:height)))
for point in array {
outterArray[point.y][point.x] = "#"
outterArray[0][0] = "s"
let strings = outterArray
.map({ $0.joined(separator: "")})
.joined(separator: "\n")
return strings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment