Skip to content

Commit

Permalink
Sync branch (#809)
Browse files Browse the repository at this point in the history
* Sync docs and metadata (#771)

* Bump actions/checkout from 4.1.7 to 4.2.0 (#772)

Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.7 to 4.2.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@692973e...d632683)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fix avogadro constant (#777)

* Update about.md (#778)

* Update about.md

Fix word-choice error.

* Also make fixes in concept:numbers:introduction.md and exercises:freelancer-rates:introduction.md

* Fix `NESButtons` typo (#779)

* Fix `NESButtons` typo

Just a little typo in the enum name.

* fix other mentions of `NESButtons`

* Bump actions/checkout from 4.2.0 to 4.2.2 (#775)

Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.0 to 4.2.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@d632683...11bd719)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [New Exercise]: Armstrong Numbers (#708)

* Add Armstrong Numbers exercise

* Add author

* [Armstrong number]: Fix formatting (#783)

* Fix formatting

* Fix

* [New Exercise]: Darts (#707)

* Add Darts exercise

* Add author

* Fix

* Sync exercise to problem spec

* Update CI configuration and add Swift Numerics dependency (#806)

* Update CI configuration and add Swift Numerics dependency

* Check if swift6 is available in macos 15

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: András B Nagy <20251272+BNAndras@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mike Shaver <shaver@off.net>
  • Loading branch information
4 people authored Dec 23, 2024
1 parent b5b8374 commit ed4fd10
Show file tree
Hide file tree
Showing 68 changed files with 699 additions and 158 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ on:

jobs:
test:
runs-on: macos-13
runs-on: macos-15
env:
RUNALL: "true"
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Run tests
run: swift test
generator-tests:
Expand All @@ -24,15 +23,15 @@ jobs:
RUNALL: "true"
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Run tests
run: swift test --package-path ./generator
generator-template-tests:
runs-on: macos-15
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Run tests
run: ./bin/test_generator.sh
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ let practiceExerciseTargets: [Target] = practiceExercises.flatMap {
return [
.target(
name:"\($0.pascalCased)",
dependencies: [.product(name: "Numerics", package: "swift-numerics")],
path:"./exercises/practice/\($0)/.meta/Sources"),
.testTarget(
name:"\($0.pascalCased)Tests",
dependencies: [
.target(name:"\($0.pascalCased)")
.target(name:"\($0.pascalCased)"),
.product(name: "Numerics", package: "swift-numerics")
],
path:"./exercises/practice/\($0)/Tests")
]
Expand All @@ -68,5 +70,6 @@ let package = Package(
name: "xswift",
targets: allTargets.filter { $0.type == .regular }.map { $0.name })
],
dependencies: [.package(url: "https://github.com/apple/swift-numerics", from: "1.0.2")],
targets: allTargets
)
2 changes: 1 addition & 1 deletion concepts/dictionaries/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ As [dictionaries][dictionaries] are one of Swift's three primary collection type
```swift
var addresses: Dictionary<String, String> = ["The Munsters": "1313 Mockingbird Lane", "The Simpsons": "742 Evergreen Terrace", "Buffy Summers": "1630 Revello Drive"]
var sequences: [String: [Int]] = ["Euler's totient": [1, 1, 2, 2, 4, 2, 6, 4], "Lazy caterer": [1, 2, 4, 7, 11, 16, 22, 29, 37], "Carmichael": [561, 1105, 1729, 2465, 2821, 6601, 8911, 10585, 15841]]
let constants: = ["pi": 3.14159, "e": 2.71828, "phi": 1.618033, "avogadro": 6.02214076e22]
let constants: = ["pi": 3.14159, "e": 2.71828, "phi": 1.618033, "avogadro": 6.02214076e23]
```

- Empty dictionaries can be written by following the type name of the dictionary by a pair of parenthesis, e.g. `[Int: String]()`, or, if the type can be determined from the context, as just a pair of square brackets surrounding a colon, `[:]`.
Expand Down
2 changes: 1 addition & 1 deletion concepts/dictionaries/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Dictionary literals are written as a series of `key: value` pairs, separated by
```swift
var addresses: Dictionary<String, String> = ["The Munsters": "1313 Mockingbird Lane", "The Simpsons": "742 Evergreen Terrace", "Buffy Summers": "1630 Revello Drive"]
var sequences: [String: [Int]] = ["Euler's totient": [1, 1, 2, 2, 4, 2, 6, 4], "Lazy caterer": [1, 2, 4, 7, 11, 16, 22, 29, 37], "Carmichael": [561, 1105, 1729, 2465, 2821, 6601, 8911, 10585, 15841]]
let constants = ["pi": 3.14159, "e": 2.71828, "phi": 1.618033, "avogadro": 6.02214076e22]
let constants = ["pi": 3.14159, "e": 2.71828, "phi": 1.618033, "avogadro": 6.02214076e23]
var emptyDict1: [Int: Int] = [:]
var emptyDict2 = [Character: String]()
var emptyDict3 = Dictionary<Int, Double>()
Expand Down
2 changes: 1 addition & 1 deletion concepts/enumerations/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ enum NESButton {
}
```

This defines a new type named `NESButtons` with possible values `up`, `down`, `left`, `right`, `a`, `b`, `select`, and `start`. These values can be referred to by following the name of the type with a dot (`.`) and the value. In cases where the type name can be inferred, only the dot and value are needed. These values can then be used like any other values in Swift.
This defines a new type named `NESButton` with possible values `up`, `down`, `left`, `right`, `a`, `b`, `select`, and `start`. These values can be referred to by following the name of the type with a dot (`.`) and the value. In cases where the type name can be inferred, only the dot and value are needed. These values can then be used like any other values in Swift.

```swift
var lastPressed = NESButton.up
Expand Down
2 changes: 1 addition & 1 deletion concepts/enumerations/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ enum NESButton {
}
```

This defines a new type named `NESButtons` with possible values `up`, `down`, `left`, `right`, `a`, `b`, `select`, and `start`. These values can be referred to by following the name of the type with a dot (`.`) and the value. In cases where the type name can be inferred, only the dot and value are needed.
This defines a new type named `NESButton` with possible values `up`, `down`, `left`, `right`, `a`, `b`, `select`, and `start`. These values can be referred to by following the name of the type with a dot (`.`) and the value. In cases where the type name can be inferred, only the dot and value are needed.

## Methods

Expand Down
2 changes: 1 addition & 1 deletion concepts/numbers/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let plancksConstant : Double = 6.62607015e-34 // plancksConstant is a Double

~~~~exercism/caution
In Swift can't mix types in arithmetic operations, so you can't use any arithmetic operator on an `Int` with a `Double` or vice versa.
Thereby you have to do a type conversion first.
Therefore, you have to do a type conversion first.
~~~~

Swift does have a set of [arithmetic operators][arithmetic-operators] that can be used to perform basic mathematical operations.
Expand Down
2 changes: 1 addition & 1 deletion concepts/numbers/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let plancksConstant : Double = 6.62607015e-34 // plancksConstant is a Double

~~~~exercism/caution
In Swift can't mix types in arithmetic operations, so you can't use any arithmetic operator on an `Int` with a `Double` or vice versa.
Thereby you have to do a type conversion first.
Therefore, you have to do a type conversion first.
~~~~

Swift does have a set of [arithmetic operators][arithmetic-operators] that can be used to perform basic mathematical operations.
Expand Down
16 changes: 16 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,14 @@
"transforming"
]
},
{
"slug": "darts",
"name": "Darts",
"uuid": "bdbc6f27-bc98-4edf-9f1d-93dbe49da361",
"practices": [],
"prerequisites": [],
"difficulty": 2
},
{
"slug": "bob",
"name": "Bob",
Expand All @@ -432,6 +440,14 @@
"transforming"
]
},
{
"slug": "armstrong-numbers",
"name": "Armstrong Numbers",
"uuid": "6bd76515-cc17-4238-bc08-7fbdfea14131",
"practices": [],
"prerequisites": [],
"difficulty": 2
},
{
"slug": "grade-school",
"name": "Grade School",
Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/freelancer-rates/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let plancksConstant : Double = 6.62607015e-34 // plancksConstant is a Double

~~~~exercism/caution
In Swift can't mix types in arithmetic operations, so you can't use any arithmetic operator on an `Int` with a `Double` or vice versa.
Thereby you have to do a type conversion first.
Therefore, you have to do a type conversion first.
~~~~

Swift does have a set of [arithmetic operators][arithmetic-operators] that can be used to perform basic mathematical operations.
Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/high-score-board/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Dictionary literals are written as a series of `key: value` pairs, separated by
```swift
var addresses: Dictionary<String, String> = ["The Munsters": "1313 Mockingbird Lane", "The Simpsons": "742 Evergreen Terrace", "Buffy Summers": "1630 Revello Drive"]
var sequences: [String: [Int]] = ["Euler's totient": [1, 1, 2, 2, 4, 2, 6, 4], "Lazy caterer": [1, 2, 4, 7, 11, 16, 22, 29, 37], "Carmichael": [561, 1105, 1729, 2465, 2821, 6601, 8911, 10585, 15841]]
let constants = ["pi": 3.14159, "e": 2.71828, "phi": 1.618033, "avogadro": 6.02214076e22]
let constants = ["pi": 3.14159, "e": 2.71828, "phi": 1.618033, "avogadro": 6.02214076e23]
var emptyDict1: [Int: Int] = [:]
var emptyDict2 = [Character: String]()
var emptyDict3 = Dictionary<Int, Double>()
Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/log-lines/.docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ enum NESButton {
}
```

This defines a new type named `NESButtons` with possible values `up`, `down`, `left`, `right`, `a`, `b`, `select`, and `start`. These values can be referred to by following the name of the type with a dot (`.`) and the value. In cases where the type name can be inferred, only the dot and value are needed.
This defines a new type named `NESButton` with possible values `up`, `down`, `left`, `right`, `a`, `b`, `select`, and `start`. These values can be referred to by following the name of the type with a dot (`.`) and the value. In cases where the type name can be inferred, only the dot and value are needed.

## Methods

Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/accumulate/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
},
"blurb": "Implement the `accumulate` operation, which, given a collection and an operation to perform on each element of the collection, returns a new collection containing the result of applying that operation to each element of the input collection.",
"source": "Conversation with James Edward Gray II",
"source_url": "https://twitter.com/jeg2"
"source_url": "http://graysoftinc.com/"
}
10 changes: 5 additions & 5 deletions exercises/practice/acronym/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Punctuation is handled as follows: hyphens are word separators (like whitespace)

For example:

|Input|Output|
|-|-|
|As Soon As Possible|ASAP|
|Liquid-crystal display|LCD|
|Thank George It's Friday!|TGIF|
| Input | Output |
| ------------------------- | ------ |
| As Soon As Possible | ASAP |
| Liquid-crystal display | LCD |
| Thank George It's Friday! | TGIF |
2 changes: 1 addition & 1 deletion exercises/practice/allergies/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ Now, given just that score of 34, your program should be able to say:
- Whether Tom is allergic to any one of those allergens listed above.
- All the allergens Tom is allergic to.

Note: a given score may include allergens **not** listed above (i.e. allergens that score 256, 512, 1024, etc.).
Note: a given score may include allergens **not** listed above (i.e. allergens that score 256, 512, 1024, etc.).
Your program should ignore those components of the score.
For example, if the allergy score is 257, your program should only report the eggs (1) allergy.
6 changes: 3 additions & 3 deletions exercises/practice/anagram/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Instructions

An anagram is a rearrangement of letters to form a new word: for example `"owns"` is an anagram of `"snow"`.
A word is not its own anagram: for example, `"stop"` is not an anagram of `"stop"`.
Your task is to, given a target word and a set of candidate words, to find the subset of the candidates that are anagrams of the target.

Given a target word and a set of candidate words, this exercise requests the anagram set: the subset of the candidates that are anagrams of the target.
An anagram is a rearrangement of letters to form a new word: for example `"owns"` is an anagram of `"snow"`.
A word is _not_ its own anagram: for example, `"stop"` is not an anagram of `"stop"`.

The target and candidates are words of one or more ASCII alphabetic characters (`A`-`Z` and `a`-`z`).
Lowercase and uppercase characters are equivalent: for example, `"PoTS"` is an anagram of `"sTOp"`, but `StoP` is not an anagram of `sTOp`.
Expand Down
12 changes: 12 additions & 0 deletions exercises/practice/anagram/.docs/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Introduction

At a garage sale, you find a lovely vintage typewriter at a bargain price!
Excitedly, you rush home, insert a sheet of paper, and start typing away.
However, your excitement wanes when you examine the output: all words are garbled!
For example, it prints "stop" instead of "post" and "least" instead of "stale."
Carefully, you try again, but now it prints "spot" and "slate."
After some experimentation, you find there is a random delay before each letter is printed, which messes up the order.
You now understand why they sold it for so little money!

You realize this quirk allows you to generate anagrams, which are words formed by rearranging the letters of another word.
Pleased with your finding, you spend the rest of the day generating hundreds of anagrams.
14 changes: 14 additions & 0 deletions exercises/practice/armstrong-numbers/.docs/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Instructions

An [Armstrong number][armstrong-number] is a number that is the sum of its own digits each raised to the power of the number of digits.

For example:

- 9 is an Armstrong number, because `9 = 9^1 = 9`
- 10 is _not_ an Armstrong number, because `10 != 1^2 + 0^2 = 1`
- 153 is an Armstrong number, because: `153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153`
- 154 is _not_ an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190`

Write some code to determine whether a number is an Armstrong number.

[armstrong-number]: https://en.wikipedia.org/wiki/Narcissistic_number
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Foundation

func isArmstrongNumber(_ number: Int) -> Bool {
let stringNumber = String(number)
let numberLength = stringNumber.count
let sum = stringNumber.compactMap { Int(String($0)) }.reduce(0) { $0 + Int(pow(Double($1), Double(numberLength))) }
return sum == number
}
19 changes: 19 additions & 0 deletions exercises/practice/armstrong-numbers/.meta/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"authors": [
"meatball133"
],
"files": {
"solution": [
"Sources/ArmstrongNumbers/ArmstrongNumbers.swift"
],
"test": [
"Tests/ArmstrongNumbersTests/ArmstrongNumbersTests.swift"
],
"example": [
".meta/Sources/ArmstrongNumbers/ArmstrongNumbersExample.swift"
]
},
"blurb": "Determine if a number is an Armstrong number.",
"source": "Wikipedia",
"source_url": "https://en.wikipedia.org/wiki/Narcissistic_number"
}
20 changes: 20 additions & 0 deletions exercises/practice/armstrong-numbers/.meta/template.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import XCTest
@testable import {{exercise|camelCase}}
class {{exercise|camelCase}}Tests: XCTestCase {
let runAll = Bool(ProcessInfo.processInfo.environment["RUNALL", default: "false"]) ?? false

{% for case in cases %}
{% if forloop.first -%}
func test{{case.description |camelCase }}() {
{% else -%}
func test{{case.description |camelCase }}() throws {
try XCTSkipIf(true && !runAll) // change true to false to run this test
{% endif -%}
{%- if case.expected -%}
XCTAssertTrue(isArmstrongNumber({{case.input.number}}))
{%- else -%}
XCTAssertFalse(isArmstrongNumber({{case.input.number}}))
{%- endif %}
}
{% endfor -%}
}
45 changes: 45 additions & 0 deletions exercises/practice/armstrong-numbers/.meta/tests.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This is an auto-generated file.
#
# Regenerating this file via `configlet sync` will:
# - Recreate every `description` key/value pair
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
# - Preserve any other key/value pair
#
# As user-added comments (using the # character) will be removed when this file
# is regenerated, comments can be added via a `comment` key.

[c1ed103c-258d-45b2-be73-d8c6d9580c7b]
description = "Zero is an Armstrong number"

[579e8f03-9659-4b85-a1a2-d64350f6b17a]
description = "Single-digit numbers are Armstrong numbers"

[2d6db9dc-5bf8-4976-a90b-b2c2b9feba60]
description = "There are no two-digit Armstrong numbers"

[509c087f-e327-4113-a7d2-26a4e9d18283]
description = "Three-digit number that is an Armstrong number"

[7154547d-c2ce-468d-b214-4cb953b870cf]
description = "Three-digit number that is not an Armstrong number"

[6bac5b7b-42e9-4ecb-a8b0-4832229aa103]
description = "Four-digit number that is an Armstrong number"

[eed4b331-af80-45b5-a80b-19c9ea444b2e]
description = "Four-digit number that is not an Armstrong number"

[f971ced7-8d68-4758-aea1-d4194900b864]
description = "Seven-digit number that is an Armstrong number"

[7ee45d52-5d35-4fbd-b6f1-5c8cd8a67f18]
description = "Seven-digit number that is not an Armstrong number"

[5ee2fdf8-334e-4a46-bb8d-e5c19c02c148]
description = "Armstrong number containing seven zeroes"
include = false

[12ffbf10-307a-434e-b4ad-c925680e1dd4]
description = "The largest and last Armstrong number"
include = false
21 changes: 21 additions & 0 deletions exercises/practice/armstrong-numbers/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// swift-tools-version:5.3

import PackageDescription

let package = Package(
name: "ArmstrongNumbers",
products: [
.library(
name: "ArmstrongNumbers",
targets: ["ArmstrongNumbers"])
],
dependencies: [],
targets: [
.target(
name: "ArmstrongNumbers",
dependencies: []),
.testTarget(
name: "ArmstrongNumbersTests",
dependencies: ["ArmstrongNumbers"]),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
func isArmstrongNumber(_ number: Int) -> Bool {
// Write your code for the 'Armstrong Numbers' exercise here.
}
Loading

0 comments on commit ed4fd10

Please sign in to comment.