Ruby solution: It's not the prettiest, but it works. I'm a Ruby newb so this was some good practice and I won't say no to any pointers or suggestions if I am doing something that's not very "Rubyish" (What word do they use for poorly used Ruby? In Python they say "that's not very "pythonic").
12defqueueTime(line,till_count)3empty=false4in_progress=[]5time_spent=06while!emptydo7# remove finished customers from in_progress8in_progress=in_progress.reject{|x|x<=0}910# add more customers to in_progress11whilein_progress.length<till_countandline.length>0do12in_progress.push(line.shift)13end1415# check if done, otherwise, keep tracking progress16ifin_progress.length==0andline.length==017empty=true18else19min=in_progress.min20in_progress=in_progress.map{|x|x-min}21time_spent+=min22end23end24time_spent25end
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ruby solution: It's not the prettiest, but it works. I'm a Ruby newb so this was some good practice and I won't say no to any pointers or suggestions if I am doing something that's not very "Rubyish" (What word do they use for poorly used Ruby? In Python they say "that's not very "pythonic").