aboutsummaryrefslogtreecommitdiff
path: root/challenge-119/james-smith/php/ch-1.php
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2021-06-28 16:34:51 +0100
committerdrbaggy <js5@sanger.ac.uk>2021-06-28 16:34:51 +0100
commit55477e94d571fcefcc949906b08a034936d1b96a (patch)
tree5e143a8676b3cab6627f37ce394687cfb7872156 /challenge-119/james-smith/php/ch-1.php
parent0c12514300145d61af1e2e16ff98c668beb09790 (diff)
downloadperlweeklychallenge-club-55477e94d571fcefcc949906b08a034936d1b96a.tar.gz
perlweeklychallenge-club-55477e94d571fcefcc949906b08a034936d1b96a.tar.bz2
perlweeklychallenge-club-55477e94d571fcefcc949906b08a034936d1b96a.zip
just thought I'd add this one in PHP as well!
Diffstat (limited to 'challenge-119/james-smith/php/ch-1.php')
-rw-r--r--challenge-119/james-smith/php/ch-1.php13
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);
+}
+