nyuudou 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30fe6907239ef1ff473a00349c4ba4d11c8a715e
4
- data.tar.gz: 662c93eb33d49dacd68a3c4a260fd84346188864
3
+ metadata.gz: 3acda42ffb3fe7dd998f7e71f872aae378995e73
4
+ data.tar.gz: 63ec91c7343a5840590899f92dfc61c591864e4b
5
5
  SHA512:
6
- metadata.gz: 8f14802ca3dff2802ab6bf3046c54446971e0580ef71123abfc3bfa75c733dce5de0562f7dff16ac9c7f52dc906635407a38a9c48b36d5b3be18441461cceb1e
7
- data.tar.gz: 8b2c68b194087f44b4c48a9d841657ddc2a18f315443690bfd48fd8a5b5f331e628eea78c14aab46523ed20c0db72143cfa47972996583abdbffef5f4e3f3159
6
+ metadata.gz: 464fefff7e2b05f1ef4bcda151d3bce853d0d90f6ec6d2dc9f4c36b60513567dba2cdf3e40c74b389d5061c55a08a306055b47f1dec76749db5a20eb468aa938
7
+ data.tar.gz: 618a93adc4b81b9da2180034474b20ec297589cc7d8c844d5823cad6ff0f5b6084e4df2944fc45992154057434aa571a4dda6af2a91d201d038be5e55b4c951e
data/README.md CHANGED
@@ -6,7 +6,8 @@ Nyuudou is sort algorithm library.
6
6
 
7
7
  ## Implementation
8
8
 
9
- * Bubble Sort
9
+ * Bubble Sort (Array#bubble_sort, Array#bubble_sort!)
10
+ * Selection Sort (Array#selection_sort, Array#selection_sort!)
10
11
 
11
12
  ## Installation
12
13
 
@@ -17,4 +17,27 @@ class Array
17
17
  }
18
18
  self
19
19
  end
20
+
21
+ def selection_sort
22
+ ary = self.dup
23
+ (0...(ary.length - 1)).each { |i|
24
+ min = i
25
+ ((i+1)...(ary.length)).each { |j|
26
+ min = j if ary[j] < ary[min]
27
+ }
28
+ ary[i], ary[min] = ary[min], ary[i]
29
+ }
30
+ ary
31
+ end
32
+
33
+ def selection_sort!
34
+ (0...(self.length - 1)).each { |i|
35
+ min = i
36
+ ((i+1)...(self.length)).each { |j|
37
+ min = j if self[j] < self[min]
38
+ }
39
+ self[i], self[min] = self[min], self[i]
40
+ }
41
+ self
42
+ end
20
43
  end
@@ -1,3 +1,3 @@
1
1
  module Nyuudou
2
- VERSION = "1.0.3"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nyuudou
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tmp1024
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-06 00:00:00.000000000 Z
11
+ date: 2016-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler