Skip to content

Instantly share code, notes, and snippets.

@jbis9051
Last active April 19, 2020 17:47
Show Gist options
  • Save jbis9051/b88dd8e4fad47cdfdab8c4cb8cc21b45 to your computer and use it in GitHub Desktop.
Save jbis9051/b88dd8e4fad47cdfdab8c4cb8cc21b45 to your computer and use it in GitHub Desktop.
function LayoutFinder(numDevices: number): DeviceLayout {
let rows = 1;
let devices_per_row = 1;
for(let i = 2; i <= numDevices; i++){
if(numDevices > rows * devices_per_row){
if(rows === devices_per_row){
devices_per_row++;
} else {
rows++;
}
}
}
return {
devices: numDevices,
rows: rows,
devices_per_row: devices_per_row
}
}
Devices Rows D/R
1 1 1
2 1 2
3 2 2
4 2 2
5 2 2
6 2 3
7 3 3
8 3 3
9 3 3
10 3 4
11 3 4
12 3 4
13 4 4
14 4 4
15 4 4
16 4 4
17 4 5
18 4 5
19 4 5
20 4 5
21 5 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment