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

Issue:
Day 47
Good morning! Here's your coding interview problem for today.

This problem was asked by Facebook.

Given a array of numbers representing the stock prices of a company in chronological order, write a function that calculates the maximum profit you could have made from buying and selling that stock once. You must buy before you can sell it.

For example, given [9, 11, 8, 5, 7, 10], you should return 5, since you could buy the stock at 5 dollars and sell it at 10 dollars.

Pull request:
Day47
Resolves #105 .

Patch:
diff --git a/README.md b/README.md
index e01fd7f..158fb9b 100644
--- a/README.md
+++ b/README.md
@@ -59,3 +59,4 @@ problems from
 * [Day 44](https://github.com/vaskoz/dailycodingproblem-go/issues/99)
 * [Day 45](https://github.com/vaskoz/dailycodingproblem-go/issues/101)
 * [Day 46](https://github.com/vaskoz/dailycodingproblem-go/issues/103)
+* [Day 47](https://github.com/vaskoz/dailycodingproblem-go/issues/105)
diff --git a/day47/problem.go b/day47/problem.go
new file mode 100644
index 0000000..322422d
--- /dev/null
+++ b/day47/problem.go
@@ -0,0 +1,35 @@
+package day47
+
+// MaxProfitBrute calculates the maximum profit from these chronological stock prices.
+// Runs in O(N^2) and O(1) space.
+func MaxProfitBrute(stockPrices []int) int {
+	var maxProfit int
+	for i := range stockPrices {
+		for j := i + 1; j < len(stockPrices); j++ {
+			if profit := stockPrices[j] - stockPrices[i]; profit > maxProfit {
+				maxProfit = profit
+			}
+		}
+	}
+	return maxProfit
+}
+
+// MaxProfit calculates the maximum profit from these chronological stock prices.
+// Runs in O(N) time and O(1) space.
+func MaxProfit(stockPrices []int) int {
+	if len(stockPrices) == 0 {
+		return 0
+	}
+	var maxProfit, lowestPrice int
+	lowestPrice = stockPrices[0]
+	for _, price := range stockPrices {
+		if price < lowestPrice {
+			lowestPrice = price
+		} else {
+			if profit := price - lowestPrice; profit > maxProfit {
+				maxProfit = profit
+			}
+		}
+	}
+	return maxProfit
+}


Test patch:
diff --git a/day47/problem_test.go b/day47/problem_test.go
new file mode 100644
index 0000000..41a0f40
--- /dev/null
+++ b/day47/problem_test.go
@@ -0,0 +1,46 @@
+package day47
+
+import "testing"
+
+var testcases = []struct {
+	prices    []int
+	maxProfit int
+}{
+	{[]int{9, 11, 8, 5, 7, 10}, 5},
+	{[]int{}, 0},
+	{nil, 0},
+}
+
+func TestMaxProfitBrute(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if profit := MaxProfitBrute(tc.prices); tc.maxProfit != profit {
+			t.Errorf("Expected profit %d but got %d", tc.maxProfit, profit)
+		}
+	}
+}
+
+func BenchmarkMaxProfitBrute(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			MaxProfitBrute(tc.prices)
+		}
+	}
+}
+
+func TestMaxProfit(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if profit := MaxProfit(tc.prices); tc.maxProfit != profit {
+			t.Errorf("Expected profit %d but got %d", tc.maxProfit, profit)
+		}
+	}
+}
+
+func BenchmarkMaxProfit(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			MaxProfit(tc.prices)
+		}
+	}
+}
Repository: JuliaPlots/Makie.jl (julia)

Issue:
`contourf!()` gives `StackOverflowError` on `Array{Union{Float64,Missing}}`
- [x] are you running newest version (version from docs) ?
- [??] can you reproduce the bug with a fresh environment ? (`]activate --temp; add Makie`) -- Don't know what to do after `add Makie`
- [x] What platform + GPU are you on? -- macOS 14.2.1, mac mini M2 (early 2023)

Makie v0.20.3

I'm pasting a program that shows the error at the end of this message.  If you replace missing values with `NaN`, a plot is generated as expected.

Is this related to https://github.com/MakieOrg/Makie.jl/issues/1399    ?

```julia
using CairoMakie

b = Array{Union{Float64,Missing}}(rand(Float64, 5, 7))
b[3,3] = missing
b[3,4] = missing

#= #--- works ---
c = replace(b, missing=>NaN)
fig = Figure()
ax = Axis(fig[1,1])
contourf!(ax, axes(c,1), axes(c,2), c) # -> fine
fig
=#

fig = Figure()
ax = Axis(fig[1,1])
contourf!(ax, axes(b,1), axes(b,2), b) # -> fails with "StackOverflowError"
fig
```
The error is
```julia
julia> include("try-makie-missing.jl")
ERROR: LoadError: StackOverflowError:
in expression starting at . . ./try-makie-missing.jl:17
```

Pull request:
Fixes https://github.com/MakieOrg/Makie.jl/issues/3515

Patch:
diff --git a/src/conversions.jl b/src/conversions.jl
index 4727f2715f5..4f75c9ba3e6 100644
--- a/src/conversions.jl
+++ b/src/conversions.jl
@@ -360,7 +360,7 @@ convert_arguments(ct::VertexGrid, x::AbstractMatrix, y::AbstractMatrix) = conver
 Takes one or two ClosedIntervals `x` and `y` and converts them to closed ranges
 with size(z, 1/2).
 """
-function convert_arguments(P::GridBased, x::RangeLike, y::RangeLike, z::AbstractMatrix)
+function convert_arguments(P::GridBased, x::RangeLike, y::RangeLike, z::AbstractMatrix{<: Union{Number, Colorant}})
     convert_arguments(P, to_linspace(x, size(z, 1)), to_linspace(y, size(z, 2)), z)
 end
 


Test patch:
diff --git a/test/conversions.jl b/test/conversions.jl
index 4d27bf4de6f..be31c61cc7c 100644
--- a/test/conversions.jl
+++ b/test/conversions.jl
@@ -358,6 +358,9 @@ end
         @test convert_arguments(Heatmap, 0:10, v2, m3) == (collect(0f0:10f0), o2, o3)
         @test_throws ErrorException convert_arguments(Heatmap, m1, m2, m3)
         @test_throws ErrorException convert_arguments(Heatmap, m1, m2)
+
+        # https://github.com/MakieOrg/Makie.jl/issues/3515
+        @test convert_arguments(Heatmap, 1:8, 1:8, Array{Union{Float64,Missing}}(zeros(8, 8))) == (0.5:8.5, 0.5:8.5, zeros(8, 8))
     end
 end
Repository: okonet/lint-staged (js)

Issue:
Yarn dev dependency not listed
### Description

The build process requires "yarn" package, but it's not listed as a dependency.
"package.json" should be updated to include this devDependency.

### Steps to reproduce

```bash
$ npm install
$ npm test

> lint-staged@0.0.0-development pretest /path/to/lint-staged
> yarn lint

sh: yarn: command not found
npm ERR! Test failed.  See above for more details.

```



Pull request:
chore: Use npm as script runner
Closes #449 
Closes #450.

Patch:
diff --git a/.lintstagedrc.json b/.lintstagedrc.json
index 7b579cb..71cd2fa 100644
--- a/.lintstagedrc.json
+++ b/.lintstagedrc.json
@@ -1,7 +1,7 @@
 {
   "linters": {
     "*.{js,json,md}": ["prettier --write", "git add"],
-    "*.js": ["yarn lint:base --fix", "git add"],
+    "*.js": ["npm run lint:base --fix", "git add"],
     ".*{rc, json}": "jsonlint"
   }
 }
diff --git a/package.json b/package.json
index d2afa78..66a9b41 100644
--- a/package.json
+++ b/package.json
@@ -18,9 +18,9 @@
     "precommit": "node index.js",
     "cz": "git-cz",
     "lint:base": "eslint --rule \"prettier/prettier: 2\"",
-    "lint": "yarn lint:base -- .",
-    "lint:fix": "yarn lint --fix",
-    "pretest": "yarn lint",
+    "lint": "npm run lint:base -- .",
+    "lint:fix": "npm run lint --fix",
+    "pretest": "npm run lint",
     "test": "jest --coverage",
     "test:watch": "jest --watch"
   },


Test patch:
diff --git a/test/__snapshots__/findBin.spec.js.snap b/test/__snapshots__/findBin.spec.js.snap
index c3d3afa..fa4989d 100644
--- a/test/__snapshots__/findBin.spec.js.snap
+++ b/test/__snapshots__/findBin.spec.js.snap
@@ -6,5 +6,5 @@ WARN \`lint-staged\` no longer supports running scripts defined in package.json.
 
 The same behavior can be achieved by changing the command to any of the following:
   - \`npm run lint -- \`
-  - \`yarn lint:base -- . \`"
+  - \`npm run lint:base -- . \`"
 `;
Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 190
Good morning! Here's your coding interview problem for today.

This problem was asked by Facebook.

Given a circular array, compute its maximum subarray sum in O(n) time.

For example, given `[8, -1, 3, 4]`, return `15` as we choose the numbers `3, 4, and 8` where the `8` is obtained from wrapping around.

Given `[-4, 5, 1, 0]`, return `6` as we choose the numbers `5 and 1`.

Pull request:
Day190
Resolves #393.

Patch:
diff --git a/README.md b/README.md
index 8064228..6ce3b31 100644
--- a/README.md
+++ b/README.md
@@ -200,3 +200,4 @@ problems from
 * [Day 187](https://github.com/vaskoz/dailycodingproblem-go/issues/387)
 * [Day 188](https://github.com/vaskoz/dailycodingproblem-go/issues/388)
 * [Day 189](https://github.com/vaskoz/dailycodingproblem-go/issues/391)
+* [Day 190](https://github.com/vaskoz/dailycodingproblem-go/issues/393)
diff --git a/day190/problem.go b/day190/problem.go
new file mode 100644
index 0000000..a7376fe
--- /dev/null
+++ b/day190/problem.go
@@ -0,0 +1,34 @@
+package day190
+
+// MaxWrapSubarraySum returns the maximum possible sum for
+// a subarray in a circular array.
+// Runs in O(N) time and O(N) space because the data is mutated.
+func MaxWrapSubarraySum(nums []int) int {
+	data := make([]int, len(nums))
+	copy(data, nums)
+	maxKadane := KadaneAlg(data)
+	maxWrap := 0
+	for i, v := range data {
+		maxWrap += v
+		data[i] = -data[i]
+	}
+	maxWrap += KadaneAlg(data)
+	return max(maxWrap, maxKadane)
+}
+
+// KadaneAlg implements https://en.wikipedia.org/wiki/Maximum_subarray_problem#Kadane's_algorithm
+func KadaneAlg(nums []int) int {
+	maxEndingHere, maxSoFar := nums[0], nums[0]
+	for i := 1; i < len(nums); i++ {
+		maxEndingHere = max(nums[i], maxEndingHere+nums[i])
+		maxSoFar = max(maxSoFar, maxEndingHere)
+	}
+	return maxSoFar
+}
+
+func max(a, b int) int {
+	if a > b {
+		return a
+	}
+	return b
+}


Test patch:
diff --git a/day190/problem_test.go b/day190/problem_test.go
new file mode 100644
index 0000000..3970bd3
--- /dev/null
+++ b/day190/problem_test.go
@@ -0,0 +1,28 @@
+package day190
+
+import "testing"
+
+var testcases = []struct {
+	nums   []int
+	maxSum int
+}{
+	{[]int{8, -1, 3, 4}, 15},
+	{[]int{-4, 5, 1, 0}, 6},
+}
+
+func TestMaxWrapSubarraySum(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if result := MaxWrapSubarraySum(tc.nums); result != tc.maxSum {
+			t.Errorf("Expected %v, got %v", tc.maxSum, result)
+		}
+	}
+}
+
+func BenchmarkMaxWrapSubarraySum(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			MaxWrapSubarraySum(tc.nums)
+		}
+	}
+}