Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- We required a module for patients control on a clinic. All patients must register upon arrival the system add this patient to a queue,
- display his number. Create a method for pull out.
- =end
- class PatientsQueue
- @q = []
- def register(patient_info)
- @q.push patient_info
- puts @q.size
- end
- def get_current_patient
- @q.shift
- end
- end
- =begin
- Create a method that receives an array of 100,000 integers and outputs the frequency with which each integer appears in ascending order
- input: array = [1,2,4,5,6,8,2,5,3]
- output: array = [1,1] [2,2] [3,1] [4,1] [5,2] [6,1] [8,1]
- =end
- def get_frequency(integers)
- integers.each_with_object(Hash.new(0)) {|key, hash| hash[key] += 1}
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement