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

Issue:
Day 15
Good morning! Here's your coding interview problem for today.

This problem was asked by Facebook.

Given a stream of elements too large to store in memory, pick a random element from the stream with uniform probability.

Pull request:
day 15 solution
Resolves #33 

Patch:
diff --git a/README.md b/README.md
index e75b4d3..90dc2b1 100644
--- a/README.md
+++ b/README.md
@@ -25,3 +25,4 @@ problems from
 * [Day 12 Count and Deepest](https://github.com/vaskoz/dailycodingproblem-go/issues/27)
 * [Day 13](https://github.com/vaskoz/dailycodingproblem-go/issues/29)
 * [Day 14](https://github.com/vaskoz/dailycodingproblem-go/issues/31)
+* [Day 15](https://github.com/vaskoz/dailycodingproblem-go/issues/33)
diff --git a/day15/problem.go b/day15/problem.go
new file mode 100644
index 0000000..c123451
--- /dev/null
+++ b/day15/problem.go
@@ -0,0 +1,25 @@
+package day15
+
+import (
+	"math/rand"
+	"time"
+)
+
+var randomizer *rand.Rand = rand.New(rand.NewSource(time.Now().UnixNano()))
+
+// UniformlyRandom reads from a stream of anything and
+// returns an element with uniform probabilty.
+// O(N) time and O(1) space
+func UniformlyRandom(stream <-chan interface{}) interface{} {
+	var result interface{}
+	var count int
+	for element := range stream {
+		if count == 0 {
+			result = element
+		} else if randomizer.Intn(count) == 0 {
+			result = element
+		}
+		count++
+	}
+	return result
+}


Test patch:
diff --git a/day15/problem_test.go b/day15/problem_test.go
new file mode 100644
index 0000000..a8af6eb
--- /dev/null
+++ b/day15/problem_test.go
@@ -0,0 +1,36 @@
+package day15
+
+import (
+	"math/rand"
+	"testing"
+)
+
+func TestUniformlyRandom(t *testing.T) {
+	t.Parallel()
+	randomizer = rand.New(rand.NewSource(99)) // use a fixed seed for testing.
+	expected := 58                            // because of the constant random seed
+	input := make(chan interface{})
+	go func() {
+		for i := 0; i < 100; i++ {
+			input <- i
+		}
+		close(input)
+	}()
+	if result := UniformlyRandom(input); result != 58 {
+		t.Errorf("Expected %v but got %v", expected, result)
+	}
+}
+
+func BenchmarkUniformlyRandom(b *testing.B) {
+	randomizer = rand.New(rand.NewSource(99)) // use a fixed seed for testing.
+	for i := 0; i < b.N; i++ {
+		input := make(chan interface{})
+		go func() {
+			for i := 0; i < 100; i++ {
+				input <- i
+			}
+			close(input)
+		}()
+		UniformlyRandom(input)
+	}
+}
Repository: jpsim/Yams (swift)

Issue:
Failure to represent empty dictionary
I have nested an empty dictionary and YAMS fails to convert it to YAML:
```
failed: caught error: "Failed to represent {
    emptydict =     {
};
```

An empty dictionary should be represented as `{}`.

Pull request:
Fixes #393.

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e653168d..56c4aa8f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,7 +10,10 @@
 
 ##### Bug Fixes
 
-* None.
+* Empty dictionaries can be now represented, regardless of its key or element
+  type information.  
+  [JP Simard](https://github.com/jpsim)
+  [#393](https://github.com/jpsim/Yams/issues/393)
 
 ## 5.0.5
 
diff --git a/Sources/Yams/Representer.swift b/Sources/Yams/Representer.swift
index 759335bb..a749c523 100644
--- a/Sources/Yams/Representer.swift
+++ b/Sources/Yams/Representer.swift
@@ -64,6 +64,8 @@ extension Dictionary: NodeRepresentable {
 private func represent(_ value: Any) throws -> Node {
     if let representable = value as? NodeRepresentable {
         return try representable.represented()
+    } else if (value as? NSDictionary)?.count == 0 {
+        return .mapping(Node.Mapping([]))
     }
     throw YamlError.representer(problem: "Failed to represent \(value)")
 }


Test patch:
diff --git a/Tests/YamsTests/RepresenterTests.swift b/Tests/YamsTests/RepresenterTests.swift
index 4829b479..fa0f4cec 100644
--- a/Tests/YamsTests/RepresenterTests.swift
+++ b/Tests/YamsTests/RepresenterTests.swift
@@ -134,6 +134,10 @@ class RepresenterTests: XCTestCase {
         let intToInt = [1: 2]
         XCTAssertEqual(try Node(intToInt), [1: 2])
     }
+
+    func testEmptyDictionary() throws {
+        XCTAssertEqual(try Yams.dump(object: NSDictionary()), "{}\n")
+    }
 }
 
 extension RepresenterTests {
@@ -149,7 +153,8 @@ extension RepresenterTests {
             ("testUUID", testUUID),
             ("testOptional", testOptional),
             ("testArray", testArray),
-            ("testDictionary", testDictionary)
+            ("testDictionary", testDictionary),
+            ("testEmptyDictionary", testEmptyDictionary)
         ]
     }
 }
Repository: phoenixframework/phoenix_html (elixir)

Issue:
`radio_button` id attribute is not generated correctly 
See: https://github.com/phoenixframework/phoenix_html/blob/v2.10.5/lib/phoenix_html/form.ex#L668

So if radio button value is "purple elephant", id generated will become `record_field_purple elephant`

I think value needs to be stripped of all spaces before concatenating with `input_id/2` .. or replaced with "_"

Pull request:
Fixing id generation on radio buttons. fixes #194
Made a `input_id/3` just so it's easier to generate `for` attribute on labels. Maybe it makes sense to expand `label` to allow value passing. Not sure. One thing at the time.

Patch:
diff --git a/lib/phoenix_html/form.ex b/lib/phoenix_html/form.ex
index 0ab2cb0..7910939 100644
--- a/lib/phoenix_html/form.ex
+++ b/lib/phoenix_html/form.ex
@@ -333,6 +333,16 @@ defmodule Phoenix.HTML.Form do
   def input_id(name, field) when is_atom(name),
     do: "#{name}_#{field}"
 
+
+  @doc """
+  Returns an id of a corresponding form field and value attached to it.
+  Useful for radio buttons and inputs like multiselect checkboxes.
+  """
+  def input_id(name, field, value) do
+    value_id = String.replace(value, ~r/\W/u, "_")
+    input_id(name, field) <> "_" <> value_id
+  end
+
   @doc """
   Returns a name of a corresponding form field.
 
@@ -733,7 +743,7 @@ defmodule Phoenix.HTML.Form do
     opts =
       opts
       |> Keyword.put_new(:type, "radio")
-      |> Keyword.put_new(:id, input_id(form, field) <> "_" <> elem(value, 1))
+      |> Keyword.put_new(:id, input_id(form, field, elem(value, 1)))
       |> Keyword.put_new(:name, input_name(form, field))
 
     opts =


Test patch:
diff --git a/test/phoenix_html/form_test.exs b/test/phoenix_html/form_test.exs
index c10c85d..0b976ee 100644
--- a/test/phoenix_html/form_test.exs
+++ b/test/phoenix_html/form_test.exs
@@ -450,6 +450,9 @@ defmodule Phoenix.HTML.FormTest do
 
     assert safe_to_string(radio_button(:search, :key, "admin", checked: true)) ==
           ~s(<input id="search_key_admin" name="search[key]" type="radio" value="admin" checked>)
+
+    assert safe_to_string(radio_button(:search, :key, "value with spaces")) ==
+          ~s(<input id="search_key_value_with_spaces" name="search[key]" type="radio" value="value with spaces">)
   end
 
   test "radio_button/4 with form" do
@@ -1006,6 +1009,16 @@ defmodule Phoenix.HTML.FormTest do
     assert safe_form(&input_id(&1, :key)) == "search_key"
   end
 
+  ## input_id/3
+
+  test "input_id/3" do
+    assert input_id(:search, :key, "") == "search_key_"
+    assert input_id(:search, :key, "foo") == "search_key_foo"
+    assert input_id(:search, :key, "foo bar") == "search_key_foo_bar"
+    assert input_id(:search, :key, "Foo baR") == "search_key_Foo_baR"
+    assert input_id(:search, :key, "F✓o]o%b+a'R") == "search_key_F_o_o_b_a_R"
+  end
+
   ## input_name/2
 
   test "input_name/2 without form" do