From 9f38465199328cb708996f863492acc600c64498 Mon Sep 17 00:00:00 2001 From: Bob DeLaurentis Date: Mon, 31 Jul 2017 12:05:59 -0700 Subject: [PATCH 01/10] Update Monty Hall Problem to Swift 4 Updated to work with Swift 4 and Xcode 9.0b4. --- Monty Hall Problem/MontyHall.playground/Contents.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Monty Hall Problem/MontyHall.playground/Contents.swift b/Monty Hall Problem/MontyHall.playground/Contents.swift index bcdafd137..4bfff2340 100644 --- a/Monty Hall Problem/MontyHall.playground/Contents.swift +++ b/Monty Hall Problem/MontyHall.playground/Contents.swift @@ -1,5 +1,10 @@ //: Playground - noun: a place where people can play +// last checked with Xcode 9.0b4 +#if swift(>=4.0) + print("Hello, Swift 4!") +#endif + import Foundation func random(_ n: Int) -> Int { @@ -43,7 +48,7 @@ func playRound() { } // Run the simulation a large number of times. -for i in 1...5000 { +for _ in 1...5000 { playRound() } From 0b097d82979cd624549154b39442860285923441 Mon Sep 17 00:00:00 2001 From: Bob DeLaurentis Date: Mon, 31 Jul 2017 12:10:24 -0700 Subject: [PATCH 02/10] Update Minimum Edit Distance to Swift 4 Updated to work with Swift 4 and Xcode 9.0b4. --- .../MinimumEditDistance.playground/Contents.swift | 9 ++++++++- .../MinimumEditDistance.playground/contents.xcplayground | 0 Minimum Edit Distance/README.markdown | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) mode change 100755 => 100644 Minimum Edit Distance/MinimumEditDistance.playground/Contents.swift mode change 100755 => 100644 Minimum Edit Distance/MinimumEditDistance.playground/contents.xcplayground diff --git a/Minimum Edit Distance/MinimumEditDistance.playground/Contents.swift b/Minimum Edit Distance/MinimumEditDistance.playground/Contents.swift old mode 100755 new mode 100644 index 238afeb9b..479815df7 --- a/Minimum Edit Distance/MinimumEditDistance.playground/Contents.swift +++ b/Minimum Edit Distance/MinimumEditDistance.playground/Contents.swift @@ -1,3 +1,10 @@ +// Minimum Edit Distance + +// last checked with Xcode 9.0b4 +#if swift(>=4.0) +print("Hello, Swift 4!") +#endif + extension String { public func minimumEditDistance(other: String) -> Int { @@ -25,7 +32,7 @@ extension String { } else { // minimum of the cost of insertion, deletion, or substitution // added to the already computed costs in the corresponding cells - matrix[i + 1][j + 1] = min(matrix[i][j] + 1, matrix[i + 1][j] + 1, matrix[i][j + 1] + 1) + matrix[i + 1][j + 1] = Swift.min(matrix[i][j] + 1, matrix[i + 1][j] + 1, matrix[i][j + 1] + 1) } } } diff --git a/Minimum Edit Distance/MinimumEditDistance.playground/contents.xcplayground b/Minimum Edit Distance/MinimumEditDistance.playground/contents.xcplayground old mode 100755 new mode 100644 diff --git a/Minimum Edit Distance/README.markdown b/Minimum Edit Distance/README.markdown index 905b358ae..b8880b2d4 100755 --- a/Minimum Edit Distance/README.markdown +++ b/Minimum Edit Distance/README.markdown @@ -45,7 +45,7 @@ for (i, selfChar) in self.characters.enumerated() { } else { // minimum of the cost of insertion, deletion, or substitution // added to the already computed costs in the corresponding cells - matrix[i + 1][j + 1] = min(matrix[i][j] + 1, matrix[i + 1][j] + 1, matrix[i][j + 1] + 1) + matrix[i + 1][j + 1] = Swift.min(matrix[i][j] + 1, matrix[i + 1][j] + 1, matrix[i][j + 1] + 1) } } } From 4c340abda42967ada0a272ff5cec4ae2fa065bd5 Mon Sep 17 00:00:00 2001 From: Bob DeLaurentis Date: Mon, 31 Jul 2017 12:14:08 -0700 Subject: [PATCH 03/10] Update Ring Buffer to Swift 4 Updated to Swift 4 and Xcode 9.0b4. No changes necessary. --- Ring Buffer/RingBuffer.playground/Contents.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Ring Buffer/RingBuffer.playground/Contents.swift b/Ring Buffer/RingBuffer.playground/Contents.swift index 29b9917a0..5c699f191 100644 --- a/Ring Buffer/RingBuffer.playground/Contents.swift +++ b/Ring Buffer/RingBuffer.playground/Contents.swift @@ -1,5 +1,10 @@ //: Playground - noun: a place where people can play +// last checked with Xcode 9.0b4 +#if swift(>=4.0) +print("Hello, Swift 4!") +#endif + public struct RingBuffer { fileprivate var array: [T?] fileprivate var readIndex = 0 From b26a44ccead4c51f0c4b1d31e0a0192bb3cea6d6 Mon Sep 17 00:00:00 2001 From: Bob DeLaurentis Date: Mon, 31 Jul 2017 12:16:45 -0700 Subject: [PATCH 04/10] Update Run-Length Encoding to Swift 4 Updated to Swift 4 and Xcode 9.0b4. No changes necessary. --- Run-Length Encoding/RLE.playground/Contents.swift | 5 +++++ Run-Length Encoding/RLE.playground/timeline.xctimeline | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 Run-Length Encoding/RLE.playground/timeline.xctimeline diff --git a/Run-Length Encoding/RLE.playground/Contents.swift b/Run-Length Encoding/RLE.playground/Contents.swift index 26f7dca48..fc2d82505 100644 --- a/Run-Length Encoding/RLE.playground/Contents.swift +++ b/Run-Length Encoding/RLE.playground/Contents.swift @@ -1,5 +1,10 @@ //: Playground - noun: a place where people can play +// last checked with Xcode 9.0b4 +#if swift(>=4.0) +print("Hello, Swift 4!") +#endif + import Foundation let originalString = "aaaaabbbcdeeeeeeef" diff --git a/Run-Length Encoding/RLE.playground/timeline.xctimeline b/Run-Length Encoding/RLE.playground/timeline.xctimeline deleted file mode 100644 index bf468afec..000000000 --- a/Run-Length Encoding/RLE.playground/timeline.xctimeline +++ /dev/null @@ -1,6 +0,0 @@ - - - - - From 21dc86c550e0be0155883255809038c522c5e290 Mon Sep 17 00:00:00 2001 From: Bob DeLaurentis Date: Mon, 31 Jul 2017 12:20:29 -0700 Subject: [PATCH 05/10] Update Linear Search to Swift 4 Updated to Swift 4 and Xcode 9.0b4. No changes necessary. --- Linear Search/LinearSearch.playground/Contents.swift | 5 +++++ Linear Search/LinearSearch.playground/timeline.xctimeline | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 Linear Search/LinearSearch.playground/timeline.xctimeline diff --git a/Linear Search/LinearSearch.playground/Contents.swift b/Linear Search/LinearSearch.playground/Contents.swift index 34e859fa3..dad9a77bd 100644 --- a/Linear Search/LinearSearch.playground/Contents.swift +++ b/Linear Search/LinearSearch.playground/Contents.swift @@ -1,5 +1,10 @@ //: Playground - noun: a place where people can play +// last checked with Xcode 9.0b4 +#if swift(>=4.0) +print("Hello, Swift 4!") +#endif + func linearSearch(_ array: [T], _ object: T) -> Int? { for (index, obj) in array.enumerated() where obj == object { return index diff --git a/Linear Search/LinearSearch.playground/timeline.xctimeline b/Linear Search/LinearSearch.playground/timeline.xctimeline deleted file mode 100644 index bf468afec..000000000 --- a/Linear Search/LinearSearch.playground/timeline.xctimeline +++ /dev/null @@ -1,6 +0,0 @@ - - - - - From f10b1b19c290ce040a9cce25a35ec4974bd68e19 Mon Sep 17 00:00:00 2001 From: Bob DeLaurentis Date: Mon, 31 Jul 2017 12:23:38 -0700 Subject: [PATCH 06/10] Update Selection Sampling to Swift 4 Update to Swift 4 and Xcode 9.0b4. No changes necessary. --- .../SelectionSampling.playground/Contents.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Selection Sampling/SelectionSampling.playground/Contents.swift b/Selection Sampling/SelectionSampling.playground/Contents.swift index 4a2484162..f4aace0c7 100644 --- a/Selection Sampling/SelectionSampling.playground/Contents.swift +++ b/Selection Sampling/SelectionSampling.playground/Contents.swift @@ -1,5 +1,10 @@ //: Playground - noun: a place where people can play +// last checked with Xcode 9.0b4 +#if swift(>=4.0) +print("Hello, Swift 4!") +#endif + import Foundation /* Returns a random integer in the range min...max, inclusive. */ From d3dd6c8b1cf08fc2ecec0ed7039ef40f8236d319 Mon Sep 17 00:00:00 2001 From: Bob DeLaurentis Date: Mon, 31 Jul 2017 12:26:46 -0700 Subject: [PATCH 07/10] Update Rabin-Karp to Swift 4 Updated to Swift 4 and Xcode 9.0b4. No changes necessary. --- Rabin-Karp/Rabin-Karp.playground/Contents.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Rabin-Karp/Rabin-Karp.playground/Contents.swift b/Rabin-Karp/Rabin-Karp.playground/Contents.swift index 4956fabe3..c0a99339a 100644 --- a/Rabin-Karp/Rabin-Karp.playground/Contents.swift +++ b/Rabin-Karp/Rabin-Karp.playground/Contents.swift @@ -1,5 +1,10 @@ //: Taking our rabin-karp algorithm for a walk +// last checked with Xcode 9.0b4 +#if swift(>=4.0) +print("Hello, Swift 4!") +#endif + import UIKit struct Constants { From b6c7f6d922dc0fd35b2c4fdd4b3d90e731adb5bd Mon Sep 17 00:00:00 2001 From: Bob DeLaurentis Date: Mon, 31 Jul 2017 12:29:48 -0700 Subject: [PATCH 08/10] Update Radix Tree to Swift 4 Updated to Swift 4 and Xcode 9.0b4. No changes necessary. --- Radix Tree/RadixTree.playground/Contents.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Radix Tree/RadixTree.playground/Contents.swift b/Radix Tree/RadixTree.playground/Contents.swift index e161e48a2..a5e614849 100644 --- a/Radix Tree/RadixTree.playground/Contents.swift +++ b/Radix Tree/RadixTree.playground/Contents.swift @@ -1,3 +1,10 @@ +// Radix Tree + +// last checked with Xcode 9.0b4 +#if swift(>=4.0) +print("Hello, Swift 4!") +#endif + var radix = RadixTree() var radixWiki = RadixTree() From 713bf52f2495203fb2806bd3944028f3e9718519 Mon Sep 17 00:00:00 2001 From: Bob DeLaurentis Date: Mon, 31 Jul 2017 12:32:04 -0700 Subject: [PATCH 09/10] Updated SetCover to Swift 4 Updated to Swift 4 and Xcode 9.0b4. No changes necessary. --- Set Cover (Unweighted)/SetCover.playground/Contents.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Set Cover (Unweighted)/SetCover.playground/Contents.swift b/Set Cover (Unweighted)/SetCover.playground/Contents.swift index dcf998a66..d61b9c84a 100644 --- a/Set Cover (Unweighted)/SetCover.playground/Contents.swift +++ b/Set Cover (Unweighted)/SetCover.playground/Contents.swift @@ -1,3 +1,10 @@ +// SetCover + +// last checked with Xcode 9.0b4 +#if swift(>=4.0) +print("Hello, Swift 4!") +#endif + let universe1 = Set(1...7) let array1 = randomArrayOfSets(covering: universe1) let cover1 = universe1.cover(within: array1) From db1fc17de22adf7c4cc08117d02686abedb01149 Mon Sep 17 00:00:00 2001 From: Bob DeLaurentis Date: Mon, 31 Jul 2017 12:37:54 -0700 Subject: [PATCH 10/10] Update Naive Bayes Classifier to Swift 4 Updated to Swift 4 and Xcode 9.0b4. No changes necessary. --- Naive Bayes Classifier/NaiveBayes.playground/Contents.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Naive Bayes Classifier/NaiveBayes.playground/Contents.swift b/Naive Bayes Classifier/NaiveBayes.playground/Contents.swift index 66aefaa32..6a2e01aab 100644 --- a/Naive Bayes Classifier/NaiveBayes.playground/Contents.swift +++ b/Naive Bayes Classifier/NaiveBayes.playground/Contents.swift @@ -1,5 +1,10 @@ import Foundation +// last checked with Xcode 9.0b4 +#if swift(>=4.0) +print("Hello, Swift 4!") +#endif + /*: ## Naive Bayes Classifier