Skip to content

Instantly share code, notes, and snippets.

@sdennler
Created March 26, 2023 11:09
Show Gist options
  • Save sdennler/cd2f034f11cfd26bb71572007ff38a0b to your computer and use it in GitHub Desktop.
Save sdennler/cd2f034f11cfd26bb71572007ff38a0b to your computer and use it in GitHub Desktop.
<?php
$l = range('A', 'I');
for($i=123456789; $i<=987654321; $i++){
$a = str_split((string)$i);
if(9 <> count(array_unique($a))) continue;
if(in_array('0', $a)) continue;
$a = array_combine($l, $a);
if($a['A'] - $a['B'] != $a['C']) continue;
if($a['A'] + $a['B'] != $a['D']) continue;
if($a['B'] * $a['E'] != $a['F']) continue;
if($a['G'] - $a['H'] != $a['I'] / $a['B']) continue;
echo "ABCDEFGHI\n$i\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment