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

Issue:
Day 220
Good morning! Here's your coding interview problem for today.

This problem was asked by Square.

In front of you is a row of N coins, with values `v1, v1, ..., vn`.

You are asked to play the following game. You and an opponent take turns choosing either the first or last coin from the row, removing it from the row, and receiving the value of the coin.

Write a program that returns the maximum amount of money you can win with certainty, if you move first, assuming your opponent plays optimally.

Pull request:
Day220
Resolves #453.

Patch:
diff --git a/README.md b/README.md
index 58b8fe3..3f1340d 100644
--- a/README.md
+++ b/README.md
@@ -229,4 +229,5 @@ problems from
 * [Day 216](https://github.com/vaskoz/dailycodingproblem-go/issues/445)
 * [Day 217](https://github.com/vaskoz/dailycodingproblem-go/issues/447)
 * [Day 218](https://github.com/vaskoz/dailycodingproblem-go/issues/449)
+* [Day 220](https://github.com/vaskoz/dailycodingproblem-go/issues/453)
 * [Day 221](https://github.com/vaskoz/dailycodingproblem-go/issues/454)
diff --git a/day220/problem.go b/day220/problem.go
new file mode 100644
index 0000000..e9085f4
--- /dev/null
+++ b/day220/problem.go
@@ -0,0 +1,41 @@
+package day220
+
+// AlternatingCoinsFirst solves the game using dynamic programming.
+// You and an opponent take turns choosing either the first or
+// last coin from the row, removing it from the row, and receiving the value of the coin.
+func AlternatingCoinsFirst(coins []int) int {
+	value := make([][]int, len(coins))
+	for i := range value {
+		value[i] = make([]int, len(coins))
+	}
+	for interval := range value {
+		for i, j := 0, interval; j < len(coins); i, j = i+1, j+1 {
+			var a, b, c int
+			if i+2 <= j {
+				a = value[i+2][j]
+			}
+			if i+1 <= j-1 {
+				b = value[i+1][j-1]
+			}
+			if i <= j-2 {
+				c = value[i][j-2]
+			}
+			value[i][j] = max(coins[i]+min(a, b), coins[j]+min(b, c))
+		}
+	}
+	return value[0][len(coins)-1]
+}
+
+func max(a, b int) int {
+	if a > b {
+		return a
+	}
+	return b
+}
+
+func min(a, b int) int {
+	if a < b {
+		return a
+	}
+	return b
+}


Test patch:
diff --git a/day220/problem_test.go b/day220/problem_test.go
new file mode 100644
index 0000000..35f3e9a
--- /dev/null
+++ b/day220/problem_test.go
@@ -0,0 +1,30 @@
+package day220
+
+import "testing"
+
+var testcases = []struct {
+	coins     []int
+	maxProfit int
+}{
+	{[]int{6, 9, 1, 2, 16, 8}, 23},
+	{[]int{8, 15, 3, 7}, 22},
+	{[]int{2, 2, 2, 2}, 4},
+	{[]int{20, 30, 2, 2, 2, 10}, 42},
+}
+
+func TestAlternatingCoinsFirst(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if result := AlternatingCoinsFirst(tc.coins); result != tc.maxProfit {
+			t.Errorf("Expected %v, got %v", tc.maxProfit, result)
+		}
+	}
+}
+
+func BenchmarkAlternatingCoinsFirst(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			AlternatingCoinsFirst(tc.coins)
+		}
+	}
+}
Repository: dprint/dprint-plugin-typescript (rust)

Issue:
Space removed after method call on number literal
**Describe the bug**

dprint-plugin-typescript version: 0.73.1

**Input Code**

```ts
1+ 2 .toString() +3
```

**Expected Output**

```ts
1 + 2 .toString() + 3
```

or

```ts
1 + 2..toString() + 3
```

or

```ts
1 + (2).toString() + 3
```

**Actual Output**

```ts
1 + 2.toString() + 3;
```

Prettier adds parens; I think that's probably the best thing to do. See also: https://github.com/microsoft/TypeScript/issues/50686

Pull request:
fix: don't create syntax error with numeric literal as object in member expression
Closes #421

Patch:
diff --git a/src/generation/generate.rs b/src/generation/generate.rs
index a34e0fe..ec864e3 100644
--- a/src/generation/generate.rs
+++ b/src/generation/generate.rs
@@ -7662,7 +7662,13 @@ fn gen_for_member_like_expr_item<'a>(item: &MemberLikeExprItem<'a>, context: &mu
     MemberLikeExprItem::Node(node) => {
       let is_optional = item.is_optional();
       gen_node_with_inner_gen(*node, context, |node_items, _| {
+        // Changing `2 .toString()` to `2.toString()` is a syntax error because `2.` is a numeric
+        // literal, so we surround it in parenthesis `(2).toString()`
+        let is_first_and_number = is_first && node.kind() == NodeKind::Number && !node.text_fast(context.program).contains('.');
         let mut items = PrintItems::new();
+        if is_first_and_number {
+          items.push_str("(");
+        }
         if !is_first {
           if is_optional {
             items.push_str("?.");
@@ -7671,6 +7677,9 @@ fn gen_for_member_like_expr_item<'a>(item: &MemberLikeExprItem<'a>, context: &mu
           }
         }
         items.extend(node_items);
+        if is_first_and_number {
+          items.push_str(")");
+        }
         items
       })
     }


Test patch:
diff --git a/tests/specs/issues/issue0421.txt b/tests/specs/issues/issue0421.txt
new file mode 100644
index 0000000..e7c8003
--- /dev/null
+++ b/tests/specs/issues/issue0421.txt
@@ -0,0 +1,13 @@
+== should add parens for member expr with numeric literal ==
+1+ 2 .toString() +3;
+1+ 2_000 .toString() +3;
+1+ 2..toString() +3;
+1+ 2.1.toString() +3;
+1+ (2).toString() +3;
+
+[expect]
+1 + (2).toString() + 3;
+1 + (2_000).toString() + 3;
+1 + 2..toString() + 3;
+1 + 2.1.toString() + 3;
+1 + (2).toString() + 3;
Repository: Rich-Harris/buble (js)

Issue:
Binary and octal number literals are not transpiled if base prefix is uppercase
Both `0B` and `0O' are [valid](https://tc39.github.io/ecma262/#sec-literals-numeric-literals) base prefixes. Example:
```js
0B01100 === 0O14
```

Pull request:
Fix binary octal num literals
Fix #74, binary and octal number literals are now properly transpired regardless uppercase or downcase base prefix

Patch:
diff --git a/src/program/types/Literal.js b/src/program/types/Literal.js
index a2f5692..379f9a8 100644
--- a/src/program/types/Literal.js
+++ b/src/program/types/Literal.js
@@ -11,8 +11,7 @@ export default class Literal extends Node {
 
 	transpile(code, transforms) {
 		if (transforms.numericLiteral) {
-			const leading = this.raw.slice(0, 2);
-			if (leading === '0b' || leading === '0o') {
+			if (this.raw.match(/^0[bo]/i)) {
 				code.overwrite(this.start, this.end, String(this.value), {
 					storeName: true,
 					contentOnly: true


Test patch:
diff --git a/test/samples/binary-and-octal.js b/test/samples/binary-and-octal.js
index 8bcb48b..fc46e8c 100644
--- a/test/samples/binary-and-octal.js
+++ b/test/samples/binary-and-octal.js
@@ -3,11 +3,13 @@ module.exports = [
 		description: 'transpiles binary numbers',
 
 		input: `
-			var num = 0b111110111;
+			var num1 = 0b111110111;
+			var num2 = 0B111110111;
 			var str = '0b111110111';`,
 
 		output: `
-			var num = 503;
+			var num1 = 503;
+			var num2 = 503;
 			var str = '0b111110111';`
 	},
 
@@ -15,11 +17,13 @@ module.exports = [
 		description: 'transpiles octal numbers',
 
 		input: `
-			var num = 0o767;
+			var num1 = 0o767;
+			var num2 = 0O767;
 			var str = '0o767';`,
 
 		output: `
-			var num = 503;
+			var num1 = 503;
+			var num2 = 503;
 			var str = '0o767';`
 	},
Repository: jprichardson/node-fs-extra (js)

Issue:
ensureFileSync vs ensureDirSync
When `ensureDirSync` is called on a folder that already exists as a file, `EEXIST` is thrown as expected.

When `ensureFileSync` is called on a file that already exists as a folder nothing is thrown.

Should not the two behaviours be the same? IMHO either both should throw or none of them should throw.

Pull request:
ensureFile & ensureFileSync should error when the path is a directory
Fixes #465 

If testing locally, make sure to run `npm update` first; I discovered a bug in universalify while working on this that has been fixed in the latest patch release of universalify.

Patch:
diff --git a/lib/ensure/file.js b/lib/ensure/file.js
index 962c21c..67eed30 100644
--- a/lib/ensure/file.js
+++ b/lib/ensure/file.js
@@ -14,9 +14,8 @@ function createFile (file, callback) {
     })
   }
 
-  pathExists(file, (err, fileExists) => {
-    if (err) return callback(err)
-    if (fileExists) return callback()
+  fs.stat(file, (err, stats) => { // eslint-disable-line handle-callback-err
+    if (!err && stats.isFile()) return callback()
     const dir = path.dirname(file)
     pathExists(dir, (err, dirExists) => {
       if (err) return callback(err)
@@ -30,7 +29,11 @@ function createFile (file, callback) {
 }
 
 function createFileSync (file) {
-  if (fs.existsSync(file)) return
+  let stats
+  try {
+    stats = fs.statSync(file)
+  } catch (e) {}
+  if (stats && stats.isFile()) return
 
   const dir = path.dirname(file)
   if (!fs.existsSync(dir)) {


Test patch:
diff --git a/lib/ensure/__tests__/ensure.test.js b/lib/ensure/__tests__/ensure.test.js
index b7b519e..0c06597 100644
--- a/lib/ensure/__tests__/ensure.test.js
+++ b/lib/ensure/__tests__/ensure.test.js
@@ -45,6 +45,19 @@ describe('fs-extra', () => {
         })
       })
     })
+
+    describe('> when there is a directory at that path', () => {
+      it('should error', done => {
+        const p = path.join(TEST_DIR, 'somedir')
+        fs.mkdirSync(p)
+
+        fse.ensureFile(p, err => {
+          assert(err)
+          assert.equal(err.code, 'EISDIR')
+          done()
+        })
+      })
+    })
   })
 
   describe('+ ensureFileSync()', () => {
@@ -68,6 +81,22 @@ describe('fs-extra', () => {
         assert(fs.existsSync(file))
       })
     })
+
+    describe('> when there is a directory at that path', () => {
+      it('should error', () => {
+        const p = path.join(TEST_DIR, 'somedir2')
+        fs.mkdirSync(p)
+
+        assert.throws(() => {
+          try {
+            fse.ensureFileSync(p)
+          } catch (e) {
+            assert.equal(e.code, 'EISDIR')
+            throw e
+          }
+        })
+      })
+    })
   })
 
   describe('+ ensureDir()', () => {
Repository: JuliaDiff/FiniteDifferences.jl (julia)

Issue:
`to_vec` should make an empty vector for `CartesianIndex`
```julia
julia> to_vec(CartesianIndex(1))[1]
1-element Vector{Int64}:
 1
```
should be an empty vector instead

Pull request:
Closes #196

Patch:
diff --git a/Project.toml b/Project.toml
index 21e4474..19ba357 100644
--- a/Project.toml
+++ b/Project.toml
@@ -1,6 +1,6 @@
 name = "FiniteDifferences"
 uuid = "26cc04aa-876d-5657-8c51-4c34ba976000"
-version = "0.12.19"
+version = "0.12.20"
 
 [deps]
 ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
diff --git a/src/to_vec.jl b/src/to_vec.jl
index e1916c0..66bb1f9 100644
--- a/src/to_vec.jl
+++ b/src/to_vec.jl
@@ -235,12 +235,15 @@ function to_vec(d::Dict)
     return d_vec, Dict_from_vec
 end
 
-# types
-function FiniteDifferences.to_vec(x::DataType)
-    function DataType_from_vec(x_vec::Vector)
-        return x
+# non-perturbable types
+for T in (:DataType, :CartesianIndex, :AbstractZero)
+    T_from_vec = Symbol(T, :_from_vec)
+    @eval function FiniteDifferences.to_vec(x::$T)
+        function $T_from_vec(x_vec::Vector)
+            return x
+        end
+        return Bool[], $T_from_vec
     end
-    return Bool[], DataType_from_vec
 end
 
 # ChainRulesCore Differentials
@@ -255,13 +258,6 @@ function FiniteDifferences.to_vec(x::Tangent{P}) where{P}
     return x_vec, Tangent_from_vec
 end
 
-function FiniteDifferences.to_vec(x::AbstractZero)
-    function AbstractZero_from_vec(x_vec::Vector)
-        return x
-    end
-    return Bool[], AbstractZero_from_vec
-end
-
 function FiniteDifferences.to_vec(t::Thunk)
     v, back = to_vec(unthunk(t))
     Thunk_from_vec = v -> @thunk(back(v))


Test patch:
diff --git a/test/to_vec.jl b/test/to_vec.jl
index 4e7a224..08f24bd 100644
--- a/test/to_vec.jl
+++ b/test/to_vec.jl
@@ -200,6 +200,13 @@ end
         test_to_vec(Vector; check_inferred=false) # isa UnionAll
     end
 
+    @testset "CartesianIndex" begin
+        test_to_vec(CartesianIndex(1))
+        test_to_vec(CartesianIndex(1, 2))
+        @test to_vec(CartesianIndex(1))[1] == []
+        @test to_vec(CartesianIndex(1, 3))[1] == []
+    end
+
     @testset "ChainRulesCore Differentials" begin
         @testset "Tangent{Tuple}" begin
             @testset "basic" begin
Repository: sveltejs/prettier-plugin-svelte (ts)

Issue:
Error when a component name begins with `Style`
The following code throws an error in prettier (`prettier --check file.svelte`):
```
    <StyledText    />

<style></style>
```

Error:
```
[error] file.svelte: Expected >
[error] > 1 | <styledTextInput  / ✂prettier:content✂="Cgo8c3R5bGU+"></style>
[error]     |                   ^ (1:19)
[error] 1: <styledTextInput  / ✂prettier:content✂="Cgo8c3R5bGU+"></style>
[error]
```

Pull request:
(fix) case sensitive script/style snipping
Fixes #198

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2f8b01f..2c8a770 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,7 @@
 ## 2.1.2 (Unreleased)
 
 * Keep whitespace around script/style tags ([#197](https://github.com/sveltejs/prettier-plugin-svelte/issues/197))
+* Make script/style tag snipping case sensitive ([#198](https://github.com/sveltejs/prettier-plugin-svelte/issues/198))
 
 ## 2.1.1
 
diff --git a/src/lib/snipTagContent.ts b/src/lib/snipTagContent.ts
index 1f69955..0f8d119 100644
--- a/src/lib/snipTagContent.ts
+++ b/src/lib/snipTagContent.ts
@@ -1,7 +1,7 @@
 export const snippedTagContentAttribute = '✂prettier:content✂';
 
 export function snipTagContent(tagName: string, source: string, placeholder = ''): string {
-    const regex = new RegExp(`<${tagName}([^]*?)>([^]*?)<\/${tagName}>`, 'gi');
+    const regex = new RegExp(`<${tagName}([^]*?)>([^]*?)<\/${tagName}>`, 'g');
     return source.replace(regex, (_, attributes, content) => {
         const encodedContent = Buffer.from(content).toString('base64');
         return `<${tagName}${attributes} ${snippedTagContentAttribute}="${encodedContent}">${placeholder}</${tagName}>`;


Test patch:
diff --git a/test/printer/samples/component-style-script-tagname.html b/test/printer/samples/component-style-script-tagname.html
new file mode 100644
index 0000000..e3e40d7
--- /dev/null
+++ b/test/printer/samples/component-style-script-tagname.html
@@ -0,0 +1,10 @@
+<script></script>
+
+<Script />
+<Script>hello</Script>
+<ScriptedContent />
+<StyledText />
+<Style />
+<Style>hello</Style>
+
+<style></style>
Repository: effector/effector (ts)

Issue:
createAPI broken types
<!--
Found a bug? Please fill out the sections below.
Be kind and objective when writing in text. Thanks!
-->

**What is the current behavior:**

TypeScript errors when I try to return undefined from the event created with createApi.

**Please provide the steps to reproduce and if possible a minimal demo of the problem via https://share.effector.dev, https://codesandbox.io or similar**

https://codesandbox.io/s/focused-bird-zke04?file=/src/index.ts

**What is the expected behavior:**

No TypeScript error :) 

**Which versions of effector packages, and which browser and OS are affected by this issue? Did this work in previous 
versions of effector?:**

effector@21.8.8


Pull request:
fix return type of reducer for createApi
close #468 

Patch:
diff --git a/packages/effector/index.d.ts b/packages/effector/index.d.ts
index e3a73e2a..a248254e 100644
--- a/packages/effector/index.d.ts
+++ b/packages/effector/index.d.ts
@@ -288,7 +288,7 @@ export class Domain implements Unit<any> {
   createStore<State>(
     defaultState: State,
     config?: {
-      name?: string 
+      name?: string
       sid?: string
       updateFilter?: (update: State, current: State) => boolean
     },
@@ -542,7 +542,7 @@ export function split<
 
 export function createApi<
   S,
-  Api extends {[name: string]: (store: S, e: any) => S}
+  Api extends {[name: string]: (store: S, e: any) => S | void}
 >(
   store: Store<S>,
   api: Api,
@@ -620,7 +620,7 @@ type UnitObject = Store<any> | Event<any> | Effect<any, any, any> | Unit<any>
 
 /**
  * Force typescript to print real type instead of geneic types
- * 
+ *
  * It's better to see {a: string; b: number}
  * instead of GetCombinedValue<{a: Store<string>; b: Store<number>}>
  * */
@@ -1299,11 +1299,11 @@ export function attach<
 }): Effect<Params, EffectResult<FX>, EffectError<FX>>
 export function attach<FN extends ((params: any) => any), FX extends Effect<any, any, any>>(config: {
   effect: FX
-  mapParams: FN extends (...args: any[]) => NoInfer<EffectParams<FX>> 
+  mapParams: FN extends (...args: any[]) => NoInfer<EffectParams<FX>>
     ? FN
     : never
   name?: string
-}): FN extends (...args: infer Args) => NoInfer<EffectParams<FX>> 
+}): FN extends (...args: infer Args) => NoInfer<EffectParams<FX>>
   ? Effect<
     Args['length'] extends 0
       ? void


Test patch:
diff --git a/src/types/__tests__/effector/createApi.test.ts b/src/types/__tests__/effector/createApi.test.ts
index 3e761686..5ca03001 100644
--- a/src/types/__tests__/effector/createApi.test.ts
+++ b/src/types/__tests__/effector/createApi.test.ts
@@ -101,6 +101,21 @@ test('createApi void calls edge case (should pass)', () => {
   `)
 })
 
+test('createApi returns nothing from reducer (should pass)', () => {
+  const $isLoading = createStore(false)
+  const {start} = createApi($isLoading, {
+    start: (_, p) => p === 1 ? true : undefined,
+  })
+
+  start()
+
+  expect(typecheck).toMatchInlineSnapshot(`
+    "
+    no errors
+    "
+  `)
+})
+
 describe('type validation', () => {
   test('correct call (should pass)', () => {
     const x = createStore(0)