From 690302784e74b7f75bfb022538418e5e691207b4 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 13:06:22 +0000 Subject: [PATCH] [Sync Iteration] go/hamming/2 --- solutions/go/hamming/2/hamming.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 solutions/go/hamming/2/hamming.go diff --git a/solutions/go/hamming/2/hamming.go b/solutions/go/hamming/2/hamming.go new file mode 100644 index 0000000..660c9a1 --- /dev/null +++ b/solutions/go/hamming/2/hamming.go @@ -0,0 +1,17 @@ +package hamming + +import "errors" + +func Distance(a, b string) (int, error) { + if len(a) != len(b) { + return 0, errors.New("Length of strands not equal.") + } + + diff := 0 + for i := 0; i < len(a); i++ { + if a[i] != b[i] { + diff++ + } + } + return diff, nil +}