Skip to content

Instantly share code, notes, and snippets.

@jendiamond
Last active June 6, 2018 05:48
Show Gist options
  • Save jendiamond/a2f2d240aa94d38657c6 to your computer and use it in GitHub Desktop.
Save jendiamond/a2f2d240aa94d38657c6 to your computer and use it in GitHub Desktop.
Challenge 4

Challenge 4

Write a program that prints the numbers from 1 to 100.

For multiples of three print “word_one” instead of the number.

For the multiples of five print “word_two” instead of the number.

For numbers which are multiples of both three and five print “word_one_word_two” instead of the number.

Kalisa:

  • call your program ticktock.rb
  • use tick for word_one
  • use tock for word_two
  • use ticktock for word_one_word_two

Kathy:

  • call your program flipflop.rb
  • use flip for word_one
  • use flop for word_two
  • use flipflop for word_one_word_two

Laura:

  • call your program hobknob.rb
  • use hob for word_one
  • use knob for word_two
  • use hobknob for word_one_word_two

When my program named wowiezowie.rb runs it looks like this:
1
2
Wowie
4
Zowie
Wowie
7
8
Wowie
Zowie
11
Wowie
13
14
WowieZowie!
16
17
Wowie
19
Zowie
Wowie
22
23
Wowie
Zowie
26
Wowie
28
29
WowieZowie!
31
32
Wowie
34
Zowie
Wowie
37
38
Wowie
Zowie
41
Wowie
43
44
WowieZowie!
46
47
Wowie
49
Zowie
Wowie
52
53
Wowie
Zowie
56
Wowie
58
59
WowieZowie!
61
62
Wowie
64
Zowie
Wowie
67
68
Wowie
Zowie
71
Wowie
73
74
WowieZowie!
76
77
Wowie
79
Zowie
Wowie
82
83
Wowie
Zowie
86
Wowie
88
89
WowieZowie!
91
92
Wowie
94
Zowie
Wowie
97
98
Wowie
Zowie

@KalisaFalzone
Copy link

That was fun. Interestingly all four of us had slightly different syntax even though we all wrote it in ruby. Originally I had had a case using mod 15 but then realized the tick and tock would just appear as ticktock if the number was divisible by 15 and made my program more streamlined. Thanks for the example problem Jen!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment