-
-
Notifications
You must be signed in to change notification settings - Fork 159
[Swift 6]: Add ranges concept #823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Hello 👋 Thanks for your PR. This repo does not currently have dedicated maintainers. Our cross-track maintainers team will attempt to review and merge your PR, but it will likely take longer for your PR to be reviewed. If you enjoy contributing to Exercism and have a track-record of doing so successfully, you might like to become an Exercism maintainer for this track. Please feel free to ask any questions, or chat to us about anything to do with this PR or the reviewing process on the Exercism forum. (cc @exercism/cross-track-maintainers) |
a7aec52
to
6908429
Compare
concepts/ranges/about.md
Outdated
|
||
| Method | Description | Example | | ||
| ----------------------- | ----------------------------------------------------------------------- | ------------------------------------- | | ||
| `count` | Returns the size of the range | `(1...5).count // returns 5` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the columns line up?
Co-authored-by: Isaac Good <[email protected]>
Co-authored-by: Isaac Good <[email protected]>
Co-authored-by: Isaac Good <[email protected]>
Co-authored-by: Isaac Good <[email protected]>
Co-authored-by: Isaac Good <[email protected]>
Co-authored-by: Isaac Good <[email protected]>
concepts/ranges/.meta/config.json
Outdated
@@ -0,0 +1,7 @@ | |||
{ | |||
"blurb": "Optionals can be used to represent the possible absence of a value.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look like a ranges
blurb.
concepts/ranges/about.md
Outdated
| `count` | Returns the size of the range | `(1...5).count // returns 5` | | ||
| [`contains`][contains] | Returns `true` if the range includes the given value, otherwise `false` | `(1...5).contains(3) // Returns true` | | ||
|
||
## Endless & beginless ranges |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Endless & beginless ranges | |
## Endless and beginless ranges |
concepts/ranges/introduction.md
Outdated
|
||
```swift | ||
let range = 1...5 | ||
let array = Array(range) // Returns [1, 2, 3, 4, 5] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let array = Array(range) // Returns [1, 2, 3, 4, 5] | |
let array = Array(range) | |
// Returns [1, 2, 3, 4, 5] |
concepts/ranges/introduction.md
Outdated
|
||
```swift | ||
let array = [1, 2, 3, 4, 5] | ||
let slice = array[1...3] // Returns [2, 3, 4] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let slice = array[1...3] // Returns [2, 3, 4] | |
let slice = array[1...3] | |
// Returns [2, 3, 4] |
concepts/ranges/about.md
Outdated
|
||
## Range methods | ||
|
||
Ranges do have a set of methods that can be used to work with them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ranges do have a set of methods that can be used to work with them. | |
Ranges have a set of methods that can be used to work with them. |
The chess game will be played on an eight-square wide and eight-square long board. | ||
The squares are identified by a letter and a number. | ||
|
||
## 1. Define rank & file range |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## 1. Define rank & file range | |
## 1. Define rank and file range |
The game will have to check if a square is valid. | ||
A square is valid if the rank and file are within the ranges of the ranks and files. | ||
|
||
Define the `isValidSquare(rank:file:)` method that takes the arguments `rank` that holds an int of the rank and `file` that holds a char of the file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is file
a char, character or String?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String, I relized I wrote the exercise but while implementing I changed it without updating the docs
The squares are formed as a string of the rank and file, e.g. "1A", "8B", "4G", etc. | ||
To get the row of a square, the game will have to calculate the index of the first square of the row. | ||
|
||
Define the `getRow(rank:)` method that takes the argument `rank` that holds an int of the rank. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define the `getRow(rank:)` method that takes the argument `rank` that holds an int of the rank. | |
Define the `getRow(rank:)` method that takes the argument `rank` that holds an `int` of the rank. |
```swift | ||
let board = ["1A", "1B", "1C", "1D", "1E", "1F", "1G", "1H", "2A", ..., "8H"] | ||
getRow(board, rank: 1) | ||
// returns ["1A", "1B", "1C", "1D", "1E", "1F", "1G", "1H"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// returns ["1A", "1B", "1C", "1D", "1E", "1F", "1G", "1H"] | |
// Returns ["1A", "1B", "1C", "1D", "1E", "1F", "1G", "1H"] |
|
||
```swift | ||
let array = [1, 2, 3, 4, 5] | ||
let slice = array[1...3] // Returns [2, 3, 4] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't match the above intro doc
TODO:
Add hints file