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

Issue:
Day 153
Good morning! Here's your coding interview problem for today.

Find an efficient algorithm to find the smallest distance (measured in number of words) between any two given words in a string.

For example, given words "hello", and "world" and a text content of "dog cat hello cat dog dog hello cat world", return 1 because there's only one word "cat" in between the two words.

Pull request:
Day153
Resolves #316.

Patch:
diff --git a/README.md b/README.md
index be9bf1c..829912a 100644
--- a/README.md
+++ b/README.md
@@ -162,3 +162,4 @@ problems from
 * [Day 149](https://github.com/vaskoz/dailycodingproblem-go/issues/311)
 * [Day 150](https://github.com/vaskoz/dailycodingproblem-go/issues/312)
 * [Day 151](https://github.com/vaskoz/dailycodingproblem-go/issues/313)
+* [Day 153](https://github.com/vaskoz/dailycodingproblem-go/issues/316)
diff --git a/day153/problem.go b/day153/problem.go
new file mode 100644
index 0000000..52f1a9b
--- /dev/null
+++ b/day153/problem.go
@@ -0,0 +1,45 @@
+package day153
+
+import (
+	"strings"
+)
+
+// SmallestDistanceBetweenWords returns the smallest number of words
+// between the two given words in the text provided.
+// Returns -1 if one or both of the words don't exist in the text.
+func SmallestDistanceBetweenWords(text, one, two string) int {
+	words := strings.Split(text, " ")
+	oneI := getIndex(words, one, 0)
+	twoI := getIndex(words, two, 0)
+	if oneI == -1 || twoI == -1 {
+		return -1
+	}
+	smallest := len(words)
+	for oneI != -1 && twoI != -1 {
+		if dist := abs(oneI - twoI); dist < smallest {
+			smallest = dist
+		}
+		if oneI < twoI {
+			oneI = getIndex(words, one, oneI+1)
+		} else {
+			twoI = getIndex(words, two, twoI+1)
+		}
+	}
+	return smallest - 1
+}
+
+func getIndex(s []string, target string, start int) int {
+	for i := start; i < len(s); i++ {
+		if s[i] == target {
+			return i
+		}
+	}
+	return -1
+}
+
+func abs(a int) int {
+	if a < 0 {
+		return -a
+	}
+	return a
+}


Test patch:
diff --git a/day153/problem_test.go b/day153/problem_test.go
new file mode 100644
index 0000000..389347e
--- /dev/null
+++ b/day153/problem_test.go
@@ -0,0 +1,29 @@
+package day153
+
+import "testing"
+
+var testcases = []struct {
+	text, one, two string
+	expected       int
+}{
+	{"dog cat hello cat dog dog hello cat world", "hello", "world", 1},
+	{"dog cat hello cat dog dog hello cat world", "hello", "cat", 0},
+	{"dog cat hello cat dog dog hello cat world", "wat?", "cat", -1},
+}
+
+func TestSmallestDistanceBetweenWords(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if result := SmallestDistanceBetweenWords(tc.text, tc.one, tc.two); result != tc.expected {
+			t.Errorf("Expected %v got %v", tc.expected, result)
+		}
+	}
+}
+
+func BenchmarkSmallestDistanceBetweenWords(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			SmallestDistanceBetweenWords(tc.text, tc.one, tc.two)
+		}
+	}
+}
Repository: jlongster/prettier (js)

Issue:
Unneeded parenthesis around await in ternary
```js
async function f() {
  const result = typeof fn === 'function' ? await fn() : null;
}
```

outputs

```js
async function f() {
  const result = typeof fn === "function" ? (await fn()) : null;
}
```

but the parenthesis is not needed.

https://jlongster.github.io/prettier/#%7B%22content%22%3A%22async%20function%20f()%20%7B%5Cn%20%20const%20result%20%3D%20typeof%20fn%20%3D%3D%3D%20'function'%20%3F%20await%20fn()%20%3A%20null%3B%5Cn%7D%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22singleQuote%22%3Afalse%2C%22trailingComma%22%3Afalse%2C%22bracketSpacing%22%3Atrue%7D%7D

Pull request:
Remove parens around AwaitExpression in ternary
Fixes #313

Patch:
diff --git a/src/fast-path.js b/src/fast-path.js
index c8479f66f..9c2797b06 100644
--- a/src/fast-path.js
+++ b/src/fast-path.js
@@ -298,7 +298,6 @@ FPp.needsParens = function(assumeExpressionContext) {
         case "SpreadElement":
         case "SpreadProperty":
         case "NewExpression":
-        case "ConditionalExpression":
         case "MemberExpression":
           return true;
 


Test patch:
diff --git a/tests/async/__snapshots__/jsfmt.spec.js.snap b/tests/async/__snapshots__/jsfmt.spec.js.snap
index d4b1a9e02..2f264651c 100644
--- a/tests/async/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/async/__snapshots__/jsfmt.spec.js.snap
@@ -550,3 +550,14 @@ async function g() {
 }
 "
 `;
+
+exports[`test conditional-expression.js 1`] = `
+"async function f() {
+  const result = typeof fn === \'function\' ? await fn() : null;
+}
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+async function f() {
+  const result = typeof fn === \"function\" ? await fn() : null;
+}
+"
+`;
diff --git a/tests/async/conditional-expression.js b/tests/async/conditional-expression.js
new file mode 100644
index 000000000..532c66d6a
--- /dev/null
+++ b/tests/async/conditional-expression.js
@@ -0,0 +1,3 @@
+async function f() {
+  const result = typeof fn === 'function' ? await fn() : null;
+}
Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 81
Good morning! Here's your coding interview problem for today.

This problem was asked by Yelp.

Given a mapping of digits to letters (as in a phone number), and a digit string, return all possible letters the number could represent. You can assume each valid number in the mapping is a single digit.

For example if {“2”: [“a”, “b”, “c”], 3: [“d”, “e”, “f”], …} then “23” should return [“ad”, “ae”, “af”, “bd”, “be”, “bf”, “cd”, “ce”, “cf"].

Pull request:
Day81
Resolves #171.

Patch:
diff --git a/README.md b/README.md
index 41acb17..9f57cd0 100644
--- a/README.md
+++ b/README.md
@@ -90,3 +90,4 @@ problems from
 * [Day 78](https://github.com/vaskoz/dailycodingproblem-go/issues/165)
 * [Day 79](https://github.com/vaskoz/dailycodingproblem-go/issues/167)
 * [Day 80](https://github.com/vaskoz/dailycodingproblem-go/issues/168)
+* [Day 81](https://github.com/vaskoz/dailycodingproblem-go/issues/171)
diff --git a/day81/problem.go b/day81/problem.go
new file mode 100644
index 0000000..4df735e
--- /dev/null
+++ b/day81/problem.go
@@ -0,0 +1,26 @@
+package day81
+
+// DigitMappings represents digits that can be mapped to multiple other values.
+// Think of the alpha codes on a phone pad.
+type DigitMappings map[rune][]string
+
+// PossiblePhoneLetters takes a given phone number and returns all possible letter
+// combinations.
+func PossiblePhoneLetters(number string, digitMappings DigitMappings) []string {
+	var result []string
+	for i, r := range number {
+		letters := digitMappings[r]
+		if i == 0 {
+			result = append(result, letters...)
+		} else {
+			tmp := make([]string, 0, len(letters)*len(result))
+			for _, part := range result {
+				for _, letter := range letters {
+					tmp = append(tmp, part+letter)
+				}
+			}
+			result = tmp
+		}
+	}
+	return result
+}


Test patch:
diff --git a/day81/problem_test.go b/day81/problem_test.go
new file mode 100644
index 0000000..90859db
--- /dev/null
+++ b/day81/problem_test.go
@@ -0,0 +1,32 @@
+package day81
+
+import (
+	"reflect"
+	"testing"
+)
+
+var testcases = []struct {
+	number   string
+	mapping  DigitMappings
+	expected []string
+}{
+	{"23", DigitMappings{'2': {"a", "b", "c"}, '3': {"d", "e", "f"}},
+		[]string{"ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"}},
+}
+
+func TestPossiblePhoneLetters(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if result := PossiblePhoneLetters(tc.number, tc.mapping); !reflect.DeepEqual(tc.expected, result) {
+			t.Errorf("Expected %v got %v", tc.expected, result)
+		}
+	}
+}
+
+func BenchmarkPossiblePhoneLetters(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			PossiblePhoneLetters(tc.number, tc.mapping)
+		}
+	}
+}
Repository: rcardin/raise4s (scala)

Issue:
Add global strategy that let you convert all raised errors in exceptions
The issue was inspired by Jon Pretty's [Contingency](https://soundness.dev/contingency/) library.

It should be possible to import a strategy that lets us transform all the raised errors into exceptions:

```scala
object Experiments {
  def unsafeRaise(error: String): Unit raises String = raise(error)

  def main(args: Array[String]): Unit = {
    import raise4s.throwRaised
    unsafeRaise("Boom")
  }
}
```

The above code should throw an exception containing the `"Boom"` error.

Add a new type of exception to contain the logical errors.

Pull request:
Closes #70

Patch:
diff --git a/core/src/main/scala/in/rcard/raise4s/Strategies.scala b/core/src/main/scala/in/rcard/raise4s/Strategies.scala
new file mode 100644
index 0000000..016a9bc
--- /dev/null
+++ b/core/src/main/scala/in/rcard/raise4s/Strategies.scala
@@ -0,0 +1,14 @@
+package in.rcard.raise4s
+
+object Strategies {
+
+  /**
+   * An exception that make it easy to throw a logic-typed error if the error is not already a [[Throwable]].
+   *
+   * @param error The logic-typed error to raise
+   * @tparam E The type of the logic-typed error
+   */
+  class UnsafeRaiseException[E](val error: E) extends Exception()
+  
+  type anyRaised = Raise[Any]
+}


Test patch:
diff --git a/core/src/test/scala/in/rcard/raise4s/StrategiesSpec.scala b/core/src/test/scala/in/rcard/raise4s/StrategiesSpec.scala
new file mode 100644
index 0000000..e6a127c
--- /dev/null
+++ b/core/src/test/scala/in/rcard/raise4s/StrategiesSpec.scala
@@ -0,0 +1,17 @@
+package in.rcard.raise4s
+
+import in.rcard.raise4s.Strategies.anyRaised
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+class StrategiesSpec extends AnyFlatSpec with Matchers {
+
+  "anyRaised" should "allow defining a strategy that throw any given error" in {
+    val lambdaRaisingError: Int raises String = Raise.raise("Oops!")
+    given anyRaised = error => throw new RuntimeException(error.toString)
+    val ex = intercept[RuntimeException] {
+      lambdaRaisingError
+    }
+    ex.getMessage shouldBe "Oops!"
+  }
+}
Repository: kmyk/online-judge-tools (python)

Issue:
a example of a problem whose sample cases have no outputs
取得に失敗してる。

https://chokudai001.contest.atcoder.jp/tasks/chokudai_001_a

AtCoder だとテストは入力と出力が常に揃っていてほしいし失敗でよさそう。下手にやると他のでゴミをサンプルだとして拾ってしまう。
しかしインターフェースはこれを返せるようになっているのに返さないのは混乱を生みそう。ちょっと困る。たぶんこのまま失敗させておくのが正解。

いずれにせよテストに足して挙動を明示しておいた方がよい。

Pull request:
Raise error if sample parse failed.
Resolve #413 

413で例外を投げるようにしました。
エラーメッセージがわかるようなわからないような感じだったので、サンプルのパースに失敗したことをメッセージ煮だすようにしました。
また、従来、中途半端にsample.in/outが残っていましたが、怪しいのでなにも残さないようにしてみました。

Patch:
diff --git a/onlinejudge/_implementation/main.py b/onlinejudge/_implementation/main.py
index fa15b0d..d86e555 100644
--- a/onlinejudge/_implementation/main.py
+++ b/onlinejudge/_implementation/main.py
@@ -297,6 +297,9 @@ def main(args: Optional[List[str]] = None) -> None:
         log.error(str(e))
         log.debug(traceback.format_exc())
         sys.exit(1)
+    except onlinejudge.type.SampleParseError:
+        log.error('Failed to parse sample.')
+        sys.exit(1)
 
 
 if __name__ == '__main__':
diff --git a/onlinejudge/type.py b/onlinejudge/type.py
index bbaacf0..b4025e3 100644
--- a/onlinejudge/type.py
+++ b/onlinejudge/type.py
@@ -82,6 +82,10 @@ class SubmissionError(RuntimeError):
     pass
 
 
+class SampleParseError(RuntimeError):
+    pass
+
+
 class Problem(ABC):
     """
     :note: :py:class:`Problem` represents just a URL of a problem, without the data of the problem.


Test patch:
diff --git a/onlinejudge/_implementation/testcase_zipper.py b/onlinejudge/_implementation/testcase_zipper.py
index f4be98d..69845df 100644
--- a/onlinejudge/_implementation/testcase_zipper.py
+++ b/onlinejudge/_implementation/testcase_zipper.py
@@ -33,6 +33,7 @@ class SampleZipper(object):
     def get(self) -> List[TestCase]:
         if self._dangling is not None:
             log.error('dangling sample string: %s', self._dangling[1])
+            raise SampleParseError
         return self._testcases
 
 
diff --git a/tests/command_download_atcoder.py b/tests/command_download_atcoder.py
index 096c21a..5481158 100644
--- a/tests/command_download_atcoder.py
+++ b/tests/command_download_atcoder.py
@@ -3,6 +3,8 @@ import unittest
 import requests.exceptions
 import tests.command_download
 
+from onlinejudge.type import SampleParseError
+
 
 class DownloadAtCoderTest(unittest.TestCase):
     def snippet_call_download(self, *args, **kwargs):
@@ -131,3 +133,7 @@ class DownloadAtCoderTest(unittest.TestCase):
 
     def test_call_download_invalid_url(self):
         self.snippet_call_download_raises(requests.exceptions.HTTPError, 'http://abc001.contest.atcoder.jp/tasks/abc001_100')
+
+    def test_call_download_413(self):
+        # This task is not supported.
+        self.snippet_call_download_raises(SampleParseError, 'https://chokudai001.contest.atcoder.jp/tasks/chokudai_001_a')
Repository: rcoh/angle-grinder (rust)

Issue:
Timeslice operator
See https://github.com/rcoh/angle-grinder/commit/274d34233bec9fd78ae680651efa58ad13b2a2e0 for a template
A non trivial undertaking. My suggested path:
- [ ] Add a `date` subtype to `data::Value` -- this will include the date rendering logic
- [ ] Add a parseDate expression that produces a `date` value from a string
- [ ] Create the timeslice operator that accepts an `Expression<Date>` as an argument and does the bucketing (nontrivial)
- [ ] Add an automatic `sort by _timeslice` automatically after groupingby `_timeslice`

Proposed query structure:
```* | parse "* * *" as level, date, message | timeslice(parseDate(level)) 5m | count by _timeslice```


Pull request:
[lib] if _timeslice is used in an aggregate, include it in the sort keys
If the user is grouping by the slice, they probably want the
results displayed from earliest to latest.

(Hmm, it looks like sorting is not quite right since the direction
 is for the entire sort operator and not a per-key thing.)

Fixes #10

Patch:
diff --git a/src/lib.rs b/src/lib.rs
index 5556d93..e926ab5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -105,13 +105,26 @@ pub mod pipeline {
         }
 
         fn implicit_sort(multi_agg: &MultiAggregateOperator) -> SortOperator {
+            let timeslice_col = Expr::column("_timeslice");
+            let (opt_timeslice, direction) = if multi_agg.key_cols.contains(&timeslice_col) {
+                (Some(timeslice_col), SortMode::Ascending)
+            } else {
+                (None, SortMode::Descending)
+            };
+
+            let sort_cols: Vec<Expr> = opt_timeslice
+                .into_iter()
+                .chain(
+                    multi_agg
+                        .aggregate_functions
+                        .iter()
+                        .map(|&(ref k, _)| Expr::column(k)),
+                )
+                .collect();
+
             SortOperator {
-                sort_cols: multi_agg
-                    .aggregate_functions
-                    .iter()
-                    .map(|&(ref k, _)| Expr::column(k))
-                    .collect(),
-                direction: SortMode::Descending,
+                sort_cols,
+                direction,
             }
         }
 


Test patch:
diff --git a/tests/structured_tests/timeslice_1.toml b/tests/structured_tests/timeslice_1.toml
index 31818fd..d11a83c 100644
--- a/tests/structured_tests/timeslice_1.toml
+++ b/tests/structured_tests/timeslice_1.toml
@@ -17,8 +17,8 @@ input = """
 output = """
 _timeslice                     _count
 ---------------------------------------------
-2013-09-06 22:00:00 UTC        7
 2013-09-06 20:00:00 UTC        2
+2013-09-06 22:00:00 UTC        7
 2013-09-06 22:05:00 UTC        2
 2013-09-06 22:10:00 UTC        1
 2013-09-06 23:05:00 UTC        1