Details
When using the grid layout in CSS, divs are placed in a particular way.
Each div can span a number of rows and columns. With the default settings,
div must come after the previous one in flow order, so when placing a div
the browser will look for the first spot that would fit and comes after
the previous div.
You will be given the number of columns, a space, then a series of
w,h
pairs representing the row and column span of each div.
Output the column and row coordinates of the top-left corner of each box,
starting from 0 0, all on one line. Each pair of numbers is seperated by a
comma.
The grid has infinite height.
Example
Given this input:
4 2,1 3,1 1,2 4,1
We know the width is 4, and the boxes are
[2,1], [3,1], [1,2], [4,1]
Greedily aranging the boxes gives us this:
┏━━━┓
┃ ┆ ┃
┣━━━┻━┳━┓
┃ ┆ ┆ ┃ ┃
┗━━━━━┫┄┃
┃ ┃
┏━━━━━┻━┫
┃ ┆ ┆ ┆ ┃
┗━━━━━━━┛
Note that the third long box could fix on the third row, however, that
would not preserve ordering so we must place it on the second row.
So we output the coordinates of the top left corners:
0,0 0,1 3,1 0,3
External links:
MDN
05AB1E is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
ALGOL 68 is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
APL is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Arturo is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Befunge is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
BQN is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
CJam is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
CoffeeScript is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Egel is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Erlang is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Fennel is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Groovy is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Harbour is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Hare is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Haxe is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Hush is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Hy is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
iogii is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Odin is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Picat is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Racket is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Rebol is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Rexx is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Scala is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Squirrel is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Stax is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Uiua is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.
Vyxal is an experimental language, no solutions will be saved.
Please leave feedback on the
GitHub issue.