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

Issue:
Day 291
Good morning! Here's your coding interview problem for today.

This problem was asked by Glassdoor.

An imminent hurricane threatens the coastal town of Codeville. If at most two people can fit in a rescue boat, and the maximum weight limit for a given boat is `k`, determine how many boats will be needed to save everyone.

For example, given a population with weights `[100, 200, 150, 80]` and a boat limit of `200`, the smallest number of boats required will be three.

Pull request:
Day291
Resolves #596.

Patch:
diff --git a/README.md b/README.md
index d8ba37f..e9aac2b 100644
--- a/README.md
+++ b/README.md
@@ -300,3 +300,4 @@ problems from
 * [Day 287](https://github.com/vaskoz/dailycodingproblem-go/issues/587)
 * [Day 288](https://github.com/vaskoz/dailycodingproblem-go/issues/590)
 * [Day 290](https://github.com/vaskoz/dailycodingproblem-go/issues/594)
+* [Day 291](https://github.com/vaskoz/dailycodingproblem-go/issues/596)
diff --git a/day291/problem.go b/day291/problem.go
new file mode 100644
index 0000000..3c2e83f
--- /dev/null
+++ b/day291/problem.go
@@ -0,0 +1,31 @@
+package day291
+
+import "sort"
+
+// BoatsNeededForEvacuation returns the minimum number of boats needed to
+// evacuate Codeville before the hurricane.
+// peopleWeights is a list of the people needing evacuation and k is the
+// max weight allowed on each boat.
+func BoatsNeededForEvacuation(peopleWeights []int, k int) int {
+	weights := make([]int, len(peopleWeights))
+	copy(weights, peopleWeights)
+	sort.Sort(sort.Reverse(sort.IntSlice(weights)))
+	var boats int
+	for i, weight := range weights {
+		if weight != -1 {
+			if weight > k {
+				panic("individual is over boat's weight. can't evacuate.")
+			}
+			remaining := k - weight
+			weights[i] = -1
+			for j := i + 1; j < len(weights); j++ {
+				if weights[j] != -1 && weights[j] <= remaining {
+					weights[j] = -1
+					break
+				}
+			}
+			boats++
+		}
+	}
+	return boats
+}


Test patch:
diff --git a/day291/problem_test.go b/day291/problem_test.go
new file mode 100644
index 0000000..e61777e
--- /dev/null
+++ b/day291/problem_test.go
@@ -0,0 +1,39 @@
+package day291
+
+import "testing"
+
+// nolint
+var testcases = []struct {
+	weights []int
+	k       int
+	boats   int
+}{
+	{[]int{100, 200, 150, 80}, 200, 3},
+}
+
+func TestBoatsNeededForEvacuation(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if boats := BoatsNeededForEvacuation(tc.weights, tc.k); boats != tc.boats {
+			t.Errorf("Expected %v, got %v", tc.boats, boats)
+		}
+	}
+}
+
+func TestBoatsNeededForEvacuationCant(t *testing.T) {
+	t.Parallel()
+	defer func() {
+		if err := recover(); err == nil {
+			t.Errorf("Expected a panic for individuals that weigh more than boat can hold")
+		}
+	}()
+	BoatsNeededForEvacuation([]int{200, 250, 300, 301}, 300)
+}
+
+func BenchmarkBoatsNeededForEvacuation(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			BoatsNeededForEvacuation(tc.weights, tc.k)
+		}
+	}
+}
Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 316
Good morning! Here's your coding interview problem for today.

This problem was asked by Snapchat.

You are given an array of length N, where each element i represents the number of ways we can produce i units of change. For example, `[1, 0, 1, 1, 2]` would indicate that there is only one way to make `0`, `2`, or `3` units, and two ways of making 4 units.

Given such an array, determine the denominations that must be in use. In the case above, for example, there must be coins with value `2, 3, and 4`.

Pull request:
Day316
Resolves #644.

Patch:
diff --git a/README.md b/README.md
index c05c33b..0ff32a8 100644
--- a/README.md
+++ b/README.md
@@ -326,6 +326,7 @@ problems from
 * [Day 313](https://github.com/vaskoz/dailycodingproblem-go/issues/639)
 * [Day 314](https://github.com/vaskoz/dailycodingproblem-go/issues/640)
 * [Day 315](https://github.com/vaskoz/dailycodingproblem-go/issues/642)
+* [Day 316](https://github.com/vaskoz/dailycodingproblem-go/issues/644)
 * [Day 317](https://github.com/vaskoz/dailycodingproblem-go/issues/645)
 * [Day 320](https://github.com/vaskoz/dailycodingproblem-go/issues/650)
 * [Day 321](https://github.com/vaskoz/dailycodingproblem-go/issues/651)
diff --git a/day316/problem.go b/day316/problem.go
new file mode 100644
index 0000000..c65a90f
--- /dev/null
+++ b/day316/problem.go
@@ -0,0 +1,43 @@
+package day316
+
+import (
+	"sort"
+)
+
+// CoinDenominationsNeeded returns the required denominations
+// to achieve the number of ways to make change.
+func CoinDenominationsNeeded(ways []int) []int {
+	denoms := make(map[int]struct{})
+
+	for d, way := range ways {
+		if others := waysToProduce(d, denoms); (way == 1 && d > 0) || others == way-1 {
+			denoms[d] = struct{}{}
+		}
+	}
+
+	res := make([]int, 0, len(denoms))
+
+	for k := range denoms {
+		res = append(res, k)
+	}
+
+	sort.Ints(res)
+
+	return res
+}
+
+func waysToProduce(target int, denoms map[int]struct{}) int {
+	if _, found := denoms[target]; found || target == 0 {
+		return 1
+	}
+
+	ways := 0
+
+	for k := range denoms {
+		if target%k == 0 {
+			ways += waysToProduce(target/k, denoms)
+		}
+	}
+
+	return ways
+}


Test patch:
diff --git a/day316/problem_test.go b/day316/problem_test.go
new file mode 100644
index 0000000..b29e108
--- /dev/null
+++ b/day316/problem_test.go
@@ -0,0 +1,31 @@
+package day316
+
+import (
+	"reflect"
+	"testing"
+)
+
+// nolint
+var testcases = []struct {
+	ways, denoms []int
+}{
+	{[]int{1, 0, 1, 1, 2}, []int{2, 3, 4}},
+}
+
+func TestCoinDenominationsNeeded(t *testing.T) {
+	t.Parallel()
+
+	for _, tc := range testcases {
+		if res := CoinDenominationsNeeded(tc.ways); !reflect.DeepEqual(res, tc.denoms) {
+			t.Errorf("Expected %v, got %v", tc.denoms, res)
+		}
+	}
+}
+
+func BenchmarkCoinDenominationsNeeded(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			CoinDenominationsNeeded(tc.ways)
+		}
+	}
+}
Repository: libgit2/git2go (go)

Issue:
Support git_repository_message / remove
It would be nice to support https://libgit2.org/libgit2/#HEAD/group/repository/git_repository_message , which is introduced in  v0.21.0. Thank you!

Pull request:
Support git_repository_message, git_repository_message_remove (#734)
Closes #646

(cherry picked from commit 07147a8ea8ccf216fa490e7ed4ec84e7c5f5d9ee)

Patch:
diff --git a/repository.go b/repository.go
index d2b9961..bba5700 100644
--- a/repository.go
+++ b/repository.go
@@ -688,3 +688,39 @@ func (r *Repository) ClearGitIgnoreRules() error {
 	}
 	return nil
 }
+
+// Message retrieves git's prepared message.
+// Operations such as git revert/cherry-pick/merge with the -n option stop just
+// short of creating a commit with the changes and save their prepared message
+// in .git/MERGE_MSG so the next git-commit execution can present it to the
+// user for them to amend if they wish.
+//
+// Use this function to get the contents of this file. Don't forget to remove
+// the file after you create the commit.
+func (r *Repository) Message() (string, error) {
+	buf := C.git_buf{}
+	defer C.git_buf_dispose(&buf)
+
+	runtime.LockOSThread()
+	defer runtime.UnlockOSThread()
+
+	cErr := C.git_repository_message(&buf, r.ptr)
+	runtime.KeepAlive(r)
+	if cErr < 0 {
+		return "", MakeGitError(cErr)
+	}
+	return C.GoString(buf.ptr), nil
+}
+
+// RemoveMessage removes git's prepared message.
+func (r *Repository) RemoveMessage() error {
+	runtime.LockOSThread()
+	defer runtime.UnlockOSThread()
+
+	cErr := C.git_repository_message_remove(r.ptr)
+	runtime.KeepAlive(r)
+	if cErr < 0 {
+		return MakeGitError(cErr)
+	}
+	return  nil
+}


Test patch:
diff --git a/merge_test.go b/merge_test.go
index d49d07c..72b1a26 100644
--- a/merge_test.go
+++ b/merge_test.go
@@ -43,6 +43,14 @@ func TestMergeWithSelf(t *testing.T) {
 	mergeHeads[0] = mergeHead
 	err = repo.Merge(mergeHeads, nil, nil)
 	checkFatal(t, err)
+
+	mergeMessage, err := repo.Message()
+	checkFatal(t, err)
+
+	expectedMessage := "Merge branch 'master'\n"
+	if mergeMessage != expectedMessage {
+		t.Errorf("merge Message = %v, want %v", mergeMessage, expectedMessage)
+	}
 }
 
 func TestMergeAnalysisWithSelf(t *testing.T) {
Repository: hyrodium/BasicBSpline.jl (julia)

Issue:
`InexactError` with `fittingcontrolpoints`
```julia
julia> P = BSplineSpace{3}(KnotVector(1:12))
BSplineSpace{3, Int64}(KnotVector([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]))

julia> BasicBSpline.innerproduct_R(x->x, (P,))
ERROR: InexactError: Int64(0.17499999999999996)
Stacktrace:
 [1] Int64
   @ ./float.jl:812 [inlined]
 [2] convert
   @ ./number.jl:7 [inlined]
 [3] setindex!
   @ ./array.jl:903 [inlined]
 [4] innerproduct_I(func::var"#3#4", Ps::Tuple{BSplineSpace{3, Int64}})
   @ BasicBSpline ~/.julia/dev/BasicBSpline/src/_Fitting.jl:95
 [5] innerproduct_R(func::var"#3#4", Ps::Tuple{BSplineSpace{3, Int64}})
   @ BasicBSpline ~/.julia/dev/BasicBSpline/src/_Fitting.jl:200
 [6] top-level scope
   @ REPL[12]:1
```

Pull request:
This PR fixes #214.

Patch:
diff --git a/src/_Fitting.jl b/src/_Fitting.jl
index c889eefa3..c270cf210 100644
--- a/src/_Fitting.jl
+++ b/src/_Fitting.jl
@@ -78,7 +78,7 @@ function innerproduct_I(func, Ps::Tuple{<:AbstractBSplineSpace{p₁}}) where {p
     l₁ = length(k₁)
     nodes₁, weights₁ = SVector{p₁+1}.(gausslegendre(p₁+1))
 
-    sample_point = func(leftendpoint(domain(P₁)))
+    sample_point = func(float(leftendpoint(domain(P₁))))
     b = Array{typeof(sample_point),1}(undef, n₁)
     fill!(b, zero(sample_point))
 
@@ -106,7 +106,7 @@ function innerproduct_I(func, Ps::Tuple{<:AbstractBSplineSpace{p₁},<:AbstractB
     nodes₁, weights₁ = SVector{p₁+1}.(gausslegendre(p₁+1))
     nodes₂, weights₂ = SVector{p₂+1}.(gausslegendre(p₂+1))
 
-    sample_point = func(leftendpoint(domain(P₁)),leftendpoint(domain(P₂)))
+    sample_point = func(float(leftendpoint(domain(P₁))),float(leftendpoint(domain(P₂))))
     b = Array{typeof(sample_point),2}(undef, n₁, n₂)
     fill!(b, zero(sample_point))
 
@@ -146,7 +146,7 @@ function innerproduct_I(func, Ps::Tuple{<:AbstractBSplineSpace{p₁},<:AbstractB
     nodes₂, weights₂ = SVector{p₂+1}.(gausslegendre(p₂+1))
     nodes₃, weights₃ = SVector{p₃+1}.(gausslegendre(p₃+1))
 
-    sample_point = func(leftendpoint(domain(P₁)),leftendpoint(domain(P₂)),leftendpoint(domain(P₃)))
+    sample_point = func(float(leftendpoint(domain(P₁))),float(leftendpoint(domain(P₂))),float(leftendpoint(domain(P₃))))
     b = Array{typeof(sample_point),3}(undef, n₁, n₂, n₃)
     fill!(b, zero(sample_point))
 


Test patch:
diff --git a/test/test_Fitting.jl b/test/test_Fitting.jl
index 5bbdb1df6..ad1379f86 100644
--- a/test/test_Fitting.jl
+++ b/test/test_Fitting.jl
@@ -226,4 +226,12 @@
             @test BasicBSpline.innerproduct_R(BSplineSpace(P)) isa Symmetric{Float64,Matrix{Float64}}
         end
     end
+
+    @testset "specific issues" begin
+        # https://github.com/hyrodium/BasicBSpline.jl/issues/214
+        P = BSplineSpace{3}(KnotVector(1:12))
+        @test BasicBSpline.innerproduct_R(t->t, (P,)) ≈ 3:10
+        @test BasicBSpline.innerproduct_R((t1,t2)->t1+t2, (P,P)) ≈ [i+j for i in 3:10, j in 3:10]
+        @test BasicBSpline.innerproduct_R((t1,t2,t3)->t1+t2+t3, (P,P,P)) ≈ [i+j+k for i in 3:10, j in 3:10, k in 3:10]
+    end
 end