Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 332
Good morning! Here's your coding interview problem for today.

This problem was asked by Jane Street.

Given integers `M` and `N`, write a program that counts how many positive integer pairs `(a, b)` satisfy the following conditions:
```
a + b = M
a XOR b = N
```

Pull request description:
Day332
Resolves #669.

Patch:
diff --git a/README.md b/README.md
index f87cbd5..eb2a77e 100644
--- a/README.md
+++ b/README.md
@@ -331,6 +331,7 @@ problems from
 * [Day 324](https://github.com/vaskoz/dailycodingproblem-go/issues/658)
 * [Day 325](https://github.com/vaskoz/dailycodingproblem-go/issues/660)
 * [Day 326](https://github.com/vaskoz/dailycodingproblem-go/issues/661)
+* [Day 332](https://github.com/vaskoz/dailycodingproblem-go/issues/669)
 * [Day 333](https://github.com/vaskoz/dailycodingproblem-go/issues/668)
 * [Day 337](https://github.com/vaskoz/dailycodingproblem-go/issues/674)
 * [Day 338](https://github.com/vaskoz/dailycodingproblem-go/issues/675)
diff --git a/day332/problem.go b/day332/problem.go
new file mode 100644
index 0000000..dd2466e
--- /dev/null
+++ b/day332/problem.go
@@ -0,0 +1,24 @@
+package day332
+
+// Pair is a set of the A and B values that satisfy
+// the requirements below.
+type Pair struct {
+	A, B int
+}
+
+// PositiveIntegerPairs returns all candidates
+// that satisfy the following conditions:
+// a + b = M
+// a XOR b = N
+func PositiveIntegerPairs(m, n int) []Pair {
+	var pairs []Pair
+
+	for a := 0; a < (m/2)+1; a++ {
+		b := m - a
+		if a^b == n {
+			pairs = append(pairs, Pair{A: a, B: b})
+		}
+	}
+
+	return pairs
+}


Test patch:
diff --git a/day332/problem_test.go b/day332/problem_test.go
new file mode 100644
index 0000000..fb7be04
--- /dev/null
+++ b/day332/problem_test.go
@@ -0,0 +1,35 @@
+package day332
+
+import (
+	"reflect"
+	"testing"
+)
+
+// nolint
+var testcases = []struct {
+	m, n     int
+	expected []Pair
+}{
+	{
+		100, 4,
+		[]Pair{{48, 52}},
+	},
+}
+
+func TestPositiveIntegerPairs(t *testing.T) {
+	t.Parallel()
+
+	for _, tc := range testcases {
+		if pairs := PositiveIntegerPairs(tc.m, tc.n); !reflect.DeepEqual(pairs, tc.expected) {
+			t.Errorf("Expected %v, got %v", tc.expected, pairs)
+		}
+	}
+}
+
+func BenchmarkPositiveIntegerPairs(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			PositiveIntegerPairs(tc.m, tc.n)
+		}
+	}
+}