Skip to content

Commit 3da1288

Browse files
authored
Merge pull request #810 from laurentaylormarshall/swift4.2-update
[Swift4.2] Update Comb Sort
2 parents ea0fd54 + fdab1a2 commit 3da1288

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

Comb Sort/Tests/CombSortTests.swift

+13-19
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,20 @@
99
import XCTest
1010

1111
class CombSortTests: XCTestCase {
12-
var sequence: [Int]!
13-
let expectedSequence: [Int] = [-12, -10, -1, 2, 9, 32, 55, 67, 89, 101]
14-
15-
func testSwift4(){
16-
#if swift(>=4.0)
17-
print("Hello, Swift 4!")
18-
#endif
19-
}
12+
var sequence: [Int]!
13+
let expectedSequence: [Int] = [-12, -10, -1, 2, 9, 32, 55, 67, 89, 101]
2014

21-
override func setUp() {
22-
super.setUp()
23-
sequence = [2, 32, 9, -1, 89, 101, 55, -10, -12, 67]
24-
}
15+
override func setUp() {
16+
super.setUp()
17+
sequence = [2, 32, 9, -1, 89, 101, 55, -10, -12, 67]
18+
}
2519

26-
override func tearDown() {
27-
super.tearDown()
28-
}
20+
override func tearDown() {
21+
super.tearDown()
22+
}
2923

30-
func testCombSort() {
31-
let sortedSequence = combSort(sequence)
32-
XCTAssertEqual(sortedSequence, expectedSequence)
33-
}
24+
func testCombSort() {
25+
let sortedSequence = combSort(sequence)
26+
XCTAssertEqual(sortedSequence, expectedSequence)
27+
}
3428
}

Comb Sort/Tests/Tests.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
SDKROOT = macosx;
188188
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
189189
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
190-
SWIFT_VERSION = 4.0;
190+
SWIFT_VERSION = 4.2;
191191
};
192192
name = Debug;
193193
};
@@ -237,7 +237,7 @@
237237
MTL_ENABLE_DEBUG_INFO = NO;
238238
SDKROOT = macosx;
239239
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
240-
SWIFT_VERSION = 4.0;
240+
SWIFT_VERSION = 4.2;
241241
};
242242
name = Release;
243243
};

Slow Sort/SlowSort.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// SlowSort.swift
3-
//
3+
//
44
//
55
// Created by Pope Lukas Schramm (Dabendorf Orthodox Religion) on 16-07-16.
66
//
@@ -9,12 +9,12 @@
99
func slowSort(_ i: Int, _ j: Int, _ numberList: inout [Int]) {
1010
guard if i < j else { return }
1111
let m = (i+j)/2
12-
slowsort(i, m, &numberList)
13-
slowsort(m+1, j, &numberList)
12+
slowSort(i, m, &numberList)
13+
slowSort(m+1, j, &numberList)
1414
if numberList[j] < numberList[m] {
1515
let temp = numberList[j]
1616
numberList[j] = numberList[m]
1717
numberList[m] = temp
1818
}
19-
slowsort(i, j-1, &numberList)
19+
slowSort(i, j-1, &numberList)
2020
}

0 commit comments

Comments
 (0)