Well, here is a little problem I would like to help with.
I have a view, and the size of the viewport will depend on the user's screen resolution. The viewport should contain N fields that are aligned next to each other from right to left and occupy the entire horizontal space in the viewport. Now, if all the boxes can be the same size, it will be easy, just divide the width of the viewport by N and you will leave.
The problem is that each box should be 10% smaller than the box on the left side, for example, if the viewport has a width of 271 pixels, and three boxes will be returned [100, 90, 81]
So, I need an algorithm that, when transmitting the width of the viewport and the number of horizontal fields, will return an array containing the width of which each of the fields should be in order to fill the width of the viewport and reduce each box size by 10%.
Answers in any OO language are cool. I would like to get some ideas on how to approach this and maybe see who can come up with the most elegant solution.
Hello,
Chris
source
share