forked from lrug/january-2019-code-golf
-
Notifications
You must be signed in to change notification settings - Fork 1
/
golf.rb
89 lines (71 loc) · 2.85 KB
/
golf.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
module Golf
# Hole 1: Multiply the contents of an array
#
# A nice each one to start. Given an array numbers, return the result of
# multiplying all of the numbers together.
#
# The parameter `a` is the array of numbers.
def hole1(a)
# put your implementation in here, but please leave the comments above and at the 'end'
end # Hole 1
# Hole 2: Fizzbuzz
#
# Everyone knows fizzbuzz, right?
#
# The parameter 'l' is the limit - the highest number to reach.
def hole2(l)
# put your implementation in here, but please leave the comments above and at the 'end'
end # Hole 2
# Hole 3: The Caeser Cipher
#
# A very simple way of encoding one string, using a variable number of "shifts" to
# turn each letter into a different one. If you know the shift, you can then decode
# the string you receive into the original message. For example:
#
# * "abc" with a shift of 1 becomes "bcd"
# * "Hello" with a shift of 3 becomes "Khoor"
# * "Jazz Hands" with a shift of 10 becomes "Mdcc Kdqgv"
#
# Your solution should handle upper and lowercase letters, retaining their case.
#
# The parameter `s` is the string to encode, and `x` is the number to shift by.
def hole3(s, x)
# put your implementation in here, but please leave the comments above and at the 'end'
end # Hole 3
# Hole 4: Roman Numerals
#
# Write a simple function to turn an integer into its roman numeral form. To get
# you started, here's the first ten numbers: I, II, III, IV, V, VI, VII, VIII, IX, X...
#
# The parameter `i` is the number to convert
def hole4(i)
# put your implementation in here, but please leave the comments above and at the 'end'
end # Hole 4
# Hole 5: Evil Numbers
#
# An "evil" number is one which has an even number of '1' digits in its binary version.
# So for example, 5 is evil because `101` has 2, but 11 is _not_ evil, because `1011`
# does not. Find all the numbers (starting at 0, up to the limit) which are evil, and
# return an array of them.
#
# The parameter `l` is the highest number to consider
def hole5(l)
# put your implementation in here, but please leave the comments above and at the 'end'
end # Hole 5
# Hole 6: Deck the halls
#
# Generate an array containing elements representing every card in a deck, including
# the jokers. Represent the cards using a two/three-character string:
#
# * the first character is the rank, ace to king: A, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K
# * the second character is the suit: C, H, S, D for clubs, hearts, spaces and diamonds
# * each joker should just be a single character string 'J'
#
# The order of the cards doesn't matter
#
def hole6
# put your implementation in here, but please leave the comments above and at the 'end'
end # Hole 5
# Please ignore this little bit of code plumbing
extend self
end