From 95dbcc33ee5a65db0b8ea65f364d69e75b644cfe Mon Sep 17 00:00:00 2001 From: solomongamid Date: Tue, 12 Jul 2016 15:06:55 +0200 Subject: [PATCH 1/4] suliman hamming addition --- hamming-suliman.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 hamming-suliman.php diff --git a/hamming-suliman.php b/hamming-suliman.php new file mode 100644 index 0000000..1952678 --- /dev/null +++ b/hamming-suliman.php @@ -0,0 +1,22 @@ + From aeb6b84d1d50bca25605e0f7436d1ff2afb51b2b Mon Sep 17 00:00:00 2001 From: suliman Date: Tue, 12 Jul 2016 15:46:08 +0200 Subject: [PATCH 2/4] Update hamming-suliman.php --- hamming-suliman.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hamming-suliman.php b/hamming-suliman.php index 1952678..0f7b82f 100644 --- a/hamming-suliman.php +++ b/hamming-suliman.php @@ -5,7 +5,7 @@ // convenience to get you started writing code faster. // -function Distance($a, $b) +function distance($a, $b) { $s1 = str_split($a); $s2 = str_split($b); @@ -17,6 +17,6 @@ function Distance($a, $b) } -echo Distance('10111010','01010111'); +echo distance('10111010','01010111'); ?> From 749ad8a229b1c8b6b35baaed2354769d7dfa7e36 Mon Sep 17 00:00:00 2001 From: suliman Date: Tue, 12 Jul 2016 17:41:27 +0200 Subject: [PATCH 3/4] Delete hamming-suliman.php --- hamming-suliman.php | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 hamming-suliman.php diff --git a/hamming-suliman.php b/hamming-suliman.php deleted file mode 100644 index 0f7b82f..0000000 --- a/hamming-suliman.php +++ /dev/null @@ -1,22 +0,0 @@ - From f375d0fe9ac5121667a24a93f7237df7811cb71e Mon Sep 17 00:00:00 2001 From: suliman Date: Tue, 12 Jul 2016 17:44:12 +0200 Subject: [PATCH 4/4] Update hamming.php --- hamming.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hamming.php b/hamming.php index b457e65..29b4012 100644 --- a/hamming.php +++ b/hamming.php @@ -5,9 +5,18 @@ // convenience to get you started writing code faster. // -function distance($a, $b) +function Distance($a, $b) { - // - // YOUR CODE GOES HERE - // + $s1 = str_split($a); + $s2 = str_split($b); + $dh = 0; + for ($i = 0; $i < count($s1); $i++) + if ($s1[$i] != $s2[$i]) + $dh++; + return $dh; + + } +echo Distance('10111010','01010111'); + +?>