From f5ccae7cb45757fb887703f65ae34d1932e561ac Mon Sep 17 00:00:00 2001 From: Wesley Arrington Date: Fri, 29 Jun 2018 02:39:20 -0700 Subject: [PATCH 01/14] Added BogoSort in Swift 4.1 --- .../bogo/code/swift/bogoSort.swift | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 chapters/sorting_searching/bogo/code/swift/bogoSort.swift diff --git a/chapters/sorting_searching/bogo/code/swift/bogoSort.swift b/chapters/sorting_searching/bogo/code/swift/bogoSort.swift new file mode 100644 index 000000000..8eb72883a --- /dev/null +++ b/chapters/sorting_searching/bogo/code/swift/bogoSort.swift @@ -0,0 +1,38 @@ +import Foundation + + +func isSorted(inputArray: [Int]) -> Bool { + + for i in 0.. inputArray[i+1] { + return false + } + } + + return true +} + + + +func shuffle(inputArray: inout [Int]) -> [Int] { + var shuffledArray = [Int]() + + for _ in 0.. [Int] { + + while(!isSorted(inputArray: sortArray)) { + sortArray = shuffle(inputArray: &sortArray) + } + + return sortArray +} From 3e82fd11f30df1e5514d4b0e764883a97fd6231d Mon Sep 17 00:00:00 2001 From: Wesley Arrington Date: Fri, 29 Jun 2018 02:45:08 -0700 Subject: [PATCH 02/14] Updated .md --- chapters/sorting_searching/bogo/bogo_sort.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chapters/sorting_searching/bogo/bogo_sort.md b/chapters/sorting_searching/bogo/bogo_sort.md index e8c91fec2..7cc53ebd6 100644 --- a/chapters/sorting_searching/bogo/bogo_sort.md +++ b/chapters/sorting_searching/bogo/bogo_sort.md @@ -32,6 +32,9 @@ In code, it looks something like this: {% sample lang="rs" %} [import, lang:"rust"](code/rust/bogosort.rs) {% endmethod %} +{% sample lang="rs" %} +[import, lang:"swift"](code/swift/bogoSort.swift) +{% endmethod %} That's it. Ship it! From 090d5b79783d235e6fb9afa8ebd6b5c534d142da Mon Sep 17 00:00:00 2001 From: Wesley Arrington Date: Fri, 29 Jun 2018 03:19:00 -0700 Subject: [PATCH 03/14] Updated book.json --- book.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/book.json b/book.json index d32aedc1f..e8a20a5a4 100644 --- a/book.json +++ b/book.json @@ -86,6 +86,10 @@ { "lang": "go", "name": "Go" + }, + { + "lang": "swift", + "name": "Swift" } ], From fa07e5e39894b45006629d9c59194a69277da333 Mon Sep 17 00:00:00 2001 From: Wesley Arrington Date: Fri, 29 Jun 2018 03:22:11 -0700 Subject: [PATCH 04/14] Updating .md --- chapters/sorting_searching/bogo/bogo_sort.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/sorting_searching/bogo/bogo_sort.md b/chapters/sorting_searching/bogo/bogo_sort.md index 7cc53ebd6..55875b848 100644 --- a/chapters/sorting_searching/bogo/bogo_sort.md +++ b/chapters/sorting_searching/bogo/bogo_sort.md @@ -32,7 +32,7 @@ In code, it looks something like this: {% sample lang="rs" %} [import, lang:"rust"](code/rust/bogosort.rs) {% endmethod %} -{% sample lang="rs" %} +{% sample lang="swift" %} [import, lang:"swift"](code/swift/bogoSort.swift) {% endmethod %} From b68abf2d89290694abea03213a46dbac2c3b7075 Mon Sep 17 00:00:00 2001 From: CD Sigma Date: Fri, 29 Jun 2018 03:28:05 -0700 Subject: [PATCH 05/14] Updated CONTRIBUTORS.md --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 57640d2d6..cd409d43e 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -8,3 +8,4 @@ Hitesh C Maxime Dherbécourt Jess 3Jane Pen Pal +CDsigma From e4c61b18cfba814bba5e73497863ccb8032950a9 Mon Sep 17 00:00:00 2001 From: CD Sigma Date: Fri, 29 Jun 2018 10:27:23 -0700 Subject: [PATCH 06/14] Fixing Formatting --- chapters/sorting_searching/bogo/code/swift/bogoSort.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/chapters/sorting_searching/bogo/code/swift/bogoSort.swift b/chapters/sorting_searching/bogo/code/swift/bogoSort.swift index 8eb72883a..4db91083c 100644 --- a/chapters/sorting_searching/bogo/code/swift/bogoSort.swift +++ b/chapters/sorting_searching/bogo/code/swift/bogoSort.swift @@ -15,6 +15,7 @@ func isSorted(inputArray: [Int]) -> Bool { func shuffle(inputArray: inout [Int]) -> [Int] { + var shuffledArray = [Int]() for _ in 0.. Date: Fri, 29 Jun 2018 11:09:23 -0700 Subject: [PATCH 07/14] Fixing formatting I accidentally had messed up the location of some the brackets --- book.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book.json b/book.json index 8dad23c07..72bff47b4 100644 --- a/book.json +++ b/book.json @@ -86,8 +86,8 @@ { "lang": "swift", "name": "Swift" - }, - { + }, + { "lang": "racket", "name": "Racket" }, From 2f1723bf84081fe8cd16f993c1c9c84296165fe5 Mon Sep 17 00:00:00 2001 From: CD Sigma Date: Fri, 29 Jun 2018 11:12:14 -0700 Subject: [PATCH 08/14] Fixing Formating This update should fix the location of the brackets --- book.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book.json b/book.json index 72bff47b4..2eb344128 100644 --- a/book.json +++ b/book.json @@ -86,8 +86,8 @@ { "lang": "swift", "name": "Swift" - }, - { + }, + { "lang": "racket", "name": "Racket" }, From cae4e825a38d244c405bf41d1babd74974cf7598 Mon Sep 17 00:00:00 2001 From: CD Sigma Date: Fri, 29 Jun 2018 12:13:58 -0700 Subject: [PATCH 09/14] Fixed Brackets Okay now I have actually formatted the brackets correctly --- book.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book.json b/book.json index 2eb344128..f706333a8 100644 --- a/book.json +++ b/book.json @@ -86,8 +86,8 @@ { "lang": "swift", "name": "Swift" - }, - { + }, + { "lang": "racket", "name": "Racket" }, From e4e82c36bf8732a046d47cd9492ace4785275f3c Mon Sep 17 00:00:00 2001 From: CDsigma Date: Fri, 29 Jun 2018 12:18:42 -0700 Subject: [PATCH 10/14] Fixing Brackets --- book.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book.json b/book.json index f706333a8..a5e9650f8 100644 --- a/book.json +++ b/book.json @@ -86,8 +86,8 @@ { "lang": "swift", "name": "Swift" - }, - { + }, + { "lang": "racket", "name": "Racket" }, From f18feabe0d1da8410369b204e75d685d3b764a23 Mon Sep 17 00:00:00 2001 From: CD Sigma Date: Fri, 29 Jun 2018 14:26:10 -0700 Subject: [PATCH 11/14] Updated File Name --- chapters/sorting_searching/bogo/bogo_sort.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapters/sorting_searching/bogo/bogo_sort.md b/chapters/sorting_searching/bogo/bogo_sort.md index 657e3893a..e682d947d 100644 --- a/chapters/sorting_searching/bogo/bogo_sort.md +++ b/chapters/sorting_searching/bogo/bogo_sort.md @@ -37,7 +37,7 @@ In code, it looks something like this: [import, lang:"rust"](code/rust/bogosort.rs) {% endmethod %} {% sample lang="swift" %} -[import, lang:"swift"](code/swift/bogoSort.swift) +[import, lang:"swift"](code/swift/bogosort.swift) {% endmethod %} That's it. From 8c3b742d3789465bd2254a128279386ea2a946e8 Mon Sep 17 00:00:00 2001 From: CDsigma Date: Fri, 29 Jun 2018 14:29:20 -0700 Subject: [PATCH 12/14] Got rid of spaces in whitespace --- book.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/book.json b/book.json index a5e9650f8..9d7122d7b 100644 --- a/book.json +++ b/book.json @@ -86,8 +86,8 @@ { "lang": "swift", "name": "Swift" - }, - { + }, + { "lang": "racket", "name": "Racket" }, From 0a0fc50065266f744105f32f9618978d6a92c7be Mon Sep 17 00:00:00 2001 From: CDsigma Date: Fri, 29 Jun 2018 14:35:48 -0700 Subject: [PATCH 13/14] Renamed bogosort.swift file --- .../bogo/code/swift/{bogoSort.swift => bogosort.swift} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename chapters/sorting_searching/bogo/code/swift/{bogoSort.swift => bogosort.swift} (100%) diff --git a/chapters/sorting_searching/bogo/code/swift/bogoSort.swift b/chapters/sorting_searching/bogo/code/swift/bogosort.swift similarity index 100% rename from chapters/sorting_searching/bogo/code/swift/bogoSort.swift rename to chapters/sorting_searching/bogo/code/swift/bogosort.swift From 414a7e85b0823f541141273fc5eb3925ee53b7b3 Mon Sep 17 00:00:00 2001 From: CD Sigma Date: Fri, 29 Jun 2018 14:52:57 -0700 Subject: [PATCH 14/14] Removing duplicate {% endmethod %} --- chapters/sorting_searching/bogo/bogo_sort.md | 1 - 1 file changed, 1 deletion(-) diff --git a/chapters/sorting_searching/bogo/bogo_sort.md b/chapters/sorting_searching/bogo/bogo_sort.md index e682d947d..ca5c77516 100644 --- a/chapters/sorting_searching/bogo/bogo_sort.md +++ b/chapters/sorting_searching/bogo/bogo_sort.md @@ -35,7 +35,6 @@ In code, it looks something like this: [import, lang:"c_cpp"](code/c++/bogosort.cpp) {% sample lang="rs" %} [import, lang:"rust"](code/rust/bogosort.rs) -{% endmethod %} {% sample lang="swift" %} [import, lang:"swift"](code/swift/bogosort.swift) {% endmethod %}