session1/challenge/4_logic.rb
# A grad student at a local university thinks he has discovered a formula to
# predict what kind of grades a person will get. He says if you own less than
# 10 books, you will get a "D". If you own 10 to 20 books, you will get a "C",
# and if you own more than 20 books, you will get a "B".
# He further hypothesizes that if you actually read your books, then you will
# get a full letter grade higher in every case.
#
# grade(4,  false)  # => "D"
# grade(4,  true)   # => "C"
# grade(15, true)   # => "B"
A grad student at a local university thinks he has discovered a formula to
predict what kind of grades a person will get. He says if you own less than
10 books, you will get a "D". If you own 10 to 20 books, you will get a "C",
and if you own more than 20 books, you will get a "B".
He further hypothesizes that if you actually read your books, then you will
get a full letter grade higher in every case.


A grad student at a local university thinks he has discovered a formula to predict what kind of grades a person will get . He says if you own less than 10 books you will get a " D " . If you own 10 to 20 books you will get a " C " and if you own more than 20 books you will get a " B " . He further hypothesizes that if you actually read your books then you will get a full letter grade higher in every case .
def grade(num_books, reads_books)
  num_books > 20 ? grade = 'B' :
  num_books >= 10 ? grade = 'C' : grade = 'D'
  reads_books ? (grade.ord - 1).chr : grade
end
def grade ( num_books , reads_books ) num_books > 20 ? grade = 'B' : num_books >= 10 ? grade = 'C' : grade = 'D' reads_books ? ( grade . ord - 1 ) . chr : grade end
A grad student at a local university thinks he has discovered a formula to
predict what kind of grades a person will get.
A grad student at a local university thinks he has discovered a formula to predict what kind of grades a person will get .
num_books
<not_specific>
reads_books
<not_specific>