Skip to content

Commit b95a721

Browse files
authored
44 (#295)
1 parent dcc71d1 commit b95a721

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

HumanEvalLean/HumanEval44.lean

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
module
22

3-
def change_base : Unit :=
4-
()
3+
def changeBase (x : Nat) (base : Nat) : String :=
4+
String.ofList (Nat.toDigits base x)
5+
6+
example : changeBase 8 3 = "22" := by native_decide
7+
example : changeBase 9 3 = "100" := by native_decide
8+
example : changeBase 234 2 = "11101010" := by native_decide
9+
example : changeBase 16 2 = "10000" := by native_decide
10+
example : changeBase 8 2 = "1000" := by native_decide
11+
example : changeBase 7 2 = "111" := by native_decide
12+
13+
theorem ofDigitChars_changeBase {x : Nat} {base : Nat} (hb' : 1 < base) (hb : base ≤ 10) :
14+
Nat.ofDigitChars base (changeBase x base).toList 0 = x := by
15+
simp [changeBase, Nat.ofDigitChars_toDigits hb' hb]
516

617
/-!
718
## Prompt
@@ -51,4 +62,4 @@ def check(candidate):
5162
assert candidate(x, x + 1) == str(x)
5263
5364
```
54-
-/
65+
-/

0 commit comments

Comments
 (0)