PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: superlistapp/super_editor (dart)

Issue:
[BUG] - [AttributedText] - Character lookup logic is wrong
`AttributedText` supports looking up characters and placeholders by index. The implementation is wrong for character lookup. It pulls characters from the plain text, not the text with placeholders, which can lead to the wrong characters being returned, and exceptions trying to access indices beyond the end of the text string.

Pull request:
[AttributedText] - Fix incorrect character lookup by index (Resolves #2531)

We need to lookup text characters while accounting for placeholders. Previously were were looking up characters in the plain text string.

Patch:
diff --git a/attributed_text/lib/src/attributed_text.dart b/attributed_text/lib/src/attributed_text.dart
index 11e77b52a0..a554282aa7 100644
--- a/attributed_text/lib/src/attributed_text.dart
+++ b/attributed_text/lib/src/attributed_text.dart
@@ -119,13 +119,13 @@ class AttributedText {
   late final String _textWithPlaceholders;
 
   /// Returns the character or placeholder at offset zero.
-  Object get first => placeholders[0] ?? _text[0];
+  Object get first => placeholders[0] ?? _textWithPlaceholders[0];
 
   /// Returns the character or placeholder at the given [offset].
-  Object operator [](int offset) => placeholders[offset] ?? _text[offset];
+  Object operator [](int offset) => placeholders[offset] ?? _textWithPlaceholders[offset];
 
   /// Returns the character or placeholder at the end of this `AttributedText`.
-  Object get last => placeholders[length - 1] ?? _text[length - 1];
+  Object get last => placeholders[length - 1] ?? _textWithPlaceholders[length - 1];
 
   /// Returns a plain-text version of this `AttributedText`.
   ///


Test patch:
diff --git a/attributed_text/test/attributed_text_placeholders_test.dart b/attributed_text/test/attributed_text_placeholders_test.dart
index f17f2a00dc..3022a05641 100644
--- a/attributed_text/test/attributed_text_placeholders_test.dart
+++ b/attributed_text/test/attributed_text_placeholders_test.dart
@@ -81,6 +81,26 @@ void main() {
       });
     });
 
+    test("reports characters and placeholders at indices", () {
+      final text1 = AttributedText("HelloWorld", null, {
+        0: const _FakePlaceholder("one"),
+        6: const _FakePlaceholder("two"),
+        12: const _FakePlaceholder("three"),
+      });
+
+      expect(text1.first, const _FakePlaceholder("one"));
+      expect(text1[1], "H");
+      expect(text1[6], const _FakePlaceholder("two"));
+      expect(text1[11], "d");
+      expect(text1.last, const _FakePlaceholder("three"));
+
+      final text2 = AttributedText("Hello World", null, {
+        0: const _FakePlaceholder("one"),
+      });
+      expect(text2[11], "d");
+      expect(text2.last, "d");
+    });
+
     test("reports plain text value", () {
       expect(
         AttributedText("", null, {
Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 333
Good morning! Here's your coding interview problem for today.

This problem was asked by Pinterest.

At a party, there is a single person who everyone knows, but who does not know anyone in return (the "celebrity"). To help figure out who this is, you have access to an `O(1)` method called `knows(a, b)`, which returns `True` if person `a` knows person `b`, else `False`.

Given a list of `N` people and the above operation, find a way to identify the celebrity in `O(N)` time.

Pull request:
Day333
Resolves #668.

Patch:
diff --git a/README.md b/README.md
index 6117477..71df4e1 100644
--- a/README.md
+++ b/README.md
@@ -329,6 +329,7 @@ problems from
 * [Day 323](https://github.com/vaskoz/dailycodingproblem-go/issues/656)
 * [Day 324](https://github.com/vaskoz/dailycodingproblem-go/issues/658)
 * [Day 325](https://github.com/vaskoz/dailycodingproblem-go/issues/660)
+* [Day 333](https://github.com/vaskoz/dailycodingproblem-go/issues/668)
 * [Day 337](https://github.com/vaskoz/dailycodingproblem-go/issues/674)
 * [Day 338](https://github.com/vaskoz/dailycodingproblem-go/issues/675)
 * [Day 339](https://github.com/vaskoz/dailycodingproblem-go/issues/676)
diff --git a/day333/problem.go b/day333/problem.go
new file mode 100644
index 0000000..c323255
--- /dev/null
+++ b/day333/problem.go
@@ -0,0 +1,37 @@
+package day333
+
+// Knowing represents a personId knowing another personId.
+// Return true of first person knows the second person.
+// NOTE: This is not bidirectional.
+type Knowing map[int]map[int]bool
+
+func (k *Knowing) Knows(a, b int) bool {
+	if known, exists := (*k)[a]; exists {
+		return known[b]
+	}
+
+	return false
+}
+
+// FindCelebrity returns the ID of the celebrity.
+// Runs in O(N) time and O(1) space.
+func FindCelebrity(knows *Knowing, numPeople int) int {
+	a := 0
+	b := numPeople - 1
+
+	for a < b {
+		if knows.Knows(a, b) {
+			a++
+		} else {
+			b--
+		}
+	}
+
+	for i := 0; i < numPeople; i++ {
+		if i != a && (knows.Knows(a, i) || !knows.Knows(i, a)) {
+			return -1
+		}
+	}
+
+	return a
+}


Test patch:
diff --git a/day333/problem_test.go b/day333/problem_test.go
new file mode 100644
index 0000000..54bbf33
--- /dev/null
+++ b/day333/problem_test.go
@@ -0,0 +1,65 @@
+package day333
+
+import "testing"
+
+// nolint
+var testcases = []struct {
+	knows     *Knowing
+	numPeople int
+	celeb     int
+}{
+	{
+		&Knowing{
+			0: {
+				1: true,
+			},
+			2: {
+				1: true,
+			},
+			3: {
+				1: true,
+			},
+			4: {
+				1: true,
+			},
+		},
+		5,
+		1,
+	},
+	{
+		&Knowing{
+			0: {
+				1: true,
+			},
+			1: {
+				2: true,
+			},
+			2: {
+				3: true,
+			},
+			3: {
+				4: true,
+			},
+		},
+		5,
+		-1,
+	},
+}
+
+func TestFindCelebrity(t *testing.T) {
+	t.Parallel()
+
+	for _, tc := range testcases {
+		if celeb := FindCelebrity(tc.knows, tc.numPeople); celeb != tc.celeb {
+			t.Errorf("Expected %v, got %v", tc.celeb, celeb)
+		}
+	}
+}
+
+func BenchmarkFindCelebrity(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			FindCelebrity(tc.knows, tc.numPeople)
+		}
+	}
+}
Repository: goadesign/goa (go)

Issue:
Union attributes are not described by the OpenAPI specification
Types that are only used as union attributes are not being described by Goa in the OpenAPI specification.
That makes sense given that they map as JSON-encoded strings, but it would be useful to have a mechanism that can be used to force a type to appear in the spec. I have tried both `type:generate:force` and `openapi:generate` with no luck.

Link to [conversation in Slack](https://gophers.slack.com/team/U043DU7LM).

Thank you!

Pull request:
Generate OpenAPI spec for forced types
Fixes #3129

Patch:
diff --git a/http/codegen/openapi/v3/types.go b/http/codegen/openapi/v3/types.go
index f25cbb42..dfdb1c98 100644
--- a/http/codegen/openapi/v3/types.go
+++ b/http/codegen/openapi/v3/types.go
@@ -130,6 +130,13 @@ func buildBodyTypes(api *expr.APIExpr) (map[string]map[string]*EndpointBodies, m
 		}
 		bodies[s.Name()] = sbodies
 	}
+	for _, t := range expr.Root.Types {
+		_, ok := t.Attribute().Meta["type:generate:force"]
+		if !ok {
+			continue
+		}
+		sf.schemafy(&expr.AttributeExpr{Type: t})
+	}
 	return bodies, sf.schemas
 }
 


Test patch:
diff --git a/http/codegen/openapi/v3/testdata/dsls/types.go b/http/codegen/openapi/v3/testdata/dsls/types.go
index 54aa847e..ba9b387f 100644
--- a/http/codegen/openapi/v3/testdata/dsls/types.go
+++ b/http/codegen/openapi/v3/testdata/dsls/types.go
@@ -150,3 +150,19 @@ func ObjectErrorResponseBodyDSL(svcName, metName string) func() {
 		})
 	}
 }
+
+func ForcedTypeDSL(svcName, metName string) func() {
+	return func() {
+		var _ = Type("Forced", func() {
+			Attribute("foo")
+			Meta("type:generate:force")
+		})
+		var _ = Service(svcName, func() {
+			Method(metName, func() {
+				HTTP(func() {
+					POST("/")
+				})
+			})
+		})
+	}
+}
diff --git a/http/codegen/openapi/v3/types_test.go b/http/codegen/openapi/v3/types_test.go
index ace4e4a3..8a0407ad 100644
--- a/http/codegen/openapi/v3/types_test.go
+++ b/http/codegen/openapi/v3/types_test.go
@@ -70,6 +70,7 @@ func TestBuildBodyTypes(t *testing.T) {
 		ExpectedType          typ
 		ExpectedFormat        string
 		ExpectedResponseTypes rt
+		ExpectedExtraTypes    map[string]typ
 	}{{
 		Name: "string_body",
 		DSL:  dsls.StringBodyDSL(svcName, "string_body"),
@@ -142,6 +143,13 @@ func TestBuildBodyTypes(t *testing.T) {
 
 		ExpectedType:          tempty,
 		ExpectedResponseTypes: rt{204: tempty, 400: tobj("name", tstring, "age", tint)},
+	}, {
+		Name: "forced_type",
+		DSL:  dsls.ForcedTypeDSL(svcName, "forced_type"),
+
+		ExpectedType:          tempty,
+		ExpectedResponseTypes: rt{204: tempty},
+		ExpectedExtraTypes:    map[string]typ{"Forced": tobj("foo", tstring)},
 	}}
 
 	for _, c := range cases {
@@ -180,6 +188,14 @@ func TestBuildBodyTypes(t *testing.T) {
 				}
 				matchesSchema(t, "response", met.ResponseBodies[s][0], types, r)
 			}
+			for name, forced := range c.ExpectedExtraTypes {
+				got, ok := types[name]
+				if !ok {
+					t.Errorf("missing forced type %q", name)
+					continue
+				}
+				matchesSchema(t, "extra type", got, types, forced)
+			}
 		})
 	}
 }