Skip to content

Instantly share code, notes, and snippets.

@iamsok
Created August 16, 2014 21:58
Show Gist options
  • Save iamsok/e3248cb783610674ba06 to your computer and use it in GitHub Desktop.
Save iamsok/e3248cb783610674ba06 to your computer and use it in GitHub Desktop.
Systems Check
scores = [75, 100, 85, 65, 84, 87, 95]
def avg(array)
total = 0
array.each do |grade|
total += grade
end
avg = total / array.length
avg
end
puts avg(scores)
def min(array)
min = array[0]
array.each do |grade|
if grade < min
min = grade
end
end
min
end
puts min(scores)
def max(array)
max = array[-1]
array.each do |grade|
if grade > max
max = grade
end
end
max
end
puts max(scores)
@hchood
Copy link

hchood commented Aug 18, 2014

Also, in case it's helpful, here's the criteria we use in "grading" these things. The ones towards the bottom will apply to all systems checks:

average method has correct signature
average method calculates average
average method converts to float (OPTIONAL)
average method handles empty list (OPTIONAL)
average method does not modify array
max method has correct signature
max method calculates max
max method does not modify array
max method does not sort the array
max method does not use the Array#max method
min method has correct signature
min method calculates min
min method does not modify array
min method does not sort the array
min method does not use the Array#min method

Proper indentation (2 spaces, no tabs).
Methods and variables have clear, meaningful names.
Method and variable names use underscores, class and module names use camel-case.
No global or instance variables.
Newline included at end of file.
No consecutive (2+) blank lines.
No unnecessary "puts" or "binding.pry" statements

Late for standup without notifying mentor.
Missed standup without notifying mentor.
Absent without notifying mentor.

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