function (int $i) use ($input) { return str_split(sprintf('%b', $input))[$i] ?? false; })); $vertices = []; for ($i = 0; $i < count($lines); $i++) { $distance = ($lines[($i + 1) % count($lines)] - $lines[$i] + 8) % 8; $vertices[] = ($distance === 4 ? 2 : 3) + $distance - 1; } sort($vertices); return implode('', $vertices); } [0, 2, 5, 7] ͱ͍͏ྻʹରͯ͠ɺཁૉؒͷ͔ࠩΒ࣮ઢؒͷڑΛٻΊΔͱɺ (2-0+8)%8=2, (5-2+8)%8=3, (7-5+8)%8=2, (0-7+8)%8=1 ͱͳΔɻ ڑ͕4ͷ߹ 2+ڑ-1 ͕ɺڑ͕ͦΕҎ֎ͷ߹ 3+ڑ-1 ͕ɻ ͷܭࢉ