Skip to content

Commit

Permalink
Merge pull request kodecocodes#810 from laurentaylormarshall/swift4.2…
Browse files Browse the repository at this point in the history
…-update

[Swift4.2] Update Comb Sort
  • Loading branch information
kelvinlauKL authored Mar 21, 2019
2 parents ea0fd54 + fdab1a2 commit 3da1288
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
32 changes: 13 additions & 19 deletions Comb Sort/Tests/CombSortTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,20 @@
import XCTest

class CombSortTests: XCTestCase {
var sequence: [Int]!
let expectedSequence: [Int] = [-12, -10, -1, 2, 9, 32, 55, 67, 89, 101]

func testSwift4(){
#if swift(>=4.0)
print("Hello, Swift 4!")
#endif
}
var sequence: [Int]!
let expectedSequence: [Int] = [-12, -10, -1, 2, 9, 32, 55, 67, 89, 101]

override func setUp() {
super.setUp()
sequence = [2, 32, 9, -1, 89, 101, 55, -10, -12, 67]
}
override func setUp() {
super.setUp()
sequence = [2, 32, 9, -1, 89, 101, 55, -10, -12, 67]
}

override func tearDown() {
super.tearDown()
}
override func tearDown() {
super.tearDown()
}

func testCombSort() {
let sortedSequence = combSort(sequence)
XCTAssertEqual(sortedSequence, expectedSequence)
}
func testCombSort() {
let sortedSequence = combSort(sequence)
XCTAssertEqual(sortedSequence, expectedSequence)
}
}
4 changes: 2 additions & 2 deletions Comb Sort/Tests/Tests.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand Down Expand Up @@ -237,7 +237,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
8 changes: 4 additions & 4 deletions Slow Sort/SlowSort.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// SlowSort.swift
//
//
//
// Created by Pope Lukas Schramm (Dabendorf Orthodox Religion) on 16-07-16.
//
Expand All @@ -9,12 +9,12 @@
func slowSort(_ i: Int, _ j: Int, _ numberList: inout [Int]) {
guard if i < j else { return }
let m = (i+j)/2
slowsort(i, m, &numberList)
slowsort(m+1, j, &numberList)
slowSort(i, m, &numberList)
slowSort(m+1, j, &numberList)
if numberList[j] < numberList[m] {
let temp = numberList[j]
numberList[j] = numberList[m]
numberList[m] = temp
}
slowsort(i, j-1, &numberList)
slowSort(i, j-1, &numberList)
}

0 comments on commit 3da1288

Please sign in to comment.