You are viewing a single comment's thread. Return to all comments →
PHP
function workbook($n, $k, $arr) { $result = array_fill(0, array_sum($arr), []); $pages = 0; $specials = 0; foreach ($arr as $numPages) { for ($problem = 1; $problem <= $numPages; $problem++) { if (count($result[$pages]) >= $k || $problem === 1) { $pages++; } $result[$pages][] = $problem; } } for ($i = 1; $i < count($result); $i++) { if (in_array($i, $result[$i])) { $specials++; } } return $result; }
Seems like cookies are disabled on this browser, please enable them to open this website
Lisa's Workbook
You are viewing a single comment's thread. Return to all comments →
PHP