PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 378
Good morning! Here's your coding interview problem for today.

This problem was asked by Coinbase.

Write a function that takes in a number, string, list, or dictionary and returns its JSON encoding. It should also handle nulls.

For example, given the following input:
```
[None, 123, ["a", "b"], {"c":"d"}]
```
You should return the following, as a string:
```
'[null, 123, ["a", "b"], {"c": "d"}]'
```

Pull request:
Day378
Resolves #762.

Patch:
diff --git a/README.md b/README.md
index 376991b..d7d471a 100644
--- a/README.md
+++ b/README.md
@@ -373,4 +373,5 @@ problems from
 * [Day 375](https://github.com/vaskoz/dailycodingproblem-go/issues/756)
 * [Day 376](https://github.com/vaskoz/dailycodingproblem-go/issues/758)
 * [Day 377](https://github.com/vaskoz/dailycodingproblem-go/issues/760)
+* [Day 378](https://github.com/vaskoz/dailycodingproblem-go/issues/762)
 
diff --git a/day378/problem.go b/day378/problem.go
new file mode 100644
index 0000000..9bfed50
--- /dev/null
+++ b/day378/problem.go
@@ -0,0 +1,14 @@
+package day378
+
+import "encoding/json"
+
+// ToJSON converts arbitrary data into a json string.
+// Delegates to json.Marshal because it exists.
+func ToJSON(data interface{}) string {
+	b, err := json.Marshal(data)
+	if err != nil {
+		return ""
+	}
+
+	return string(b)
+}


Test patch:
diff --git a/day378/problem_test.go b/day378/problem_test.go
new file mode 100644
index 0000000..0344310
--- /dev/null
+++ b/day378/problem_test.go
@@ -0,0 +1,36 @@
+package day378
+
+import "testing"
+
+// nolint
+var testcases = []struct {
+	input    interface{}
+	expected string
+}{
+	{
+		[]interface{}{nil, 123, []string{"a", "b"}, map[string]string{"c": "d"}},
+		`[null,123,["a","b"],{"c":"d"}]`,
+	},
+	{
+		func() {},
+		"",
+	},
+}
+
+func TestToJSON(t *testing.T) {
+	t.Parallel()
+
+	for _, tc := range testcases {
+		if result := ToJSON(tc.input); result != tc.expected {
+			t.Errorf("Expected %v, got %v", tc.expected, result)
+		}
+	}
+}
+
+func BenchmarkToJSON(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			ToJSON(tc.input)
+		}
+	}
+}
Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 178
Good morning! Here's your coding interview problem for today.

This problem was asked by Two Sigma.

Alice wants to join her school's Probability Student Club. Membership dues are computed via one of two simple probabilistic games.

The first game: roll a die repeatedly. Stop rolling once you get a five followed by a six. Your number of rolls is the amount you pay, in dollars.

The second game: same, except that the stopping condition is a five followed by a five.

Which of the two games should Alice elect to play? Does it even matter? Write a program to simulate the two games and calculate their expected value.

Pull request:
Day178
Resolves #367.

Patch:
diff --git a/README.md b/README.md
index a28119e..782c346 100644
--- a/README.md
+++ b/README.md
@@ -186,3 +186,4 @@ problems from
 * [Day 172](https://github.com/vaskoz/dailycodingproblem-go/issues/358)
 * [Day 173](https://github.com/vaskoz/dailycodingproblem-go/issues/360)
 * [Day 177](https://github.com/vaskoz/dailycodingproblem-go/issues/365)
+* [Day 178](https://github.com/vaskoz/dailycodingproblem-go/issues/367)
diff --git a/day178/problem.go b/day178/problem.go
new file mode 100644
index 0000000..adc6bf4
--- /dev/null
+++ b/day178/problem.go
@@ -0,0 +1,53 @@
+package day178
+
+import (
+	"math/rand"
+	"time"
+)
+
+// Dice represents a 6-sided random die.
+type Dice struct {
+	r *rand.Rand
+}
+
+// Next returns the value of the next die throw.
+func (d *Dice) Next() int {
+	if d.r == nil {
+		d.r = rand.New(rand.NewSource(time.Now().UnixNano()))
+	}
+	return d.r.Intn(6) + 1
+}
+
+// FirstGame returns the number of rolls required to meet the condition.
+// Condition is a five followed by a six.
+func FirstGame(d *Dice) int {
+	var rolls int
+	var prevFive bool
+	for {
+		rolls++
+		if value := d.Next(); value == 5 {
+			prevFive = true
+		} else if value == 6 && prevFive {
+			return rolls
+		} else {
+			prevFive = false
+		}
+	}
+}
+
+// SecondGame returns the number of rolls required to meet the condition.
+// Condition is a five followed by another five.
+func SecondGame(d *Dice) int {
+	var rolls int
+	var prevFive bool
+	for {
+		rolls++
+		if value := d.Next(); value == 5 && prevFive {
+			return rolls
+		} else if value == 5 {
+			prevFive = true
+		} else {
+			prevFive = false
+		}
+	}
+}


Test patch:
diff --git a/day178/problem_test.go b/day178/problem_test.go
new file mode 100644
index 0000000..c5c29e0
--- /dev/null
+++ b/day178/problem_test.go
@@ -0,0 +1,33 @@
+package day178
+
+import "testing"
+
+func TestFirstGame(t *testing.T) {
+	t.Parallel()
+	var d Dice
+	if cost := FirstGame(&d); cost > 500 {
+		t.Errorf("Expected result to be around 36, got %v", cost)
+	}
+}
+
+func TestSecondGame(t *testing.T) {
+	t.Parallel()
+	var d Dice
+	if cost := SecondGame(&d); cost > 500 {
+		t.Errorf("Expected result to be around 36, got %v", cost)
+	}
+}
+
+func BenchmarkFirstGame(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		var d Dice
+		FirstGame(&d)
+	}
+}
+
+func BenchmarkSecondGame(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		var d Dice
+		SecondGame(&d)
+	}
+}
Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 56
Good morning! Here's your coding interview problem for today.

This problem was asked by Google.

Given an undirected graph represented as an adjacency matrix and an integer k, write a function to determine whether each vertex in the graph can be colored such that no two adjacent vertices share the same color using at most k colors.

Pull request:
Day56
Resolves #123.

Patch:
diff --git a/README.md b/README.md
index cb383ed..d605c51 100644
--- a/README.md
+++ b/README.md
@@ -67,3 +67,4 @@ problems from
 * [Day 53](https://github.com/vaskoz/dailycodingproblem-go/issues/114)
 * [Day 54](https://github.com/vaskoz/dailycodingproblem-go/issues/118)
 * [Day 55](https://github.com/vaskoz/dailycodingproblem-go/issues/121)
+* [Day 56](https://github.com/vaskoz/dailycodingproblem-go/issues/123)
diff --git a/day56/problem.go b/day56/problem.go
new file mode 100644
index 0000000..8fb1e22
--- /dev/null
+++ b/day56/problem.go
@@ -0,0 +1,31 @@
+package day56
+
+// Graph represents an adjacency list.
+type Graph map[int]map[int]struct{}
+
+// CanColor returns true if the graph can be colored with at
+// most k colors.
+func CanColor(v int, g Graph, color []int, k int) bool {
+	if v == len(g) {
+		return true
+	}
+	for c := 1; c <= k; c++ {
+		if isSafe(v, g, color, c) {
+			color[v] = c
+			if CanColor(v+1, g, color, k) {
+				return true
+			}
+			color[v] = 0
+		}
+	}
+	return false
+}
+
+func isSafe(v int, g Graph, color []int, c int) bool {
+	for i := 0; i < len(g); i++ {
+		if _, found := g[v][i]; found && c == color[i] {
+			return false
+		}
+	}
+	return true
+}


Test patch:
diff --git a/day56/problem_test.go b/day56/problem_test.go
new file mode 100644
index 0000000..97a903f
--- /dev/null
+++ b/day56/problem_test.go
@@ -0,0 +1,67 @@
+package day56
+
+import "testing"
+
+var testcases = []struct {
+	g        Graph
+	k        int
+	canColor bool
+}{
+	{map[int]map[int]struct{}{
+		0: map[int]struct{}{
+			1: struct{}{},
+			2: struct{}{},
+			3: struct{}{},
+		},
+		1: map[int]struct{}{
+			0: struct{}{},
+			2: struct{}{},
+		},
+		2: map[int]struct{}{
+			0: struct{}{},
+			1: struct{}{},
+			3: struct{}{},
+		},
+		3: map[int]struct{}{
+			1: struct{}{},
+			2: struct{}{},
+		},
+	}, 3, true},
+	{map[int]map[int]struct{}{
+		0: map[int]struct{}{
+			1: struct{}{},
+			2: struct{}{},
+			3: struct{}{},
+		},
+		1: map[int]struct{}{
+			0: struct{}{},
+			2: struct{}{},
+		},
+		2: map[int]struct{}{
+			0: struct{}{},
+			1: struct{}{},
+			3: struct{}{},
+		},
+		3: map[int]struct{}{
+			1: struct{}{},
+			2: struct{}{},
+		},
+	}, 2, false},
+}
+
+func TestCanColor(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if canColor := CanColor(0, tc.g, make([]int, len(tc.g)), tc.k); canColor != tc.canColor {
+			t.Errorf("Expected %v got %v", tc.canColor, canColor)
+		}
+	}
+}
+
+func BenchmarkCanColor(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			CanColor(0, tc.g, make([]int, len(tc.g)), tc.k)
+		}
+	}
+}