Skip to content

Instantly share code, notes, and snippets.

#Run the code. Read the error message.
#Change the assigned value of sample_avg so that it does not throw an error.
def mean(numbers)
sum = numbers.inject(:+)
return sum / numbers.length
end
~ irb
irb(main):001:0> def say_hi(name)
irb(main):002:1> puts "Hi " + name
irb(main):003:1> end
=> :say_hi
irb(main):004:0> say_hi("Ruui & Josh")
Hi Ruui & Josh
=> nil
irb(main):005:0> a = [5,4,3,2,1]
=> [5, 4, 3, 2, 1]
@rwpr
rwpr / deaf_aunty.rb
Last active August 29, 2015 14:24 — forked from josh1812/deaf_aunty.rb
# original count/status
ctr = 0
hello = gets.chomp
# print out the raw
puts hello.inspect
# ctr += 1 if hello == ""
# print out what's ctr (iaw status)
# -----------------------------
# SUDOKU
# -----------------------------
# Solve a Sudoku problem in seconds
# create a text file under c:\ drive called "hard sudoku problem.txt" with following text (without # symbol) and then run the code below
#85---24--
#72------9
#--4------
#---1-7--2