aboutsummaryrefslogtreecommitdiff
path: root/challenge-121/james-smith
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2021-07-12 08:32:24 +0100
committerdrbaggy <js5@sanger.ac.uk>2021-07-12 08:32:24 +0100
commit1b622bae5cca59329cf4b967f8dfcadc625f0339 (patch)
tree07e8c67a2eeec22893026e6092e4b2bfa2c21852 /challenge-121/james-smith
parent1aa7b6eaba2a58fc1ef0612373e3aed6b61f345d (diff)
downloadperlweeklychallenge-club-1b622bae5cca59329cf4b967f8dfcadc625f0339.tar.gz
perlweeklychallenge-club-1b622bae5cca59329cf4b967f8dfcadc625f0339.tar.bz2
perlweeklychallenge-club-1b622bae5cca59329cf4b967f8dfcadc625f0339.zip
first commit
Diffstat (limited to 'challenge-121/james-smith')
-rw-r--r--challenge-121/james-smith/perl/ch-1.pl24
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-121/james-smith/perl/ch-1.pl b/challenge-121/james-smith/perl/ch-1.pl
new file mode 100644
index 0000000000..1929dc1409
--- /dev/null
+++ b/challenge-121/james-smith/perl/ch-1.pl
@@ -0,0 +1,24 @@
+#!/usr/local/bin/perl
+
+use strict;
+
+use warnings;
+use feature qw(say);
+use Test::More;
+use Benchmark qw(cmpthese timethis);
+use Data::Dumper qw(Dumper);
+
+my @TESTS = (
+ [ 12, 3, 8 ],
+ [ 18, 4, 26 ],
+);
+
+is( flip_bit($_->[0],$_->[1]), $_->[2] ) foreach @TESTS;
+is( flip_bit($_->[2],$_->[1]), $_->[0] ) foreach @TESTS;
+
+done_testing();
+
+sub flip_bit {
+ return $_[0] ^ 1<<$_[1]-1;
+}
+