aboutsummaryrefslogtreecommitdiff
path: root/challenge-119/james-smith/php/ch-1.php
blob: 955a0b4380339093f603001fcba427fbb2d4b7ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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);
}