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

Issue:
Day 30
Good morning! Here's your coding interview problem for today.

This problem was asked by Facebook.

You are given an array of non-negative integers that represents a two-dimensional elevation map where each element is unit-width wall and the integer is the height. Suppose it will rain and all spots between two walls get filled up.

Compute how many units of water remain trapped on the map in O(N) time and O(1) space.

For example, given the input [2, 1, 2], we can hold 1 unit of water in the middle.

Given the input [3, 0, 1, 3, 0, 5], we can hold 3 units in the first index, 2 in the second, and 3 in the fourth index (we cannot hold 5 since it would run off to the left), so we can trap 8 units of water.

Pull request:
Day30
Resolves #69 .

Patch:
diff --git a/README.md b/README.md
index b465c34..fb066e2 100644
--- a/README.md
+++ b/README.md
@@ -43,3 +43,4 @@ problems from
 * [Day 27](https://github.com/vaskoz/dailycodingproblem-go/issues/63)
 * [Day 28](https://github.com/vaskoz/dailycodingproblem-go/issues/65)
 * [Day 29](https://github.com/vaskoz/dailycodingproblem-go/issues/67)
+* [Day 30](https://github.com/vaskoz/dailycodingproblem-go/issues/69)
diff --git a/day30/problem.go b/day30/problem.go
new file mode 100644
index 0000000..d7c3d69
--- /dev/null
+++ b/day30/problem.go
@@ -0,0 +1,43 @@
+package day30
+
+// TrappedWater returns the amount of water that can be trapped.
+// Runs in O(N) time and O(1) space.
+func TrappedWater(heights []int) int {
+	if len(heights) < 3 {
+		return 0
+	}
+	total := 0
+	hl := heights[0]
+	hri, hr := highestToRight(heights, 2)
+	for i := 1; i < len(heights)-1; i++ {
+		h := min(hl, hr)
+		if cavity := h - heights[i]; cavity > 0 {
+			total += cavity
+		}
+		if heights[i] > hl {
+			hl = heights[i]
+		}
+		if i+1 == hri {
+			hri, hr = highestToRight(heights, hri)
+		}
+	}
+	return total
+}
+
+func highestToRight(heights []int, start int) (int, int) {
+	var highest, highestI int
+	for i := start; i < len(heights); i++ {
+		if heights[i] > highest {
+			highest = heights[i]
+			highestI = i
+		}
+	}
+	return highestI, highest
+}
+
+func min(a, b int) int {
+	if a < b {
+		return a
+	}
+	return b
+}


Test patch:
diff --git a/day30/problem_test.go b/day30/problem_test.go
new file mode 100644
index 0000000..e28eff1
--- /dev/null
+++ b/day30/problem_test.go
@@ -0,0 +1,30 @@
+package day30
+
+import "testing"
+
+var testcases = []struct {
+	elevations []int
+	expected   int
+}{
+	{[]int{2, 1}, 0},
+	{[]int{2, 1, 2}, 1},
+	{[]int{3, 0, 1, 3, 0, 5}, 8},
+	{[]int{1, 2, 3, 0, 5}, 3},
+}
+
+func TestTrappedWater(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if result := TrappedWater(tc.elevations); result != tc.expected {
+			t.Errorf("Expected %v but got %v", tc.expected, result)
+		}
+	}
+}
+
+func BenchmarkTrappedWater(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			TrappedWater(tc.elevations)
+		}
+	}
+}
Repository: dermotduffy/frigate-hass-card (ts)

Issue:
Hidden menu css stays visible even after hidden menu is closed

Pull request:
Fix menu hide bug causing menu background to stay even when hidden
* Closes #1431 

Patch:
diff --git a/src/components-lib/menu-controller.ts b/src/components-lib/menu-controller.ts
index 0410a340..9f773a56 100644
--- a/src/components-lib/menu-controller.ts
+++ b/src/components-lib/menu-controller.ts
@@ -14,7 +14,7 @@ import {
   frigateCardHandleActionConfig,
   getActionConfigGivenAction,
 } from '../utils/action';
-import { arrayify, isTruthy } from '../utils/basic.js';
+import { arrayify, isTruthy, setOrRemoveAttribute } from '../utils/basic.js';
 import { refreshDynamicStateParameters } from '../utils/ha/index.js';
 
 export class MenuController {
@@ -86,7 +86,7 @@ export class MenuController {
 
   public setExpanded(expanded: boolean): void {
     this._expanded = expanded;
-    this._host.setAttribute('expanded', '');
+    setOrRemoveAttribute(this._host, expanded, 'expanded');
     this._host.requestUpdate();
   }
 


Test patch:
diff --git a/tests/components-lib/menu-controller.test.ts b/tests/components-lib/menu-controller.test.ts
index 596d9312..1467ea47 100644
--- a/tests/components-lib/menu-controller.test.ts
+++ b/tests/components-lib/menu-controller.test.ts
@@ -67,6 +67,22 @@ describe('MenuController', () => {
     expect(host.getAttribute('data-alignment')).toBe('top');
   });
 
+  it('should expand', () => {
+    const host = createLitElement();
+    const controller = new MenuController(host);
+
+    expect(controller.isExpanded()).toBeFalsy();
+    expect(host.getAttribute('expanded')).toBeNull();
+
+    controller.setExpanded(true);
+    expect(controller.isExpanded()).toBeTruthy();
+    expect(host.getAttribute('expanded')).toBe('');
+
+    controller.setExpanded(false);
+    expect(controller.isExpanded()).toBeFalsy();
+    expect(host.getAttribute('expanded')).toBeNull();
+  });
+
   describe('should set and sort buttons', () => {
     it('by priority', () => {
       const controller = new MenuController(createLitElement());
Repository: dprint/dprint-plugin-typescript (rust)

Issue:
Single line block with const variable has curlies removed
**Describe the bug**

dprint-plugin-typescript version: 0.84.0

**Input Code**

```ts
if (typeof err !== 'undefined') { const _err: Error = err; }
```

**Expected Output**

```ts
if (typeof err !== 'undefined') { const _err: Error = err; }
```

**Actual Output**

```ts
if (typeof err !== 'undefined') const _err: Error = err;
```

https://dprint.dev/playground/#code/JYMwBAFALgngDgUwPbgQJzWAhAXh2AcgFcA7AEwRGBITIIEowBvMAYyRIGcowB9dNAC4wAUQxJM+AQG4wAXyA/language/typescript


Pull request:
fix: keep braces on if & while statements when block body contains single decl
Closes #510

Patch:
diff --git a/src/generation/generate.rs b/src/generation/generate.rs
index 693993c..ae5fd32 100644
--- a/src/generation/generate.rs
+++ b/src/generation/generate.rs
@@ -8435,7 +8435,9 @@ fn gen_conditional_brace_body<'a>(opts: GenConditionalBraceBodyOptions<'a>, cont
 
   fn get_force_braces(body_node: Node) -> bool {
     if let Node::BlockStmt(body_node) = body_node {
-      body_node.stmts.is_empty() || body_node.stmts.iter().all(|s| s.kind() == NodeKind::EmptyStmt)
+      body_node.stmts.is_empty()
+        || body_node.stmts.iter().all(|s| s.kind() == NodeKind::EmptyStmt)
+        || (body_node.stmts.len() == 1 && matches!(body_node.stmts[0], Stmt::Decl(_)))
     } else {
       false
     }


Test patch:
diff --git a/tests/specs/issues/issue0510.txt b/tests/specs/issues/issue0510.txt
new file mode 100644
index 0000000..edf7ab8
--- /dev/null
+++ b/tests/specs/issues/issue0510.txt
@@ -0,0 +1,11 @@
+== should not remove braces in an if/while statement when the body contains a declaration ==
+if (true) { const _err = 5; }
+while (true) { const _err = 5; }
+if (true) { class Test {} }
+while (true) { class Test {} }
+
+[expect]
+if (true) { const _err = 5; }
+while (true) { const _err = 5; }
+if (true) { class Test {} }
+while (true) { class Test {} }