From 0b07e67fcc7aad91a5d7197b780a108b187acd48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Wed, 23 Dec 2020 14:57:32 +0100 Subject: [PATCH] :construction: Commence le jour 23 --- day_23/part_1.php | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 day_23/part_1.php diff --git a/day_23/part_1.php b/day_23/part_1.php new file mode 100644 index 0000000..ac83d3e --- /dev/null +++ b/day_23/part_1.php @@ -0,0 +1,60 @@ += count($cups)) { + $current_index = 0; + } +} + +// moves done, now count from 1 +$index_1 = array_search(1, $cups, true); +$final_labels = ''; +$current_index = $index_1 + 1; +for ($i = 1, $l = count($cups); $i < $l; $i++) { + if ($current_index >= $l) { + $current_index = 0; + } + $final_labels .= $cups[$current_index]; + $current_index++; +} + +echo $final_labels; +