We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defcountApplesAndOranges(s,t,a,b,apples,oranges):# Write your code herecount_apple_house=0count_orange_house=0#finding apples fall in house areaforappleinapples:apples_position_from_tree=a+apple#checking distance of apple fall in house area ifapples_position_from_tree>=sandapples_position_from_tree<=t:count_apple_house+=1print(count_apple_house)#finding oranges fall in house areafororangeinoranges:orange_position_from_tree=b+orange#checking distance of orange fall in house areaiforange_position_from_tree>=sandorange_position_from_tree<=t:count_orange_house+=1print(count_orange_house)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Apple and Orange
You are viewing a single comment's thread. Return to all comments →