Skip to content

Commit e0a1bf6

Browse files
author
Matthew Judy
committed
Reorganize extensions.
1 parent a923b45 commit e0a1bf6

File tree

5 files changed

+68
-36
lines changed

5 files changed

+68
-36
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//
2+
// <#ChallengeName#>.swift
3+
//
4+
// Created by Author on <#YYYY-MM-DD#>.
5+
//
6+
7+
8+
import ArgumentParser
9+
import Foundation
10+
import Shared
11+
12+
13+
/**
14+
Day 8 : Treetop Tree House
15+
16+
# Part One
17+
18+
<#Challenge Documentation#>
19+
*/
20+
@main
21+
struct <#ChallengeName#>: ParsableCommand
22+
{
23+
/// <#Enumeration for argument which activates "Part Two" behavior#>
24+
enum Mode: String, ExpressibleByArgument, CaseIterable
25+
{
26+
case modeA
27+
case modeB
28+
}
29+
30+
@Option(help: "<#Argument used to activate “Part Two” behavior.#>")
31+
var mode: Mode
32+
}
33+
34+
35+
// MARK: - Command Execution
36+
37+
extension <#ChallengeName#>
38+
{
39+
mutating func run() throws
40+
{
41+
while let inputLine = readLine()
42+
{
43+
print("\(inputLine)")
44+
}
45+
}
46+
}
47+

Sources/Shared/ClosedRange+Covers.swift renamed to Sources/Shared/ClosedRange+Overlap.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//
2-
// File.swift
3-
//
2+
// ClosedRange+Covers.swift
43
//
54
// Created by Matthew Judy on 12/4/22.
65
//
@@ -15,8 +14,10 @@ extension ClosedRange where Bound : Comparable
1514
return (other.clamped(to: self) == other)
1615
}
1716

17+
1818
public func isCoveredBy(_ other: Self) -> Bool
1919
{
2020
return (self.clamped(to: other) == self)
2121
}
2222
}
23+

Sources/Shared/Collection+.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//
2+
// File.swift
3+
//
4+
//
5+
// Created by Matthew Judy on 12/4/23.
6+
//
7+
8+
import Foundation
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
//
2-
// RangeReplaceableCollection+Rotate.swift
2+
// RangeReplaceableCollection+Every.swift
33
//
4-
// Created by Matthew Judy on 2022-12-02.
4+
// Created by Matthew Judy on 12/26/22.
55
//
66

77
import Foundation
88

99

1010
extension RangeReplaceableCollection
1111
{
12+
public func every(from: Index? = nil, through: Index? = nil, nth: Int) -> Self
13+
{
14+
return Self(stride(from: from, through: through, by: nth))
15+
}
16+
17+
1218
public func rotatedLeft(by distance: Int) -> SubSequence
1319
{
1420
// Handle subarrays, which don't necessarily start at 0.
@@ -18,10 +24,12 @@ extension RangeReplaceableCollection
1824
return (self[spliceIndex...] + self[..<spliceIndex])
1925
}
2026

27+
2128
public func rotatedRight(by distance: Int) -> SubSequence
2229
{
2330
// As above, so below.
2431
let spliceIndex = self.index(self.endIndex, offsetBy: (-(distance)), limitedBy: self.startIndex) ?? self.startIndex
2532
return (self[spliceIndex...] + self[..<spliceIndex])
2633
}
2734
}
35+

Sources/Shared/RangeReplaceableCollection+Every.swift

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)