Skip to content

Instantly share code, notes, and snippets.

@neomadara
Last active July 13, 2021 23:42
Show Gist options
  • Save neomadara/ee4533fd4335711d0ea289b84017a6af to your computer and use it in GitHub Desktop.
Save neomadara/ee4533fd4335711d0ea289b84017a6af to your computer and use it in GitHub Desktop.
Guillotine cutting algorithm
$paginador = 6;
$contador_interno = 1;
$total_tickets = 18;
$cada = ceil($total_tickets/$paginador);
$total_pagina = $cada * 5;
for($contador = 1; $contador<=$cada; $contador++){
for($contador_interno = $contador; $contador_interno<=$total_pagina+$contador; $contador_interno += $cada){
if($contador_interno<=$total_tickets){
echo $contador_interno.' ';
}
}
echo ' '. PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment