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

Issue:
Day 399
Good morning! Here's your coding interview problem for today.

This problem was asked by Facebook.

Given a list of strictly positive integers, partition the list into 3 contiguous partitions which each sum up to the same value. If not possible, return null.

For example, given the following list:

`[3, 5, 8, 0, 8]`
Return the following 3 partitions:
```
[[3, 5],
 [8, 0],
 [8]]
```
Which each add up to 8.

Pull request:
Day399
Resolves #801.

Patch:
diff --git a/README.md b/README.md
index 86c0901..50cc17b 100644
--- a/README.md
+++ b/README.md
@@ -391,4 +391,5 @@ problems from
 * [Day 396](https://github.com/vaskoz/dailycodingproblem-go/issues/795)
 * [Day 397](https://github.com/vaskoz/dailycodingproblem-go/issues/797)
 * [Day 398](https://github.com/vaskoz/dailycodingproblem-go/issues/799)
+* [Day 399](https://github.com/vaskoz/dailycodingproblem-go/issues/801)
 
diff --git a/day399/problem.go b/day399/problem.go
new file mode 100644
index 0000000..29d32df
--- /dev/null
+++ b/day399/problem.go
@@ -0,0 +1,44 @@
+package day399
+
+import (
+	"errors"
+)
+
+var errNotPossible = errors.New("impossible to get 3 partitions equal")
+
+// PartitionIntoThreeEqualSum tries to partition the input
+// into 3 contiguous sets with equal sums.
+func PartitionIntoThreeEqualSum(nums []int) ([][]int, error) {
+	var sum int
+
+	for _, num := range nums {
+		sum += num
+	}
+
+	target := sum / 3
+
+	if sum%3 != 0 {
+		return nil, errNotPossible
+	}
+
+	ans := make([][]int, 3)
+	pos := 0
+	sum = 0
+
+	for _, num := range nums {
+		sum += num
+
+		switch {
+		case sum < target:
+			ans[pos] = append(ans[pos], num)
+		case sum == target:
+			ans[pos] = append(ans[pos], num)
+			sum = 0
+			pos++
+		default:
+			return nil, errNotPossible
+		}
+	}
+
+	return ans, nil
+}


Test patch:
diff --git a/day399/problem_test.go b/day399/problem_test.go
new file mode 100644
index 0000000..42ac3f2
--- /dev/null
+++ b/day399/problem_test.go
@@ -0,0 +1,52 @@
+package day399
+
+import (
+	"reflect"
+	"testing"
+)
+
+// nolint
+var testcases = []struct {
+	input       []int
+	expected    [][]int
+	expectedErr error
+}{
+	{
+		[]int{3, 5, 8, 0, 8},
+		[][]int{
+			{3, 5},
+			{8},
+			{0, 8},
+		},
+		nil,
+	},
+	{
+		[]int{3, 5, 8, 0, 9},
+		nil,
+		errNotPossible,
+	},
+	{
+		[]int{5, 5, 8, 0, 9},
+		nil,
+		errNotPossible,
+	},
+}
+
+func TestPartitionIntoThreeEqualSum(t *testing.T) {
+	t.Parallel()
+
+	for _, tc := range testcases {
+		if res, err := PartitionIntoThreeEqualSum(tc.input); !reflect.DeepEqual(res, tc.expected) ||
+			tc.expectedErr != err {
+			t.Errorf("Expected(%v,%v), got (%v,%v)", tc.expected, tc.expectedErr, res, err)
+		}
+	}
+}
+
+func BenchmarkPartitionIntoThreeEqualSum(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			PartitionIntoThreeEqualSum(tc.input) // nolint
+		}
+	}
+}
Repository: ruby/prism (c)

Issue:
Different escaping if not using default regexp syntaxes
Seems if you use same char you are escaping to delimit your regexp it removes the escaping:

```ruby
p /\!/       #=> /\!/
p %r{\!}  #=> /\!/
p %!\!!    #=> /!/
p %^\!^  #=> /\!/
```



Pull request:
Regexp terminator escapes
I don't pretend to understand what is going on here, but basically if you use a regular expression opening/closing that is not `/` then sometimes you need an escape and sometimes you don't. I derived these rules by running every value in US-ASCII until it matched.

Fixes #2031.

Patch:
diff --git a/src/prism.c b/src/prism.c
index 1b5d82b4..015193ff 100644
--- a/src/prism.c
+++ b/src/prism.c
@@ -9478,7 +9478,9 @@ parser_lex(pm_parser_t *parser) {
                         case '\r':
                             parser->current.end++;
                             if (peek(parser) != '\n') {
-                                pm_token_buffer_push(&token_buffer, '\\');
+                                if (lex_mode->as.regexp.terminator != '\r') {
+                                    pm_token_buffer_push(&token_buffer, '\\');
+                                }
                                 pm_token_buffer_push(&token_buffer, '\r');
                                 break;
                             }
@@ -9506,7 +9508,20 @@ parser_lex(pm_parser_t *parser) {
                             escape_read(parser, &token_buffer.buffer, PM_ESCAPE_FLAG_REGEXP);
                             break;
                         default:
-                            if (lex_mode->as.regexp.terminator == '/' && peeked == '/') {
+                            if (lex_mode->as.regexp.terminator == peeked) {
+                                // Some characters when they are used as the
+                                // terminator also receive an escape. They are
+                                // enumerated here.
+                                switch (peeked) {
+                                    case '$': case ')': case '*': case '+':
+                                    case '.': case '>': case '?': case ']':
+                                    case '^': case '|': case '}':
+                                        pm_token_buffer_push(&token_buffer, '\\');
+                                        break;
+                                    default:
+                                        break;
+                                }
+
                                 pm_token_buffer_push(&token_buffer, peeked);
                                 parser->current.end++;
                                 break;


Test patch:
diff --git a/test/prism/snapshots/seattlerb/bug190.txt b/test/prism/snapshots/seattlerb/bug190.txt
index ef4411dd..f7eaefa5 100644
--- a/test/prism/snapshots/seattlerb/bug190.txt
+++ b/test/prism/snapshots/seattlerb/bug190.txt
@@ -8,4 +8,4 @@
             ├── opening_loc: (1,0)-(1,3) = "%r'"
             ├── content_loc: (1,3)-(1,5) = "\\'"
             ├── closing_loc: (1,5)-(1,6) = "'"
-            └── unescaped: "\\'"
+            └── unescaped: "'"