fizzbuzzer 0.0.1 → 0.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: 7cce129d72a233da5127749a82679db77546bbdd
4
- data.tar.gz: e300f3f6a540fcd6343fcb341089b9040bdd4d08
3
+ metadata.gz: 28811d471013230a977d03c106fb752a6367ebaf
4
+ data.tar.gz: 64f7fd56a9228ac13a81028d3c9f363b7120908c
5
5
  SHA512:
6
- metadata.gz: 5ed98feb599ea8764bcc714baf771ef45e7fd838f7dee6a67242b2efbff8985187891642539db63343c6ae9f60d975099280a26054d154c891bd972344fc6b4f
7
- data.tar.gz: 67cb59c03123cb4b535e48f9be54e481116cde503cf82c099df64ca2f2b8a0b78b67168ce09758a2b086d175e2c5b7afda99d6504db43674d7bc3d6ed58aaf81
6
+ metadata.gz: 7712b412f04216e2d143b258dc4c029924a27db4b9b26d63e992ef01bb787c848d03e7609ac78a2d7df53d5972fed4efb6e1731f218b03dbccc06722935488e9
7
+ data.tar.gz: b2fb9b151340b3a08af3d07cf1e8e97a68c80df108b2af4c44a55a59cddafd5e47cc9e32323cd9193a84a866d1d0eb9b1a7abca056b7e098bc6c3c0adff86507
data/Manifest.txt CHANGED
@@ -2,5 +2,6 @@ HISTORY.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
+ bin/fizzbuzz
5
6
  lib/fizzbuzzer.rb
6
7
  lib/fizzbuzzer/version.rb
data/README.md CHANGED
@@ -6,32 +6,86 @@ or helps you find the world's best coders in programming job interviews
6
6
  the feedbuzzer!
7
7
 
8
8
 
9
- ## Usage
10
9
 
11
- Q: Can you code a program for the fizz buzz word game for the first hundred numbers?
10
+ ## What's Fizz Buzz?
11
+
12
+ > Fizz buzz is a group word game for children to teach them about division.
13
+ > Players take turns to count incrementally, replacing any number divisible by three with the word
14
+ > "fizz", and any number divisible by five with the word "buzz".
15
+ >
16
+ > **Play**.
17
+ > Players generally sit in a circle. The player designated to go first says the number "1",
18
+ > and each player counts one number in turn. However, any number divisible by three is replaced by the
19
+ > word fizz and any divisible by five by the word buzz. Numbers divisible by both become fizz buzz.
20
+ > A player who hesitates or makes a mistake is eliminated from the game.
21
+ >
22
+ > For example, a typical round of fizz buzz would start as follows:
23
+ >
24
+ > 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, Fizz Buzz, 16, 17, Fizz, 19, Buzz,
25
+ > Fizz, 22, 23, Fizz, Buzz, 26, Fizz, 28, 29, Fizz Buzz, 31, 32, Fizz, 34, Buzz, Fizz, ...
26
+ >>
27
+ > **Other Uses**.
28
+ > Fizz buzz has been used as an interview screening device for computer programmers.
29
+ > Creating a list of the first hundred fizz buzz numbers is a trivial problem
30
+ > for any computer programmer, so interviewers can easily sort out those with insufficient
31
+ > programming ability.
32
+ >
33
+ > -- [Fizz Buzz @ Wikipedia](https://en.wikipedia.org/wiki/Fizz_buzz)
34
+
35
+
36
+ Can they?
37
+ Q: Can you code a program for the fizz buzz word game that prints the first hundred numbers?
38
+
39
+ A: Why not (re)use the (open source, free) fizzbuzzer library? ;-) -
40
+ Don't reinvent the wheel or the feedbuzzer!
12
41
 
13
- A:
14
42
 
15
43
  ```
16
44
  $ fizzbuzz
17
45
 
18
- 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, Fizz Buzz, 16, 17, Fizz, 19, Buzz, Fizz, 22, 23, Fizz, Buzz, 26, Fizz, 28, 29, Fizz Buzz, 31, 32, Fizz, 34, Buzz, Fizz, ...
46
+ 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16, 17,
47
+ Fizz, 19, Buzz, Fizz, 22, 23, Fizz, Buzz, 26, Fizz, 28, 29, FizzBuzz, 31, 32,
48
+ Fizz, 34, Buzz, Fizz, 37, 38, Fizz, Buzz, 41, Fizz, 43, 44, FizzBuzz, 46, 47,
49
+ Fizz, 49, Buzz, Fizz, 52, 53, Fizz, Buzz, 56, Fizz, 58, 59, FizzBuzz, 61, 62,
50
+ Fizz, 64, Buzz, Fizz, 67, 68, Fizz, Buzz, 71, Fizz, 73, 74, FizzBuzz, 76, 77,
51
+ Fizz, 79, Buzz, Fizz, 82, 83, Fizz, Buzz, 86, Fizz, 88, 89, FizzBuzz, 91, 92,
52
+ Fizz, 94, Buzz, Fizz, 97, 98, Fizz, Buzz
19
53
  ```
20
54
 
21
55
 
22
56
 
23
57
  ## Algorithms
24
58
 
25
- Creating a list of the first hundred Fizz buzz numbers
26
- is a trivial problem for any computer programer, so interviewers can easily sort out those with insufficient programming ability. Can they?
59
+ > Task
60
+ >
61
+ > Write a program that prints the integers from **1** to **100** (inclusive).
62
+ >
63
+ > But:
64
+ >
65
+ > - for multiples of three, print **Fizz** (instead of the number)
66
+ > - for multiples of five, print **Buzz** (instead of the number)
67
+ > - for multiples of both three and five, print **FizzBuzz** (instead of the number)
68
+ >
69
+ > -- [Fizz Buzz @ Rosseta Code](https://rosettacode.org/wiki/FizzBuzz)
70
+
27
71
 
28
72
 
29
73
  ### Gold Standard
30
74
 
31
- Lookup pre-calculated constants. Fast. Faster. Fastest.
75
+ Lookup pre-calculated ("hard coded") constants. Fast. Faster. Fastest.
32
76
 
33
77
  ``` ruby
34
-
78
+ def fizzbuzz
79
+ [1, 2, "Fizz", 4, "Buzz", "Fizz", 7, 8, "Fizz", "Buzz", 11, "Fizz", 13, 14,
80
+ "FizzBuzz", 16, 17, "Fizz", 19, "Buzz", "Fizz", 22, 23, "Fizz", "Buzz", 26,
81
+ "Fizz", 28, 29, "FizzBuzz", 31, 32, "Fizz", 34, "Buzz", "Fizz", 37, 38,
82
+ "Fizz", "Buzz", 41, "Fizz", 43, 44, "FizzBuzz", 46, 47, "Fizz", 49, "Buzz",
83
+ "Fizz", 52, 53, "Fizz", "Buzz", 56, "Fizz", 58, 59, "FizzBuzz", 61, 62,
84
+ "Fizz", 64, "Buzz", "Fizz", 67, 68, "Fizz", "Buzz", 71, "Fizz", 73, 74,
85
+ "FizzBuzz", 76, 77, "Fizz", 79, "Buzz", "Fizz", 82, 83, "Fizz", "Buzz", 86,
86
+ "Fizz", 88, 89, "FizzBuzz", 91, 92, "Fizz", 94, "Buzz", "Fizz", 97, 98,
87
+ "Fizz", "Buzz"]
88
+ end
35
89
  ```
36
90
 
37
91
 
data/bin/fizzbuzz ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ###################
4
+ # DEV TIPS:
5
+ #
6
+ # For local testing run like:
7
+ #
8
+ # ruby -Ilib bin/fizzbuzz
9
+ #
10
+ # Set the executable bit in Linux. Example:
11
+ #
12
+ # % chmod a+x bin/fizzbuzz
13
+ #
14
+
15
+ require 'fizzbuzzer'
16
+
17
+ FizzBuzzer.main
data/lib/fizzbuzzer.rb CHANGED
@@ -7,5 +7,38 @@ require 'pp'
7
7
  require 'fizzbuzzer/version' # note: let version always go first
8
8
 
9
9
 
10
- pp FizzBuzzer.banner
11
- pp FizzBuzzer.root
10
+ module FizzBuzzer
11
+
12
+ module V1
13
+ def fizzbuzz
14
+ [1, 2, "Fizz", 4, "Buzz", "Fizz", 7, 8, "Fizz", "Buzz", 11, "Fizz", 13, 14,
15
+ "FizzBuzz", 16, 17, "Fizz", 19, "Buzz", "Fizz", 22, 23, "Fizz", "Buzz", 26,
16
+ "Fizz", 28, 29, "FizzBuzz", 31, 32, "Fizz", 34, "Buzz", "Fizz", 37, 38,
17
+ "Fizz", "Buzz", 41, "Fizz", 43, 44, "FizzBuzz", 46, 47, "Fizz", 49, "Buzz",
18
+ "Fizz", 52, 53, "Fizz", "Buzz", 56, "Fizz", 58, 59, "FizzBuzz", 61, 62,
19
+ "Fizz", 64, "Buzz", "Fizz", 67, 68, "Fizz", "Buzz", 71, "Fizz", 73, 74,
20
+ "FizzBuzz", 76, 77, "Fizz", 79, "Buzz", "Fizz", 82, 83, "Fizz", "Buzz", 86,
21
+ "Fizz", 88, 89, "FizzBuzz", 91, 92, "Fizz", 94, "Buzz", "Fizz", 97, 98,
22
+ "Fizz", "Buzz"]
23
+ end
24
+ end ## module V1
25
+
26
+
27
+
28
+
29
+ module Main ## todo/check: use a class Runner instead (w/ include V1 etc.) - why? why not?
30
+ extend V1
31
+ end
32
+
33
+
34
+ def self.main
35
+ puts Main.fizzbuzz.join( ', ' )
36
+
37
+ ## print source add the end e.g. source:
38
+ ## possible why? why not?
39
+ end # method self.main
40
+
41
+ end # module FizzBuzzer
42
+
43
+ ## add alias for convenience
44
+ FizzBuzz = FizzBuzzer
@@ -4,8 +4,8 @@
4
4
  module FizzBuzzer
5
5
 
6
6
  MAJOR = 0
7
- MINOR = 0
8
- PATCH = 1
7
+ MINOR = 1
8
+ PATCH = 0
9
9
  VERSION = [MAJOR,MINOR,PATCH].join('.')
10
10
 
11
11
  def self.version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fizzbuzzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
@@ -44,7 +44,8 @@ description: fizzbuzzer - 1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz,
44
44
  or helps you find the world's best coders in programming job interviews - are you
45
45
  (re)using the fizzbuzzer library? ;-) - don't reinvent the wheel or the feedbuzzer!
46
46
  email: wwwmake@googlegroups.com
47
- executables: []
47
+ executables:
48
+ - fizzbuzz
48
49
  extensions: []
49
50
  extra_rdoc_files:
50
51
  - HISTORY.md
@@ -55,6 +56,7 @@ files:
55
56
  - Manifest.txt
56
57
  - README.md
57
58
  - Rakefile
59
+ - bin/fizzbuzz
58
60
  - lib/fizzbuzzer.rb
59
61
  - lib/fizzbuzzer/version.rb
60
62
  homepage: https://github.com/rubylibs/fizzbuzzer