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

Issue:
Day 372
Good morning! Here's your coding interview problem for today.

This problem was asked by Amazon.

Write a function that takes a natural number as input and returns the number of digits the input has.

Constraint: don't use any loops.

Pull request:
Day372
Resolves #748.

Patch:
diff --git a/README.md b/README.md
index 89e7ddc..8aadd78 100644
--- a/README.md
+++ b/README.md
@@ -365,4 +365,5 @@ problems from
 * [Day 367](https://github.com/vaskoz/dailycodingproblem-go/issues/740)
 * [Day 368](https://github.com/vaskoz/dailycodingproblem-go/issues/743)
 * [Day 369](https://github.com/vaskoz/dailycodingproblem-go/issues/745)
+* [Day 372](https://github.com/vaskoz/dailycodingproblem-go/issues/748)
 
diff --git a/day372/problem.go b/day372/problem.go
new file mode 100644
index 0000000..c2ac1c8
--- /dev/null
+++ b/day372/problem.go
@@ -0,0 +1,17 @@
+package day372
+
+import "math"
+
+// NumberOfDigits returns the number of digits
+// for a natural number input.
+// Runs in O(1) time and space and doesn't use loops.
+// https://en.wikipedia.org/wiki/Natural_number
+func NumberOfDigits(n int) int {
+	if n == 0 {
+		return 1
+	} else if n < 0 {
+		n = -n
+	}
+
+	return int(math.Log10(float64(n))) + 1
+}


Test patch:
diff --git a/day372/problem_test.go b/day372/problem_test.go
new file mode 100644
index 0000000..a24f365
--- /dev/null
+++ b/day372/problem_test.go
@@ -0,0 +1,36 @@
+package day372
+
+import "testing"
+
+// nolint
+var testcases = []struct {
+	n         int
+	numDigits int
+}{
+	{0, 1},
+	{3, 1},
+	{9, 1},
+	{10, 2},
+	{-10, 2},
+	{-100, 3},
+	{-99, 2},
+	{99, 2},
+}
+
+func TestNumberOfDigits(t *testing.T) {
+	t.Parallel()
+
+	for _, tc := range testcases {
+		if numDigits := NumberOfDigits(tc.n); numDigits != tc.numDigits {
+			t.Errorf("Given %v, expected %v, got %v", tc.n, tc.numDigits, numDigits)
+		}
+	}
+}
+
+func BenchmarkNumberOfDigits(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			NumberOfDigits(tc.n)
+		}
+	}
+}
Repository: gavv/httpexpect (go)

Issue:
Improve test coverage of Number and String
See coverage reports here:

* https://coveralls.io/builds/54781134/source?filename=number.go
* https://coveralls.io/builds/54781134/source?filename=string.go

There are uncovered branches in Number.NotInRange and String.AsNumber. We should cover them in unit tests.

Pull request:
185 fix err handle and add unit test of string and number
fix #185

Patch:
diff --git a/string.go b/string.go
index fccda44..e2b3da6 100644
--- a/string.go
+++ b/string.go
@@ -563,7 +563,7 @@ func (s *String) AsNumber(base ...int) *Number {
 		inum, err = strconv.ParseInt(s.value, base[0], 64)
 		num = float64(inum)
 
-		if err == strconv.ErrRange {
+		if errors.Is(err, strconv.ErrRange) {
 			var unum uint64
 
 			unum, err = strconv.ParseUint(s.value, base[0], 64)


Test patch:
diff --git a/number_test.go b/number_test.go
index ce33b5e..e4ce0be 100644
--- a/number_test.go
+++ b/number_test.go
@@ -252,6 +252,14 @@ func TestNumberInRange(t *testing.T) {
 	value.NotInRange(1234+1, 1234-1)
 	value.chain.assertOK(t)
 	value.chain.reset()
+
+	value.NotInRange(1234+1, "1234+2")
+	value.chain.assertFailed(t)
+	value.chain.reset()
+
+	value.NotInRange("1234+1", 1234+2)
+	value.chain.assertFailed(t)
+	value.chain.reset()
 }
 
 func TestNumberConvertEqual(t *testing.T) {
diff --git a/string_test.go b/string_test.go
index 8aba3cd..3776570 100644
--- a/string_test.go
+++ b/string_test.go
@@ -341,6 +341,20 @@ func TestStringAsNumber(t *testing.T) {
 		value2.chain.assertFailed(t)
 		num2.chain.assertFailed(t)
 		assert.Equal(t, float64(0), num2.Raw())
+
+		value3 := NewString(reporter, "8000000000000000")
+		num3 := value3.AsNumber(16)
+		value3.chain.assertOK(t)
+		num3.chain.assertOK(t)
+		assert.Equal(t, float64(9223372036854775808), num3.Raw())
+	})
+
+	t.Run("multiple_base", func(t *testing.T) {
+		value1 := NewString(reporter, "100")
+		num1 := value1.AsNumber(10, 16)
+		value1.chain.assertFailed(t)
+		num1.chain.assertFailed(t)
+		assert.Equal(t, float64(0), num1.Raw())
 	})
 }