From d1fa3b368dcbc39eb87545bd5af22729c6add022 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Mon, 27 Apr 2026 12:18:11 +0000 Subject: [PATCH] [Sync Iteration] go/hamming/1 --- solutions/go/hamming/1/hamming.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 solutions/go/hamming/1/hamming.go diff --git a/solutions/go/hamming/1/hamming.go b/solutions/go/hamming/1/hamming.go new file mode 100644 index 0000000..28bdff0 --- /dev/null +++ b/solutions/go/hamming/1/hamming.go @@ -0,0 +1,19 @@ +package hamming + +import ( + "fmt" + ) + +func Distance(a, b string) (int, error) { + if len(a) != len(b) { + return 0, fmt.Errorf("Length of strands not equal.") + } + + diff:=0 + for i:=0; i < len(a); i++ { + if a[i] != b[i] { + diff++ + } + } + return diff, nil +}