## Day 45: Understanding Chessboard logic

 Feb '22 During the day nr. 45 topic nr. 3 I'm struggling for the first time with understanding logic behind the code. I can't contect the "dots" between the: "for...in..." if (row + column).isMultiple(of: 2) let rect = CGRect(x: startX, y: startY, width: columnsSize, height: rowSize) (black and white chessboard with first top left rectangle being white) My wrong understanding(example): For row = 0 and column = 0 ............if (0 + 0).isMultiple(of: 2) .........is not multiple / 2 For row = 0 and column = 1 .............if (0 + 1).isMultiple(of: 2) .........is not multiple / 2 For row = 1 and column = 0.............. if (1 + 0).isMultiple(of: 2) ..........is not multiple / 2 Following this logic there should be 3 rectangles with the same color next to eachother I assume that if (0 + 0).isMultiple(of: 2) is in fact multiple of 2 because in reality it's row: 1 and column 1 but writen down as a 0 in both cases (1 + 1 multiple of 2). Is that correct? If it's correct then startX = 0, startY = 0 (that's the very corner of the view). How by applying startX = 0, startY = 0 into the : let rect = CGRect(x: startX, y: startY, width: columnsSize, height: rowSize) do we get black rectangles but not in the area attached with the 0,0 coordinations? This is my first post with asking for help in any topic related with programming so forgive me mess if there is some. I hope it's readable. Thank you in advance. ``````struct Checkerboard: Shape { var rows: Int var columns: Int func path(in rect: CGRect) -> Path { var path = Path() let rowSize = rect.height / Double(rows) let columnsSize = rect.width / Double(columns) for row in 0..

SAVE 50% To celebrate WWDC23, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

### Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

You are not logged in