-
Notifications
You must be signed in to change notification settings - Fork 60
/
count_max.rb
30 lines (26 loc) · 1.04 KB
/
count_max.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
# Method name: count_max
# Inputs: A list of numbers
# Returns: The number of times the largest number in the list
# appears in the list
# Prints: Nothing
#
# For example,
# count_max([10, 1,2,10,10]) == 3
# because "10" is the largest number in the list and it occurs 3 times
# This is how we require the max.rb and count_in_list.rb files in the current
# folder. We can now use the "max" and "count_in_list" methods we defined there
# -- as if we had defined them right here!
require_relative "./max"
require_relative "./count_in_list"
def count_max(list)
# You can write this using nothing more than the max and count_in_list
# methods that you've already written. You do not HAVE to, but it's worth
# trying. The "require_relative" statements above make them available to us.
#
# But remember: inelegant, working code is better than elegant,
# unfinished code.
end
if __FILE__ == $PROGRAM_NAME
# I'd advise putting some sanity checks here.
# How else will you be sure your code does what you think it does?
end