Function that takes an array of Points (a Type with (x,y) ) and creates an ASCII representation.
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
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] = "#" | |
} | |
//[Y][X] | |
outterArray[0][0] = "s" | |
let strings = outterArray | |
.map({ $0.joined(separator: "")}) | |
.reversed() | |
.joined(separator: "\n") | |
print(strings) | |
return strings | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment