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

Issue:
Day 36
Good morning! Here's your coding interview problem for today.

This problem was asked by Dropbox.

Given the root to a binary search tree, find the second largest node in the tree.

Pull request:
Day36
Resolves #79 .

Patch:
diff --git a/README.md b/README.md
index bdb5283..f9dafaf 100644
--- a/README.md
+++ b/README.md
@@ -47,3 +47,4 @@ problems from
 * [Day 31](https://github.com/vaskoz/dailycodingproblem-go/issues/71)
 * [Day 33](https://github.com/vaskoz/dailycodingproblem-go/issues/73)
 * [Day 35](https://github.com/vaskoz/dailycodingproblem-go/issues/77)
+* [Day 36](https://github.com/vaskoz/dailycodingproblem-go/issues/79)
diff --git a/day36/problem.go b/day36/problem.go
new file mode 100644
index 0000000..cade081
--- /dev/null
+++ b/day36/problem.go
@@ -0,0 +1,29 @@
+package day36
+
+// BST represents a binary search tree.
+type BST struct {
+	val         int
+	left, right *BST
+}
+
+// SecondLargest takes the root of a binary search tree and returns the
+// pointer to the 2nd largest value.
+// Runs in O(height) and O(1) space.
+func SecondLargest(root *BST) int {
+	var prev, cur *BST
+	if root.right != nil {
+		prev = root
+		cur = root.right
+		for cur.right != nil {
+			cur = cur.right
+			prev = prev.right
+		}
+		cur = prev
+	} else {
+		cur = root.left
+		for cur.right != nil {
+			cur = cur.right
+		}
+	}
+	return cur.val
+}


Test patch:
diff --git a/day36/problem_test.go b/day36/problem_test.go
new file mode 100644
index 0000000..00d65d5
--- /dev/null
+++ b/day36/problem_test.go
@@ -0,0 +1,28 @@
+package day36
+
+import "testing"
+
+var testcases = []struct {
+	root     *BST
+	expected int
+}{
+	{&BST{10, nil, &BST{20, nil, &BST{30, nil, nil}}}, 20},
+	{&BST{10, &BST{5, nil, &BST{8, nil, nil}}, nil}, 8},
+}
+
+func TestSecondLargest(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if result := SecondLargest(tc.root); result != tc.expected {
+			t.Errorf("Expected %v got %v", tc.expected, result)
+		}
+	}
+}
+
+func BenchmarkSecondLargest(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			SecondLargest(tc.root)
+		}
+	}
+}
Repository: JuliaAI/MLJBase.jl (julia)

Issue:
target_scitype for SupervisedPipelines
Hello everyone,

I think we could add a `target_scitype` directive for SupervisedPipelines.

```julia

LinearRegressor = @load LinearRegressor pkg=MLJLinearModels verbosity = 0
pipe = (X -> coerce(X, :age=>Continuous)) |> ContinuousEncoder() |> LinearRegressor()
target_scitype(pipe)
```

will result in Unknown.

The following should work and happy to try and make the change if your concern is somewhere else:

```julia

target_scitype(p::SupervisedPipeline) = target_scitype(supervised_component(p))
```

Pull request:
To solve https://github.com/JuliaAI/MLJBase.jl/issues/710

Patch:
diff --git a/src/composition/models/pipelines.jl b/src/composition/models/pipelines.jl
index 41cae336..8379da7e 100644
--- a/src/composition/models/pipelines.jl
+++ b/src/composition/models/pipelines.jl
@@ -613,3 +613,5 @@ function iteration_parameter(pipe::SupervisedPipeline)
     name =  supervised_component_name(pipe)
     MLJBase.prepend(name, iteration_parameter(model))
 end
+
+target_scitype(p::SupervisedPipeline) = target_scitype(supervised_component(p))
\ No newline at end of file


Test patch:
diff --git a/test/composition/models/pipelines.jl b/test/composition/models/pipelines.jl
index defe883f..28355387 100644
--- a/test/composition/models/pipelines.jl
+++ b/test/composition/models/pipelines.jl
@@ -358,6 +358,9 @@ end
     MLJBase.tree(mach.fitresult.predict).arg1.model.features == [:x3, ]
     @test predict(mach, X) ≈ hand_built
 
+    # Check target_scitype of a supervised pipeline is the same as the supervised component
+    @test target_scitype(p) == target_scitype(KNNRegressor())
+
     # test cache is set correctly internally:
     @test all(fitted_params(mach).machines) do m
         MLJBase._cache_status(m)  == " caches data"
@@ -408,6 +411,9 @@ end
     fit!(mach, verbosity=0)
     @test predict(mach, X) == fill('f', 7)
 
+    # Check target_scitype of a supervised pipeline is the same as the supervised component
+    @test target_scitype(p) == target_scitype(ConstantClassifier())
+    
     # test pipelines with weights:
     w = map(y) do η
         η == 'm' ? 100 : 1
@@ -436,6 +442,9 @@ MLJBase.transform(transf::MyTransformer3, verbosity, X) =
                    MyTransformer3(:age))
     mach = fit!(machine(p99, X), verbosity=0)
     @test transform(mach, X) == float.(X.age)
+
+    # Check target_scitype of an unsupervised pipeline is Unknown
+    @test target_scitype(p99) == Unknown
 end
 
 @testset "integration 5" begin
@@ -473,6 +482,8 @@ end
     y = transform(mach, x)
     x̂ = inverse_transform(mach, y)
     @test isapprox(x, x̂)
+    # Check target_scitype of an unsupervised pipeline is Unknown
+    @test target_scitype(p) == Unknown
 end
 
 # A dummy clustering model:
Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 224
Good morning! Here's your coding interview problem for today.

This problem was asked by Amazon.

Given a sorted array, find the smallest positive integer that is not the sum of a subset of the array.

For example, for the input `[1, 2, 3, 10]`, you should return `7`.

Do this in O(N) time.

Pull request:
Day224
Resolves #462.

Patch:
diff --git a/README.md b/README.md
index 5a4dc8b..7f50028 100644
--- a/README.md
+++ b/README.md
@@ -234,3 +234,4 @@ problems from
 * [Day 221](https://github.com/vaskoz/dailycodingproblem-go/issues/454)
 * [Day 222](https://github.com/vaskoz/dailycodingproblem-go/issues/458)
 * [Day 223](https://github.com/vaskoz/dailycodingproblem-go/issues/460)
+* [Day 224](https://github.com/vaskoz/dailycodingproblem-go/issues/462)
diff --git a/day224/problem.go b/day224/problem.go
new file mode 100644
index 0000000..1dae348
--- /dev/null
+++ b/day224/problem.go
@@ -0,0 +1,13 @@
+package day224
+
+// SmallestPositiveIntNotInSubsetSum returns the
+// smallest positive integer that is not the sum of a subset of the array,
+// given a sorted array.
+// Runs in O(N) time and O(1) space.
+func SmallestPositiveIntNotInSubsetSum(nums []int) int {
+	result := 1
+	for i := 0; i < len(nums) && nums[i] <= result; i++ {
+		result += nums[i]
+	}
+	return result
+}


Test patch:
diff --git a/day224/problem_test.go b/day224/problem_test.go
new file mode 100644
index 0000000..a8e6924
--- /dev/null
+++ b/day224/problem_test.go
@@ -0,0 +1,31 @@
+package day224
+
+import "testing"
+
+var testcases = []struct {
+	nums     []int
+	smallest int
+}{
+	{[]int{1, 2, 3, 10}, 7},
+	{[]int{1, 3, 4, 5}, 2},
+	{[]int{1, 2, 6, 10, 11, 15}, 4},
+	{[]int{1, 1, 1, 1}, 5},
+	{[]int{1, 1, 3, 4}, 10},
+}
+
+func TestSmallestPositiveIntNotInSubsetSum(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if result := SmallestPositiveIntNotInSubsetSum(tc.nums); result != tc.smallest {
+			t.Errorf("For %v, expected %v, got %v", tc.nums, tc.smallest, result)
+		}
+	}
+}
+
+func BenchmarkSmallestPositiveIntNotInSubsetSum(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			SmallestPositiveIntNotInSubsetSum(tc.nums)
+		}
+	}
+}
Repository: amoffat/sh (python)

Issue:
Accept pathlib.Path objects for _out and _err
Currently, if I pass `pathlib.Path` object to any command as its `_out` argument, it is effectively ignored without any error:
```
import sh
from pathlib import Path

out = Path('/tmp/out')
sh.echo('hello', _out=out)
print(out.exists())  # False
```

Current workaround is to convert path to `string` before passing it to sh:
```
sh.echo('hello', _out=str(out))
print(out.exists())  # True
```

It would be nice to also accept Paths "as is", or at least raise an error if something unsupported is passed for `_out` or `_err`.

Pull request:
Accept pathlib.Path objects for stdout/stderr
Fix #597.
I decided to not add an additional import for `pathlib.Path` and instead check if the object passed is "path-like" according to [PEP-519](https://www.python.org/dev/peps/pep-0519/).

Patch:
diff --git a/sh.py b/sh.py
index 5fc9c2c..f14f63a 100644
--- a/sh.py
+++ b/sh.py
@@ -990,7 +990,7 @@ class RunningCommand(object):
 
 
 def output_redirect_is_filename(out):
-    return isinstance(out, basestring)
+    return isinstance(out, basestring) or hasattr(out, '__fspath__')
 
 
 def get_prepend_stack():


Test patch:
diff --git a/test.py b/test.py
index 0e4b206..6d17a25 100644
--- a/test.py
+++ b/test.py
@@ -136,6 +136,7 @@ requires_utf8 = skipUnless(sh.DEFAULT_ENCODING == "UTF-8", "System encoding must
 not_macos = skipUnless(not IS_MACOS, "Doesn't work on MacOS")
 requires_py3 = skipUnless(IS_PY3, "Test only works on Python 3")
 requires_py35 = skipUnless(IS_PY3 and MINOR_VER >= 5, "Test only works on Python 3.5 or higher")
+requires_py36 = skipUnless(IS_PY3 and MINOR_VER >= 6, "Test only works on Python 3.6 or higher")
 
 
 def requires_poller(poller):
@@ -1772,6 +1773,15 @@ exit(code)
         outfile.seek(0)
         self.assertEqual(b"output\n", outfile.read())
 
+    @requires_py36
+    def test_out_pathlike(self):
+        from pathlib import Path
+        outfile = tempfile.NamedTemporaryFile()
+        py = create_tmp_test("print('output')")
+        python(py.name, _out=Path(outfile.name))
+        outfile.seek(0)
+        self.assertEqual(b"output\n", outfile.read())
+
     def test_bg_exit_code(self):
         py = create_tmp_test("""
 import time