cyclical_cube_sum 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +51 -0
- data/LICENSE.txt +21 -0
- data/README.md +38 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/cyclical_cube_sum.gemspec +42 -0
- data/lib/cyclical_cube_sum.rb +7 -0
- data/lib/cyclical_cube_sum/cyclical_cube_summer.rb +41 -0
- data/lib/cyclical_cube_sum/version.rb +3 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3e884ce965b52f5f807156c14ad4634c6f3a19a1
|
4
|
+
data.tar.gz: 9a5b383d810178a3bae6231e6c63e0afe4099d29
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bdb126fd6d0ad5e43e588a2984613f4579648d754c2871452ea073a485a3563b0b4e2945802c6f72a3dd408ab37f30df2607c87cd9d209ac44329652993f8d89
|
7
|
+
data.tar.gz: a7a55c7a0d4697a71b80ebd49d902c0313b33bd08af238588c2f85bddb8217c7eb965dd9e477b844c91c27cdd01082a42fb6d06569642d6055b270e8da285b72
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
File without changes
|
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in cube_sum.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'bundler'
|
9
|
+
gem 'rake'
|
10
|
+
|
11
|
+
group :test do
|
12
|
+
gem 'rspec'
|
13
|
+
end
|
14
|
+
|
15
|
+
group :develop do
|
16
|
+
gem 'rubocop', '~> 0.52.1'
|
17
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cyclical_cube_sum (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
diff-lcs (1.3)
|
11
|
+
parallel (1.12.1)
|
12
|
+
parser (2.5.1.2)
|
13
|
+
ast (~> 2.4.0)
|
14
|
+
powerpack (0.1.2)
|
15
|
+
rainbow (3.0.0)
|
16
|
+
rake (10.5.0)
|
17
|
+
rspec (3.8.0)
|
18
|
+
rspec-core (~> 3.8.0)
|
19
|
+
rspec-expectations (~> 3.8.0)
|
20
|
+
rspec-mocks (~> 3.8.0)
|
21
|
+
rspec-core (3.8.0)
|
22
|
+
rspec-support (~> 3.8.0)
|
23
|
+
rspec-expectations (3.8.2)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.8.0)
|
26
|
+
rspec-mocks (3.8.0)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.8.0)
|
29
|
+
rspec-support (3.8.0)
|
30
|
+
rubocop (0.52.1)
|
31
|
+
parallel (~> 1.10)
|
32
|
+
parser (>= 2.4.0.2, < 3.0)
|
33
|
+
powerpack (~> 0.1)
|
34
|
+
rainbow (>= 2.2.2, < 4.0)
|
35
|
+
ruby-progressbar (~> 1.7)
|
36
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
37
|
+
ruby-progressbar (1.10.0)
|
38
|
+
unicode-display_width (1.4.0)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
x64-mingw32
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
bundler
|
45
|
+
cyclical_cube_sum!
|
46
|
+
rake
|
47
|
+
rspec
|
48
|
+
rubocop (~> 0.52.1)
|
49
|
+
|
50
|
+
BUNDLED WITH
|
51
|
+
1.17.0.pre.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Milton Stanley
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# CyclicalCubeSum
|
2
|
+
|
3
|
+
CyclicalCubeSum calculates the veracity and accuracy of the "153" data fround [here](http://home.earthlink.net/~bobseller1/id89.html).
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'cyclical_cube_sum'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install cyclical_cube_sum
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Run the file and view the output data
|
25
|
+
|
26
|
+
## Development
|
27
|
+
|
28
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
29
|
+
|
30
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/MiltonStanley/cyclical_cube_sum.
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "cyclical_cube_sum"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "cyclical_cube_sum/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cyclical_cube_sum"
|
8
|
+
spec.version = CyclicalCubeSum::VERSION
|
9
|
+
spec.authors = ["Milton Stanley"]
|
10
|
+
spec.email = ["milton.stanley@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Calculates and groups Cyclical Cube Sums}
|
13
|
+
spec.description = %q{Visit http://home.earthlink.net/~bobseller1/id89.html for a more-detailed description}
|
14
|
+
spec.homepage = "http://www.milton-stanley.com"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org/"
|
21
|
+
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/MiltonStanley/cyclical_cube_summer"
|
24
|
+
spec.metadata["changelog_uri"] = "https://github.com/MiltonStanley/cyclical_cube_summer/blob/master/CHANGELOG.md"
|
25
|
+
else
|
26
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
"public gem pushes."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.bindir = "exe"
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.add_development_dependency "bundler", "~> 1.17.a"
|
40
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
41
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
42
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module CyclicalCubeSum
|
2
|
+
class CyclicalCubeSummer
|
3
|
+
|
4
|
+
TRIANGULAR_NUMBERS = [153, 371, 370]
|
5
|
+
FOUND_TRIANGLES = [407]
|
6
|
+
ALL_TRIANGLES = TRIANGULAR_NUMBERS.push(FOUND_TRIANGLES).flatten
|
7
|
+
|
8
|
+
def get_digit_array(integer)
|
9
|
+
integer.to_s.chars.map(&:to_i)
|
10
|
+
end
|
11
|
+
|
12
|
+
def cube_array(array)
|
13
|
+
array.map! { |x| x**3 }
|
14
|
+
end
|
15
|
+
|
16
|
+
def sum_array(x)
|
17
|
+
x.inject(0){|sum,x| sum + x }
|
18
|
+
end
|
19
|
+
|
20
|
+
def single_cycle(integer)
|
21
|
+
char_array = get_digit_array(integer)
|
22
|
+
cubed_array = cube_array(char_array)
|
23
|
+
result = sum_array(cubed_array)
|
24
|
+
result
|
25
|
+
end
|
26
|
+
|
27
|
+
def full_cycle(integer)
|
28
|
+
return :triangle if ALL_TRIANGLES.include?(integer)
|
29
|
+
result = single_cycle(integer)
|
30
|
+
return :loop if result == integer
|
31
|
+
count = 0
|
32
|
+
result_list = []
|
33
|
+
until(count == 99 || ALL_TRIANGLES.include?(result)) # || result_list.include?(result))s
|
34
|
+
result = single_cycle(result)
|
35
|
+
return :loop if result_list.include? result #puts "Result list: #{result_list}"
|
36
|
+
result_list << result
|
37
|
+
end
|
38
|
+
result
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cyclical_cube_sum
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Milton Stanley
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.17.a
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.17.a
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Visit http://home.earthlink.net/~bobseller1/id89.html for a more-detailed
|
56
|
+
description
|
57
|
+
email:
|
58
|
+
- milton.stanley@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- CHANGELOG.md
|
67
|
+
- Gemfile
|
68
|
+
- Gemfile.lock
|
69
|
+
- LICENSE.txt
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- bin/console
|
73
|
+
- bin/setup
|
74
|
+
- cyclical_cube_sum.gemspec
|
75
|
+
- lib/cyclical_cube_sum.rb
|
76
|
+
- lib/cyclical_cube_sum/cyclical_cube_summer.rb
|
77
|
+
- lib/cyclical_cube_sum/version.rb
|
78
|
+
homepage: http://www.milton-stanley.com
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata:
|
82
|
+
allowed_push_host: https://rubygems.org/
|
83
|
+
homepage_uri: http://www.milton-stanley.com
|
84
|
+
source_code_uri: https://github.com/MiltonStanley/cyclical_cube_summer
|
85
|
+
changelog_uri: https://github.com/MiltonStanley/cyclical_cube_summer/blob/master/CHANGELOG.md
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.5.2
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Calculates and groups Cyclical Cube Sums
|
106
|
+
test_files: []
|