diff options
| -rw-r--r-- | challenge-119/james-smith/php/ch-1.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/challenge-119/james-smith/php/ch-1.php b/challenge-119/james-smith/php/ch-1.php new file mode 100644 index 0000000000..955a0b4380 --- /dev/null +++ b/challenge-119/james-smith/php/ch-1.php @@ -0,0 +1,13 @@ +<?php + +$TESTS = [ [101,86],[18,33] ]; + +foreach($TESTS as $_ ) { + echo swap_nibble($_[0]) == $_[1] ? 'OK' : '--',"\n"; + echo swap_nibble($_[1]) == $_[0] ? 'OK' : '--',"\n"; +} + +function swap_nibble($_) { + return ($_>>4) | (($_&15)<<4); +} + |
