TODO
TODO:TODO
簡介
TODO

講解
TODO
解答
請務必嘗試解題
請同學務必嘗試自己解題,不要直接看答案。學習程式時最好的學習方法是自己嘗試解題,程式設計不會只有一種寫法,請通過不斷的嘗試和優化來找到屬於自己最好的解答。
| let allCoordinates = world.allPossibleCoordinates
// Create two empty arrays of type [Coordinate].
var island: [Coordinate] = []
var sea: [Coordinate] = []
for coordinate in allCoordinates {
if coordinate.column >= 3 && coordinate.column < 7 && coordinate.row > 3 && coordinate.row < 7 {
island.append(coordinate)
} else {
sea.append(coordinate)
}
}
// For your island, array, place blocks.
for coordinate in island {
for i in 1...4 {
world.place(Block(), at: coordinate)
}
}
// For your sea, array, place water.
for coordinate in sea {
world.removeAllBlocks(at: coordinate)
world.place(Water(), at: coordinate)
}
|
後記
TODO