In your favorite language, write a program that takes a list/array of numbers which corresponds to a bar chart, where water can fill any gaps in the bars. Calculate the total area/units of water (bars are integers).
Water drains off left and right sides, and an array value of zero is a bottom hole that also drains water.
how can a single list of numbers correspond to the chart?
Eli Turner
also none of the bars in your picture have gaps
Chase Garcia
one axis is index and other axis is values
and you've just failed this job interview
Ryder Diaz
What if i have [1,5,1,5,1,5,1] ?
Anyways, i guess something like this would work:
>Asume first number in array is the biggest number >Initialize total as 0 >For each element in the array >if number is bigger than our biggest number, change biggest number to this number >if not, calculate biggest number - number, and add it up to total >if number is 0 or below, set total to 0
Adam Garcia
>array >axis Not sure if I want a job where the superiors have no idea how to say "jagged array".
Cameron Collins
Just give the real assignement, if you want us to do your homework go to /sqt/ and give every info.
Jayden Mitchell
>Water drains off left and right sides, and an array value of zero is a bottom hole that also drains water. Is there a trick or something? Would vector 2 1 2 0 contain water between twos? Would vector 2 1 4 1 3 contain 2 different water levels?
Landon Baker
Complain instead of trying to give a solution.
Way to go Jow Forums
Henry Davis
>give poorly-formed question lacking information >complain you don't get instant answers to your highschool intro to programming homework