@anonymous/GiganticGregariousSanddollar
Ruby

No description

Files
  • main.rb
main.rb
# Simulate a JSON request parsed into a Ruby hashmap
#
# @return [Hash{String => Hash}]
def request_body
  { 'abc_123' => {
    date_of_birth: nil,
    cancers: [
      { cancer_type: :breast,
        age_of_diagnosis: nil },
      { cancer_type: :colorectal,
        age_of_diagnosis: 51 }
    ]
  } }
end

# Deterimine whether any family member has breast cancer under 50
#
# @return [Boolean]
def family_has_breast_cancer_under_50(data)
  data.values.any? do |family_member|
    family_member[:cancers].any? do |cancer|
      cancer[:cancer_type] == :breast && cancer[:age_of_diagnosis] < 50
    end
  end
end

puts family_has_breast_cancer_under_50(request_body)
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]