pizza-algorithm 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c4275bf40d9e90ba32412443670f986f31a5ac35
4
+ data.tar.gz: 2e3fb84c269dd53322b7e95bbf4a7f883c3ed971
5
+ SHA512:
6
+ metadata.gz: a806e18620be6181f3191ca9a7faa629d94764c2e6cbd8ec7b4e5c88cdd94bf77a5f381cb6d428e46734a699ef416820611418cefed83311e9bbca45efa0145e
7
+ data.tar.gz: e1dfedd8f95b940ada5eddf4753130e0c1df3d13cbca7d43c442da12f0c101578fd75324d61d2e12f17819864f5b2fbfde2fffabfa7043dd0acf672ab2f9a324
@@ -0,0 +1 @@
1
+ # The Pizza Algorithm
@@ -0,0 +1,6 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:tests) do |t|
4
+ end
5
+
6
+ task default: :tests
@@ -0,0 +1,17 @@
1
+ class Pizza
2
+ attr_reader :amount
3
+
4
+ def initialize(amount)
5
+ @amount = amount
6
+ end
7
+
8
+ def mediums
9
+ amt = ((amount.to_f + 1)/3)
10
+ (amt.to_s).include?(".33") ? (amt + 1).round : amt.round
11
+ end
12
+
13
+ def larges
14
+ amt = ((amount.to_f + 1)/4)
15
+ (amt.to_s).include?(".25") ? (amt + 1).round : amt.round
16
+ end
17
+ end
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+ require 'pizza'
3
+
4
+ describe Pizza do
5
+ it "one large pizza for 1 person" do
6
+ pizza = Pizza.new(1)
7
+ expect(pizza.larges).to eq 1
8
+ end
9
+
10
+ it "one large pizza for 2 people" do
11
+ pizza = Pizza.new(2)
12
+ expect(pizza.larges).to eq 1
13
+ end
14
+
15
+ it "one large pizza for 3 people" do
16
+ pizza = Pizza.new(3)
17
+ expect(pizza.larges).to eq 1
18
+ end
19
+
20
+ it "two large pizzas for 4 people" do
21
+ pizza = Pizza.new(4)
22
+ expect(pizza.larges).to eq 2
23
+ end
24
+
25
+ it "two large pizzas for 5 people" do
26
+ pizza = Pizza.new(5)
27
+ expect(pizza.larges).to eq 2
28
+ end
29
+
30
+ it "two large pizzas for 6 people" do
31
+ pizza = Pizza.new(6)
32
+ expect(pizza.larges).to eq 2
33
+ end
34
+
35
+ it "two large pizzas for 7 people" do
36
+ pizza = Pizza.new(7)
37
+ expect(pizza.larges).to eq 2
38
+ end
39
+
40
+ it "two large pizzas for 8 people" do
41
+ pizza = Pizza.new(8)
42
+ expect(pizza.larges).to eq 3
43
+ end
44
+
45
+ it "three large pizzas for 9 people" do
46
+ pizza = Pizza.new(9)
47
+ expect(pizza.larges).to eq 3
48
+ end
49
+
50
+ it "four large pizzas for 12 people" do
51
+ pizza = Pizza.new(12)
52
+ expect(pizza.larges).to eq 4
53
+ end
54
+
55
+ it "five large pizzas for 16 people" do
56
+ pizza = Pizza.new(16)
57
+ expect(pizza.larges).to eq 5
58
+ end
59
+
60
+ it "one medium pizza for 1 person" do
61
+ pizza = Pizza.new(1)
62
+ expect(pizza.mediums).to eq 1
63
+ end
64
+
65
+ it "one medium pizza for 2 people" do
66
+ pizza = Pizza.new(2)
67
+ expect(pizza.mediums).to eq 1
68
+ end
69
+
70
+ it "two medium pizzas for 3 people" do
71
+ pizza = Pizza.new(3)
72
+ expect(pizza.mediums).to eq 2
73
+ end
74
+
75
+ it "three medium pizzas for 6 people" do
76
+ pizza = Pizza.new(6)
77
+ expect(pizza.mediums).to eq 3
78
+ end
79
+ end
@@ -0,0 +1,91 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+ RSpec.configure do |config|
20
+ # rspec-expectations config goes here. You can use an alternate
21
+ # assertion/expectation library such as wrong or the stdlib/minitest
22
+ # assertions if you prefer.
23
+ config.expect_with :rspec do |expectations|
24
+ # This option will default to `true` in RSpec 4. It makes the `description`
25
+ # and `failure_message` of custom matchers include text for helper methods
26
+ # defined using `chain`, e.g.:
27
+ # be_bigger_than(2).and_smaller_than(4).description
28
+ # # => "be bigger than 2 and smaller than 4"
29
+ # ...rather than:
30
+ # # => "be bigger than 2"
31
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
+ end
33
+
34
+ # rspec-mocks config goes here. You can use an alternate test double
35
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
36
+ config.mock_with :rspec do |mocks|
37
+ # Prevents you from mocking or stubbing a method that does not exist on
38
+ # a real object. This is generally recommended, and will default to
39
+ # `true` in RSpec 4.
40
+ mocks.verify_partial_doubles = true
41
+ end
42
+
43
+ # The settings below are suggested to provide a good initial experience
44
+ # with RSpec, but feel free to customize to your heart's content.
45
+ =begin
46
+ # These two settings work together to allow you to limit a spec run
47
+ # to individual examples or groups you care about by tagging them with
48
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
+ # get run.
50
+ config.filter_run :focus
51
+ config.run_all_when_everything_filtered = true
52
+
53
+ # Limits the available syntax to the non-monkey patched syntax that is
54
+ # recommended. For more details, see:
55
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
56
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
57
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
58
+ config.disable_monkey_patching!
59
+
60
+ # This setting enables warnings. It's recommended, but in some cases may
61
+ # be too noisy due to issues in dependencies.
62
+ config.warnings = true
63
+
64
+ # Many RSpec users commonly either run the entire suite or an individual
65
+ # file, and it's useful to allow more verbose output when running an
66
+ # individual spec file.
67
+ if config.files_to_run.one?
68
+ # Use the documentation formatter for detailed output,
69
+ # unless a formatter has already been configured
70
+ # (e.g. via a command-line flag).
71
+ config.default_formatter = 'doc'
72
+ end
73
+
74
+ # Print the 10 slowest examples and example groups at the
75
+ # end of the spec run, to help surface which specs are running
76
+ # particularly slow.
77
+ config.profile_examples = 10
78
+
79
+ # Run specs in random order to surface order dependencies. If you find an
80
+ # order dependency and want to debug it, you can fix the order by providing
81
+ # the seed, which is printed after each run.
82
+ # --seed 1234
83
+ config.order = :random
84
+
85
+ # Seed global randomization in this process using the `--seed` CLI option.
86
+ # Setting this allows you to use `--seed` to deterministically reproduce
87
+ # test failures related to randomization by passing the same `--seed` value
88
+ # as the one that triggered the failure.
89
+ Kernel.srand config.seed
90
+ =end
91
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pizza-algorithm
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Meagan Waller
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-14 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Pizza Algorithm
14
+ email: meaganewaller@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - README.md
20
+ - Rakefile
21
+ - lib/pizza.rb
22
+ - spec/pizza_spec.rb
23
+ - spec/spec_helper.rb
24
+ homepage: http://www.meaganwaller.com
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.4.3
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Pizza Algorithm for for Calculating How Many Pizzas your Group Should Order.
48
+ test_files: []