This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ ~ 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----------------------------- | |
# 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 |