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

Issue:
Day 177
Good morning! Here's your coding interview problem for today.

This problem was asked by Airbnb.

Given a linked list and a positive integer `k`, rotate the list to the right by `k` places.

For example, given the linked list `7 -> 7 -> 3 -> 5` and `k = 2`, it should become `3 -> 5 -> 7 -> 7`.

Given the linked list `1 -> 2 -> 3 -> 4 -> 5` and `k = 3`, it should become `4 -> 5 -> 1 -> 2 -> 3`.

Pull request:
Day177
Resolves #365.

Patch:
diff --git a/README.md b/README.md
index 1f804ba..a28119e 100644
--- a/README.md
+++ b/README.md
@@ -185,3 +185,4 @@ problems from
 * [Day 171](https://github.com/vaskoz/dailycodingproblem-go/issues/356)
 * [Day 172](https://github.com/vaskoz/dailycodingproblem-go/issues/358)
 * [Day 173](https://github.com/vaskoz/dailycodingproblem-go/issues/360)
+* [Day 177](https://github.com/vaskoz/dailycodingproblem-go/issues/365)
diff --git a/day177/problem.go b/day177/problem.go
new file mode 100644
index 0000000..8114d9b
--- /dev/null
+++ b/day177/problem.go
@@ -0,0 +1,33 @@
+package day177
+
+// LL is a singly linked list.
+type LL struct {
+	Value interface{}
+	Next  *LL
+}
+
+// RotateRightLL rotates the linked list to the right
+// by k elements.
+// Runs in O(N) time and O(1) extra space.
+func RotateRightLL(head *LL, k int) *LL {
+	if head == nil {
+		return nil
+	}
+	size := 1
+	var end *LL
+	for end = head; end.Next != nil; end = end.Next {
+		size++
+	}
+	if k%size == 0 {
+		return head
+	}
+	k = k % size
+	curr := head
+	for i := 0; i < k-1; i++ {
+		curr = curr.Next
+	}
+	newHead := curr.Next
+	curr.Next = nil
+	end.Next = head
+	return newHead
+}


Test patch:
diff --git a/day177/problem_test.go b/day177/problem_test.go
new file mode 100644
index 0000000..9860f50
--- /dev/null
+++ b/day177/problem_test.go
@@ -0,0 +1,51 @@
+package day177
+
+import "testing"
+
+var testcases = []struct {
+	input    *LL
+	k        int
+	expected *LL
+}{
+	{&LL{7, &LL{7, &LL{3, &LL{5, nil}}}}, 2, &LL{3, &LL{5, &LL{7, &LL{7, nil}}}}},
+	{&LL{1, &LL{2, &LL{3, &LL{4, &LL{5, nil}}}}}, 3, &LL{4, &LL{5, &LL{1, &LL{2, &LL{3, nil}}}}}},
+	{nil, 10, nil},
+	{&LL{5, nil}, 10000, &LL{5, nil}},
+	{&LL{1, &LL{2, &LL{3, &LL{4, &LL{5, nil}}}}}, 503, &LL{4, &LL{5, &LL{1, &LL{2, &LL{3, nil}}}}}},
+}
+
+func TestRotateRightLL(t *testing.T) {
+	t.Parallel()
+	for tcid, tc := range testcases {
+		copied := cloneLL(tc.input)
+		if result := RotateRightLL(copied, tc.k); !equal(tc.expected, result) {
+			t.Errorf("TCID%d doesn't match expected", tcid)
+		}
+	}
+}
+
+func BenchmarkRotateRightLL(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			copied := cloneLL(tc.input)
+			RotateRightLL(copied, tc.k)
+		}
+	}
+}
+
+func cloneLL(a *LL) *LL {
+	head := &LL{}
+	for ptr := head; a != nil; ptr, a = ptr.Next, a.Next {
+		ptr.Next = &LL{a.Value, nil}
+	}
+	return head.Next
+}
+
+func equal(a, b *LL) bool {
+	for ; a != nil && b != nil; a, b = a.Next, b.Next {
+		if a.Value != b.Value {
+			return false
+		}
+	}
+	return a == nil && b == nil
+}
Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 347
Good morning! Here's your coding interview problem for today.

This problem was asked by Yahoo.

You are given a string of length `N` and a parameter `k`. The string can be manipulated by taking one of the first k letters and moving it to the end.

Write a program to determine the lexicographically smallest string that can be created after an unlimited number of moves.

For example, suppose we are given the string `daily` and `k = 1`. The best we can create in this case is `ailyd`.

Pull request:
Day347
Resolves #689.

Patch:
diff --git a/README.md b/README.md
index 3e2ccd9..cce6a41 100644
--- a/README.md
+++ b/README.md
@@ -333,3 +333,4 @@ problems from
 * [Day 339](https://github.com/vaskoz/dailycodingproblem-go/issues/676)
 * [Day 340](https://github.com/vaskoz/dailycodingproblem-go/issues/679)
 * [Day 342](https://github.com/vaskoz/dailycodingproblem-go/issues/682)
+* [Day 347](https://github.com/vaskoz/dailycodingproblem-go/issues/689)
diff --git a/day347/problem.go b/day347/problem.go
new file mode 100644
index 0000000..1406ea9
--- /dev/null
+++ b/day347/problem.go
@@ -0,0 +1,26 @@
+package day347
+
+import "strings"
+
+// LexicographicallySmallest returns the lexicographically smallest
+// string that can be created after an unlimited number of moves
+func LexicographicallySmallest(str string, k int) string {
+	var sb strings.Builder
+	result := str
+	for len(str) > 0 {
+		smallest := rune(str[0])
+		smallestIndex := 0
+		for i, r := range str {
+			if i < k && r < smallest {
+				smallest = r
+				smallestIndex = i
+			}
+		}
+		str = str[:smallestIndex] + str[smallestIndex+1:]
+		sb.WriteString(string(smallest))
+		if candidate := str + sb.String(); candidate < result {
+			result = candidate
+		}
+	}
+	return result
+}


Test patch:
diff --git a/day347/problem_test.go b/day347/problem_test.go
new file mode 100644
index 0000000..f79ea99
--- /dev/null
+++ b/day347/problem_test.go
@@ -0,0 +1,31 @@
+package day347
+
+import "testing"
+
+// nolint
+var testcases = []struct {
+	str      string
+	k        int
+	expected string
+}{
+	{"daily", 1, "ailyd"},
+	{"gaurang", 3, "agangru"},
+	{"geeksforgeeks", 5, "eefggeekkorss"},
+}
+
+func TestLexicographicallySmallest(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if result := LexicographicallySmallest(tc.str, tc.k); result != tc.expected {
+			t.Errorf("Expected %v, got %v", tc.expected, result)
+		}
+	}
+}
+
+func BenchmarkLexicographicallySmallest(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			LexicographicallySmallest(tc.str, tc.k)
+		}
+	}
+}
Repository: go-critic/go-critic (go)

Issue:
commentedOutCode: false positive for the example output oneliner
The following code in the file `gocritic_test.go` produces `commentedOutCode` false positive:
```go
package env_test

import "fmt"

func ExampleCommentedOutCode() {
	const c = "{Foo:a}"
	fmt.Printf("%v", c)
	// Output: {Foo:a}
}
```

```sh
❯ gocritic check -enable commentedOutCode gocritic_test.go
./gocritic_test.go:8:2: commentedOutCode: may want to remove commented-out code
```


Found in the `caarlos0/env` [repo](https://github.com/caarlos0/env/blob/a9fcfa336f5ca5d31788135b4a6c9b3375b06976/example_test.go#L354):

```sh
❯ gocritic check -enable commentedOutCode example_test.go
./example_test.go:353:2: commentedOutCode: may want to remove commented-out code
./example_test.go:391:2: commentedOutCode: may want to remove commented-out code
```

Pull request:
checkers: fix commentedOutCode false positive
Fixes #1444

Patch:
diff --git a/checkers/commentedOutCode_checker.go b/checkers/commentedOutCode_checker.go
index 8595b79..788355d 100644
--- a/checkers/commentedOutCode_checker.go
+++ b/checkers/commentedOutCode_checker.go
@@ -93,6 +93,10 @@ func (c *commentedOutCodeChecker) VisitLocalComment(cg *ast.CommentGroup) {
 		return
 	}
 
+	if c.isExampleOutputComment(s) {
+		return
+	}
+
 	stmt := strparse.Stmt(s)
 
 	if c.isPermittedStmt(stmt) {
@@ -109,11 +113,6 @@ func (c *commentedOutCodeChecker) VisitLocalComment(cg *ast.CommentGroup) {
 		return
 	}
 
-	// Some attempts to avoid false positives.
-	if c.skipBlock(s) {
-		return
-	}
-
 	// Add braces to make block statement from
 	// multiple statements.
 	stmt = strparse.Stmt(fmt.Sprintf("{ %s }", s))
@@ -123,15 +122,18 @@ func (c *commentedOutCodeChecker) VisitLocalComment(cg *ast.CommentGroup) {
 	}
 }
 
-func (c *commentedOutCodeChecker) skipBlock(s string) bool {
-	lines := strings.Split(s, "\n") // There is at least 1 line, that's invariant
-
-	// Special example test block.
-	if isExampleTestFunc(c.fn) && strings.Contains(lines[0], "Output:") {
-		return true
-	}
-
-	return false
+// An example output comment can be one of the following:
+//
+//	Output: some output
+//
+// or
+//
+//	Output:
+//	some output
+//
+// See https://go.dev/blog/examples
+func (c *commentedOutCodeChecker) isExampleOutputComment(s string) bool {
+	return isExampleTestFunc(c.fn) && strings.Contains(s, "Output:")
 }
 
 func (c *commentedOutCodeChecker) isPermittedStmt(stmt ast.Stmt) bool {


Test patch:
diff --git a/checkers/testdata/commentedOutCode/negative_tests.go b/checkers/testdata/commentedOutCode/negative_tests.go
index cf71ca1..8e7c187 100644
--- a/checkers/testdata/commentedOutCode/negative_tests.go
+++ b/checkers/testdata/commentedOutCode/negative_tests.go
@@ -6,6 +6,10 @@ func ExampleFoo() {
 	// blah
 }
 
+func ExampleBar() {
+	// Output: {Bar:a}
+}
+
 func permittedComments() {
 	// TODO: foo(1+2)
Repository: stylelint-scss/stylelint-scss (js)

Issue:
False positive scss/operator-no-unspaced  Expected single space after "-"
Input:

```
@mixin test {
  @for $i from 0 through 10 {
    &:nth-child(#{$i + 1}) {
      top: #{$i * -10}px;
      transform: scale(#{(10 - $i) * 0.1}) !important;
    }
  }
}
```
Require:

```
@mixin test {
  @for $i from 0 through 10 {
    &:nth-child(#{$i + 1}) {
      top: #{$i * - 10}px;
      transform: scale(#{(10 - $i) * 0.1}) !important;
    }
  }
}
```
Expected (no errors):

```
@mixin test {
  @for $i from 0 through 10 {
    &:nth-child(#{$i + 1}) {
      top: #{$i * -10}px;
      transform: scale(#{(10 - $i) * 0.1}) !important;
    }
  }
}
```

Pull request:
operator-no-unspaced: don't check operators from data URIs
Fixes #561

Patch:
diff --git a/src/rules/operator-no-unspaced/index.js b/src/rules/operator-no-unspaced/index.js
index 397fcda..b33e6fe 100644
--- a/src/rules/operator-no-unspaced/index.js
+++ b/src/rules/operator-no-unspaced/index.js
@@ -147,6 +147,8 @@ export function calculationOperatorSpaceChecker({ root, result, checker }) {
     return results;
   }
 
+  const dataURIRegex = /^url\(\s*['"]?data:.+;base64,.+['"]?\s*\)$/;
+
   root.walk(item => {
     if (item.prop === "unicode-range") {
       return;
@@ -156,6 +158,9 @@ export function calculationOperatorSpaceChecker({ root, result, checker }) {
 
     // Check a value (`10px` in `width: 10px;`)
     if (item.value !== undefined) {
+      if (dataURIRegex.test(item.value)) {
+        return results;
+      }
       results.push({
         source: item.value,
         operators: findOperators({


Test patch:
diff --git a/src/rules/operator-no-unspaced/__tests__/index.js b/src/rules/operator-no-unspaced/__tests__/index.js
index 00a936d..8ce616a 100644
--- a/src/rules/operator-no-unspaced/__tests__/index.js
+++ b/src/rules/operator-no-unspaced/__tests__/index.js
@@ -75,6 +75,10 @@ testRule({
       div { background-image: url(https://99-0a.x.y.rackcdn.com/z.jpg); }
       `,
       description: "Op +: background-image with url that has a hyphen"
+    },
+    {
+      code: `div { background: url(data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0Ljk1IDEwIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6IzQ0NDt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPmFycm93czwvdGl0bGU+PHJlY3QgY2xhc3M9ImNscy0xIiB3aWR0aD0iNC45NSIgaGVpZ2h0PSIxMCIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxLjQxIDQuNjcgMi40OCAzLjE4IDMuNTQgNC42NyAxLjQxIDQuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iMy41NCA1LjMzIDIuNDggNi44MiAxLjQxIDUuMzMgMy41NCA1LjMzIi8+PC9zdmc+) }`,
+      description: "background image with base64 data, issue #561"
     }
   ],
Repository: domluna/JuliaFormatter.jl (julia)

Issue:
Parse error using @inbounds inside an expression
The following is properly formatted by `JuliaFormatter`:

```
threads_count = @inbounds min(remaining_batches_count, threads_count_of_processes[worker_id])
```

But the following fails with a parse error:

```
threads_count = min(remaining_batches_count, @inbounds threads_count_of_processes[worker_id])
```

BTW, it would be nice if, when there is a parse error, there was some indication of where the error was in the file... I had to do a binary search to isolate this line.

Pull request:
When `CSTParser.MacroCall` was split into itself and `MacroBlock` it was forgotten not to add a trailing comma if the final element is a `MacroBlock`.

difference for reference:

```
MacroCall @call(a, b)
MacroBlock @call a
```

fixes #248

Patch:
diff --git a/src/fst.jl b/src/fst.jl
index d4322d192..e887cd60c 100644
--- a/src/fst.jl
+++ b/src/fst.jl
@@ -207,6 +207,7 @@ function add_node!(t::FST, n::FST, s::State; join_lines = false, max_padding = -
            en.typ === CSTParser.Filter ||
            en.typ === CSTParser.Flatten ||
            en.typ === CSTParser.MacroCall ||
+           en.typ === MacroBlock ||
            (is_comma(en) && t.typ === CSTParser.TupleH && n_args(t.ref[]) == 1)
             # don't insert trailing comma in these cases
         elseif is_comma(en)


Test patch:
diff --git a/test/default_style.jl b/test/default_style.jl
index 38509913f..f9521517a 100644
--- a/test/default_style.jl
+++ b/test/default_style.jl
@@ -4781,4 +4781,16 @@ some_function(
                arg2"""
         @test fmt(str_, 4, 1) == str
     end
+
+    @testset "issue 248" begin
+        str_ = """
+        var = call(a, @macrocall b)"""
+        str = """
+        var =
+            call(
+                a,
+                @macrocall b
+            )"""
+        @test fmt(str_, 4, 1) == str
+    end
 end