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

Issue:
Day 218
Good morning! Here's your coding interview problem for today.

This problem was asked by Yahoo.

Write an algorithm that computes the reversal of a directed graph. For example, if a graph consists of `A -> B -> C`, it should become `A <- B <- C`.

Pull request:
Day218
Resolves #449.

Patch:
diff --git a/README.md b/README.md
index 8e47b1a..5c0e2a2 100644
--- a/README.md
+++ b/README.md
@@ -228,3 +228,4 @@ problems from
 * [Day 215](https://github.com/vaskoz/dailycodingproblem-go/issues/443)
 * [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)
diff --git a/day218/problem.go b/day218/problem.go
new file mode 100644
index 0000000..92186ec
--- /dev/null
+++ b/day218/problem.go
@@ -0,0 +1,20 @@
+package day218
+
+// AdjacencyMatrix is a directed graph adjacency matrix.
+type AdjacencyMatrix map[rune]map[rune]struct{}
+
+// ReverseDirectedGraph reverses all the edges in a given
+// directed graph.
+// Runs in O(N) time and produces a new graph using O(N) space.
+func ReverseDirectedGraph(g AdjacencyMatrix) AdjacencyMatrix {
+	reversed := make(AdjacencyMatrix, len(g))
+	for a := range g {
+		for b := range g[a] {
+			if _, found := reversed[b]; !found {
+				reversed[b] = make(map[rune]struct{})
+			}
+			reversed[b][a] = struct{}{}
+		}
+	}
+	return reversed
+}


Test patch:
diff --git a/day218/problem_test.go b/day218/problem_test.go
new file mode 100644
index 0000000..0f77b9f
--- /dev/null
+++ b/day218/problem_test.go
@@ -0,0 +1,38 @@
+package day218
+
+import (
+	"reflect"
+	"testing"
+)
+
+var testcases = []struct {
+	g, reversed AdjacencyMatrix
+}{
+	{
+		AdjacencyMatrix{
+			'A': {
+				'B': struct{}{},
+			},
+			'B': {
+				'C': struct{}{},
+			},
+		},
+		AdjacencyMatrix{
+			'C': {
+				'B': struct{}{},
+			},
+			'B': {
+				'A': struct{}{},
+			},
+		},
+	},
+}
+
+func TestReverseDirectedGraph(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if reversed := ReverseDirectedGraph(tc.g); !reflect.DeepEqual(reversed, tc.reversed) {
+			t.Errorf("Expected %v, got %v", tc.reversed, reversed)
+		}
+	}
+}
Repository: pion/dtls (go)

Issue:
Slice bounds out of range
<!--
  Come join our community on Slack https://pion.ly/slack for quicker support and more resources

  We also provide a Knowledge Base https://pion.ly/knowledge-base that covers Pion and general WebRTC
  
  We maintain a FAQ of common issues and questions https://pion.ly/knowledge-base/pion-basics/faq/

 Please answer these questions before submitting your issue. Thanks!
-->

### Your environment.
  - Version: v1.5.0
  - Browser: Firefox 68.0.1
  - Other Information - *stacktraces, related issues, suggestions how to fix, links for us to have context*
```
panic: runtime error: slice bounds out of range

goroutine 1490 [running]:
github.com/pion/dtls.unpackDatagram(0xc0006a0000, 0x2000, 0x2000, 0x2000, 0x2000, 0x0, 0x0, 0x0)
        /home/paul/go/pkg/mod/github.com/pion/dtls@v1.5.0/record_layer.go:84 +0x227
github.com/pion/dtls.(*Conn).inboundLoop(0xc000091b80)
        /home/paul/go/pkg/mod/github.com/pion/dtls@v1.5.0/conn.go:353 +0x150
created by github.com/pion/dtls.createConn
        /home/paul/go/pkg/mod/github.com/pion/dtls@v1.5.0/conn.go:170 +0x619
```

### What did you do?
It looks like it just occurs when a peer connects. I can't cause this to reproduce, but it does seem to happen once in a while. It could either be caused by a Firefox client or a client using the NPM wrtc library (latest ver.)

### What did you expect?
No panic.

### What happened?
Panics

Pull request:
Add length check to unpackDatagram
Fixes #87

Patch:
diff --git a/record_layer.go b/record_layer.go
index f51e2af..7bd2932 100644
--- a/record_layer.go
+++ b/record_layer.go
@@ -81,6 +81,10 @@ func unpackDatagram(buf []byte) ([][]byte, error) {
 		}
 
 		pktLen := (recordLayerHeaderSize + int(binary.BigEndian.Uint16(buf[offset+11:])))
+		if offset+pktLen > len(buf) {
+			return nil, errLengthMismatch
+		}
+
 		out = append(out, buf[offset:offset+pktLen])
 		offset += pktLen
 	}


Test patch:
diff --git a/record_layer_test.go b/record_layer_test.go
index 049a6bd..f838aa8 100644
--- a/record_layer_test.go
+++ b/record_layer_test.go
@@ -30,12 +30,16 @@ func TestUDPDecode(t *testing.T) {
 				{0x14, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x01, 0x01},
 			},
 		},
-
 		{
 			Name:      "Invalid packet length",
 			Data:      []byte{0x14, 0xfe},
 			WantError: errDTLSPacketInvalidLength,
 		},
+		{
+			Name:      "Packet declared invalid length",
+			Data:      []byte{0x14, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xFF, 0x01},
+			WantError: errLengthMismatch,
+		},
 	} {
 		dtlsPkts, err := unpackDatagram(test.Data)
 		if err != test.WantError {
Repository: pmndrs/valtio (ts)

Issue:
Computed set doesn't work for objects and arrays
Reported by @italodeandra

Repro codesandbox: https://codesandbox.io/s/valtio-proxywithcomputed-update-array-bug-yb7mj?file=/src/App.tsx

Pull request:
support object setters
close #97

Patch:
diff --git a/src/vanilla.ts b/src/vanilla.ts
index b88fa3b..64f72dd 100644
--- a/src/vanilla.ts
+++ b/src/vanilla.ts
@@ -129,7 +129,11 @@ export const proxy = <T extends object>(initialObject: T = {} as T): T => {
       if (childListeners) {
         childListeners.delete(notifyUpdate)
       }
-      if (refSet.has(value) || !isSupportedObject(value)) {
+      if (
+        refSet.has(value) ||
+        !isSupportedObject(value) ||
+        Object.getOwnPropertyDescriptor(target, prop)?.set
+      ) {
         target[prop] = value
       } else if (value instanceof Promise) {
         target[prop] = value
@@ -160,7 +164,7 @@ export const proxy = <T extends object>(initialObject: T = {} as T): T => {
       initialObject,
       key
     ) as PropertyDescriptor
-    if (desc.get) {
+    if (desc.get || desc.set) {
       Object.defineProperty(baseObject, key, desc)
     } else {
       proxyObject[key] = (initialObject as any)[key]


Test patch:
diff --git a/tests/computed.test.tsx b/tests/computed.test.tsx
index acf5b5c..ed4bfd7 100644
--- a/tests/computed.test.tsx
+++ b/tests/computed.test.tsx
@@ -110,3 +110,43 @@ it('computed getters and setters', async () => {
   expect(snapshot(state)).toMatchObject({ text: 'a', count: 0.5, doubled: 1 })
   expect(computeDouble).toBeCalledTimes(3)
 })
+
+it('computed setters with object and array', async () => {
+  const state = proxyWithComputed(
+    {
+      obj: { a: 1 },
+      arr: [2],
+    },
+    {
+      object: {
+        get: (snap) => snap.obj,
+        set: (state, newValue: any) => {
+          state.obj = newValue
+        },
+      },
+      array: {
+        get: (snap) => snap.arr,
+        set: (state, newValue: any) => {
+          state.arr = newValue
+        },
+      },
+    }
+  )
+
+  expect(snapshot(state)).toMatchObject({
+    obj: { a: 1 },
+    arr: [2],
+    object: { a: 1 },
+    array: [2],
+  })
+
+  state.object = { a: 2 }
+  state.array = [3]
+  await Promise.resolve()
+  expect(snapshot(state)).toMatchObject({
+    obj: { a: 2 },
+    arr: [3],
+    object: { a: 2 },
+    array: [3],
+  })
+})