task_id
stringlengths
3
79
question_id
int64
2
3.24k
difficulty
stringclasses
3 values
tags
listlengths
1
8
description
stringlengths
224
3.74k
leetcode_signature
stringlengths
18
130
rust_signature
stringlengths
25
141
lean_function
stringlengths
13
102
rust_solution
stringlengths
52
8.38k
lean_types
stringlengths
716
1.17k
lean_funs
stringlengths
921
54.6k
lean_funs_external
stringclasses
151 values
lean_eval
stringlengths
420
114k
test_cases
listlengths
3
450
num_test_cases
int64
3
450
order_insensitive
bool
2 classes
rust_cases_passed
int64
3
450
lean_check
stringclasses
2 values
lean_check_cases
int64
3
10
lean_check_cases_true
int64
3
10
num_llm_calls
int64
1
7
total_completion_tokens
int64
41
176k
trajectory
listlengths
7
27
lean_specs
stringlengths
0
31k
num_specs
int64
0
20
add-two-numbers
2
Medium
[ "Recursion", "Linked List", "Math" ]
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself.  ...
addTwoNumbers(l1: linkedlist, l2: linkedlist) -> linkedlist
pub fn add_two_numbers(l1: &List, l2: &List) -> List
Aegis.AddTwoNumbers.add_two_numbers
pub fn add_two_numbers(l1: &List, l2: &List) -> List { let mut a: Vec<i64> = Vec::new(); let mut cur1 = l1; let mut done1 = false; while !done1 { match cur1 { List::Nil => { done1 = true; } List::Cons(v, next) => { a.push(*v); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [add_two_numbers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [add_two_numbers]: function definitions module public import Aeneas public import Aegis.AddTwoNumbers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opt...
import Aegis.AddTwoNumbers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving inst...
[ { "input": "[[0], [0]]", "output": "[0]" }, { "input": "[[5], [5]]", "output": "[0, 1]" }, { "input": "[[1], [9]]", "output": "[0, 1]" }, { "input": "[[9], [1]]", "output": "[0, 1]" }, { "input": "[[1, 8], [0]]", "output": "[1, 8]" }, { "input": "[[1, ...
59
false
59
verified
10
10
1
11,442
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.AddTwoNumbers.Code.Funs /-! # Specifications of `Aegis.AddTwoNumbers.add_two_numbers` LeetCode problem `add-two-numbers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.AddTwoNumbers def digits : Aegis.AddTwoNumbers.List → List Int...
6
longest-substring-without-repeating-characters
3
Medium
[ "Hash Table", "String", "Sliding Window" ]
Given a string s, find the length of the longest substring without repeating characters.   Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: Input: s = "pwwkew" ...
lengthOfLongestSubstring(s: str) -> int
pub fn length_of_longest_substring(s: &[u8]) -> i64
Aegis.LengthOfLongestSubstring.length_of_longest_substring
pub fn length_of_longest_substring(s: &[u8]) -> i64 { let n = s.len(); // last[c] stores the most recent index of byte c, or -1 if unseen. let mut last: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 256 { last.push(-1); i += 1; } let mut best: i64 = 0; let mut ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [length_of_longest_substring]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [length_of_longest_substring]: function definitions module public import Aeneas public import Aegis.LengthOfLongestSubstring.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.ha...
import Aegis.LengthOfLongestSubstring.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #e...
[ { "input": "[\"abcabcbb\"]", "output": "3" }, { "input": "[\"bbbbb\"]", "output": "1" }, { "input": "[\"pwwkew\"]", "output": "3" }, { "input": "[\"abcdabcabcabcd\"]", "output": "4" }, { "input": "[\"abcdefgabcdefgabcdefgabcdefg\"]", "output": "7" }, { ...
36
false
36
verified
10
10
1
2,478
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LengthOfLongestSubstring.Code.Funs /-! # Specifications of `Aegis.LengthOfLongestSubstring.length_of_longest_substring` LeetCode problem `longest-substring-without-repeating-characters`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Le...
13
reverse-integer
7
Medium
[ "Math" ]
Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the environment does not allow you to store 64-bit integers (signed or unsigned).   Example 1: Input: x = 123 Output: 321 Example 2: ...
reverse(x: int) -> int
pub fn reverse(x: i64) -> i64
Aegis.Reverse.reverse
pub fn reverse(x: i64) -> i64 { let limit: i64 = 2147483647; let min_limit: i64 = -2147483648; let negative = x < 0; let mut n = x; if negative { n = -n; } let mut rev: i64 = 0; while n != 0 { let digit = n % 10; n = n / 10; rev = rev * 10 + digit; }...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reverse]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reverse]: function definitions module public import Aeneas public import Aegis.Reverse.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unu...
import Aegis.Reverse.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[-2147483412]", "output": "-2143847412" }, { "input": "[2147483647]", "output": "0" }, { "input": "[120]", "output": "21" }, { "input": "[-123]", "output": "-321" }, { "input": "[1534236469]", "output": "0" }, { "input": "[0]", "output"...
61
false
61
verified
10
10
1
464
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Reverse.Code.Funs /-! # Specifications of `Aegis.Reverse.reverse` LeetCode problem `reverse-integer`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Reverse def InI32 (n : ℤ) : Prop := -2147483648 ≤ n ∧ n ≤ 2147483647 instance inI32_d...
16
string-to-integer-atoi
8
Medium
[ "String" ]
Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer. The algorithm for myAtoi(string s) is as follows: Whitespace: Ignore any leading whitespace (" "). Signedness: Determine the sign by checking if the next character is '-' or '+', assuming positivity if neither present. Convers...
myAtoi(s: str) -> int
pub fn my_atoi(s: &[u8]) -> i64
Aegis.MyAtoi.my_atoi
pub fn my_atoi(s: &[u8]) -> i64 { let n = s.len(); let mut i: usize = 0; while i < n && s[i] == b' ' { i += 1; } let mut sign: i64 = 1; if i < n { if s[i] == b'-' { sign = -1; i += 1; } else if s[i] == b'+' { i += 1; } } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [my_atoi]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [my_atoi]: function definitions module public import Aeneas public import Aegis.MyAtoi.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unus...
import Aegis.MyAtoi.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "eva...
[ { "input": "[\"2147483647\"]", "output": "2147483647" }, { "input": "[\"42 with words\"]", "output": "42" }, { "input": "[\"20000000000000000000000000000000000000000\"]", "output": "2147483647" }, { "input": "[\"-2147483649\"]", "output": "-2147483648" }, { "input...
185
false
185
verified
10
10
1
1,623
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MyAtoi.Code.Funs /-! # Specifications of `Aegis.MyAtoi.my_atoi` LeetCode problem `string-to-integer-atoi`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MyAtoi abbrev Byte := Aeneas.Std.U8 abbrev ByteSlice := Aeneas.Std.Slice Aeneas....
14
palindrome-number
9
Easy
[ "Math" ]
Given an integer x, return true if x is a palindrome, and false otherwise.   Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Example 2: Input: x = -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Th...
isPalindrome(x: int) -> bool
pub fn is_palindrome(x: i64) -> bool
Aegis.IsPalindrome.is_palindrome
pub fn is_palindrome(x: i64) -> bool { if x < 0 { return false; } if x != 0 && x % 10 == 0 { return false; } let mut n: i64 = x; let mut reversed: i64 = 0; while n > reversed { reversed = reversed * 10 + n % 10; n = n / 10; } n == reversed || n == r...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_palindrome]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_palindrome]: function definitions module public import Aeneas public import Aegis.IsPalindrome.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.IsPalindrome.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[1221]", "output": "true" }, { "input": "[10]", "output": "false" }, { "input": "[123421]", "output": "false" }, { "input": "[1]", "output": "true" }, { "input": "[-121]", "output": "false" }, { "input": "[12345678987654321]", "output":...
54
false
54
verified
10
10
1
2,511
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsPalindrome.Code.Funs /-! # Specifications of `Aegis.IsPalindrome.is_palindrome` LeetCode problem `palindrome-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsPalindrome def digitsRev (n : Nat) : List Nat := if h : n = 0 th...
6
regular-expression-matching
10
Hard
[ "Recursion", "String", "Dynamic Programming" ]
Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where: '.' Matches any single character.​​​​ '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial).   Example 1: Input: s = "aa", p = "a" Output: fa...
isMatch(s: str, p: str) -> bool
pub fn is_match(s: &[u8], p: &[u8]) -> bool
Aegis.IsMatch.is_match
pub fn is_match(s: &[u8], p: &[u8]) -> bool { let n: usize = s.len(); let m: usize = p.len(); let cols: usize = m + 1; let total: usize = (n + 1) * cols; let mut dp: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < total { dp.push(0); k += 1; } dp[0] = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_match]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_match]: function definitions module public import Aeneas public import Aegis.IsMatch.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.IsMatch.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[\"aa\", \"a*\"]", "output": "true" }, { "input": "[\"aab\", \"c*a*b\"]", "output": "true" }, { "input": "[\"ab\", \".*\"]", "output": "true" }, { "input": "[\"aa\", \"a\"]", "output": "false" }, { "input": "[\"mississippi\", \"mis*is*p*.\"]", "out...
151
false
151
verified
10
10
1
2,769
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsMatch.Code.Funs /-! # Specifications of `Aegis.IsMatch.is_match` LeetCode problem `regular-expression-matching`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsMatch open Aegis.IsMatch def isLowerByte (b : U8) : Prop := 97 ≤...
11
container-with-most-water
11
Medium
[ "Greedy", "Array", "Two Pointers" ]
You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]). Find two lines that together with the x-axis form a container, such that the container contains the most water. Return the maximum amount of water a container ca...
maxArea(height: list_int) -> int
pub fn max_area(height: &[i64]) -> i64
Aegis.MaxArea.max_area
pub fn max_area(height: &[i64]) -> i64 { let n = height.len(); if n < 2 { return 0; } let mut left: usize = 0; let mut right: usize = n - 1; let mut best: i64 = 0; while left < right { let lh = height[left]; let rh = height[right]; let h = if lh < rh { lh }...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_area]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_area]: function definitions module public import Aeneas public import Aegis.MaxArea.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.MaxArea.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[[1, 1]]", "output": "1" }, { "input": "[[1, 2, 1]]", "output": "2" }, { "input": "[[1, 2, 4, 3]]", "output": "4" }, { "input": "[[4, 3, 2, 1, 4]]", "output": "16" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "6" }, { "input": "[[2, 3, 10, ...
116
false
116
verified
10
10
1
591
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxArea.Code.Funs /-! # Specifications of `Aegis.MaxArea.max_area` LeetCode problem `container-with-most-water`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxArea def size (height : Slice Std.I64) : ℕ := height.val.length def ele...
14
roman-to-integer
13
Easy
[ "Hash Table", "Math", "String" ]
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just two ones added together. 12 is written as...
romanToInt(s: str) -> int
pub fn roman_to_int(s: &[u8]) -> i64
Aegis.RomanToInt.roman_to_int
fn roman_value(c: u8) -> i64 { if c == b'I' { 1 } else if c == b'V' { 5 } else if c == b'X' { 10 } else if c == b'L' { 50 } else if c == b'C' { 100 } else if c == b'D' { 500 } else if c == b'M' { 1000 } else { 0 } } pub...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [roman_to_int]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [roman_to_int]: function definitions module public import Aeneas public import Aegis.RomanToInt.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option li...
import Aegis.RomanToInt.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[\"XCIX\"]", "output": "99" }, { "input": "[\"MMCMXCIX\"]", "output": "2999" }, { "input": "[\"MMMCMXCIX\"]", "output": "3999" }, { "input": "[\"DCXXI\"]", "output": "621" }, { "input": "[\"XC\"]", "output": "90" }, { "input": "[\"VIII\"]",...
94
false
94
verified
10
10
1
516
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RomanToInt.Code.Funs /-! # Specifications of `Aegis.RomanToInt.roman_to_int` LeetCode problem `roman-to-integer`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RomanToInt def bI : U8 := 73#u8 def bV : U8 := 86#u8 def bX : U8 := 88#u...
9
3sum
15
Medium
[ "Array", "Two Pointers", "Sorting" ]
Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain duplicate triplets.   Example 1: Input: nums = [-1,0,1,2,-1,-4] Output: [[-1,-1,2],[-1,0,1]] Explanation: nums[0] +...
threeSum(nums: list_int) -> list_list_int
pub fn three_sum(nums: &[i64]) -> Vec<Vec<i64>>
Aegis.ThreeSum.three_sum
#![allow(unused_macros)] // A crate-local `vec!` shadowing the prelude one. // The empty arm is pinned to `Vec<Vec<i64>>` so that comparisons such as // `assert_eq!(three_sum(...), vec![])` are unambiguous (the std empty // `Vec<_>` cannot be inferred when the element type is itself a `Vec`). #[macro_export] macro_rul...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [three_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [three_sum]: function definitions module public import Aeneas public import Aegis.ThreeSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.ThreeSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[0, 1, 1]]", "output": "[]" }, { "input": "[[1, 2, -2, -1]]", "output": "[]" }, { "input": "[[0, 0, 0]]", "output": "[[0, 0, 0]]" }, { "input": "[[-1, 1, 0]]", "output": "[[-1, 0, 1]]" }, { "input": "[[1, -1, -1, 0]]", "output": "[[-1, 0, 1]]" }...
103
false
103
verified
10
10
2
32,449
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ThreeSum.Code.Funs /-! # Specifications of `Aegis.ThreeSum.three_sum` LeetCode problem `3sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ThreeSum abbrev VecI64 : Type := Aeneas.Std.alloc.vec.Vec Aeneas.Std.I64 abbrev VecVec...
8
3sum-closest
16
Medium
[ "Array", "Two Pointers", "Sorting" ]
Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution.   Example 1: Input: nums = [-1,2,1,-4], target = 1 Output: 2 Explanation: The sum that...
threeSumClosest(nums: list_int, target: int) -> int
pub fn three_sum_closest(nums: &[i64], target: i64) -> i64
Aegis.ThreeSumClosest.three_sum_closest
pub fn three_sum_closest(nums: &[i64], target: i64) -> i64 { let n = nums.len(); let mut arr: Vec<i64> = Vec::new(); let mut k = 0; while k < n { arr.push(nums[k]); k += 1; } // Selection sort the copied array. let mut i = 0; while i < n { let mut min_idx = i; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [three_sum_closest]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [three_sum_closest]: function definitions module public import Aeneas public import Aegis.ThreeSumClosest.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set...
import Aegis.ThreeSumClosest.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegis...
[ { "input": "[[0, 0, 0], 1]", "output": "0" }, { "input": "[[1, 1, 1, 0], -100]", "output": "2" }, { "input": "[[-10, -2, -5, -1], -12]", "output": "-13" }, { "input": "[[1, 1, 1, 1], 3]", "output": "3" }, { "input": "[[5, 5, 5, 5], 15]", "output": "15" }, ...
99
false
99
verified
10
10
2
2,631
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ThreeSumClosest.Code.Funs /-! # Specifications of `Aegis.ThreeSumClosest.three_sum_closest` LeetCode problem `3sum-closest`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ThreeSumClosest def nth (nums : Slice Std.I64) (i : Nat) : ...
14
4sum
18
Medium
[ "Array", "Two Pointers", "Sorting" ]
Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: 0 <= a, b, c, d < n a, b, c, and d are distinct. nums[a] + nums[b] + nums[c] + nums[d] == target You may return the answer in any order.   Example 1: Input: nums = [1,0,-1,0,-2,2], target ...
fourSum(nums: list_int, target: int) -> list_list_int
pub fn four_sum(nums: &[i64], target: i64) -> Vec<Vec<i64>>
Aegis.FourSum.four_sum
pub fn four_sum(nums: &[i64], target: i64) -> Vec<Vec<i64>> { let n = nums.len(); let mut a: Vec<i64> = Vec::new(); let mut idx: usize = 0; while idx < n { a.push(nums[idx]); idx += 1; } // Selection sort the copied array. let mut i: usize = 0; while i < n { let...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [four_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [four_sum]: function definitions module public import Aeneas public import Aegis.FourSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.FourSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[[0, 0, 0, 0], 0]", "output": "[[0, 0, 0, 0]]" }, { "input": "[[1000000000, 1000000000, 1000000000, 1000000000], 4000000000]", "output": "[[1000000000, 1000000000, 1000000000, 1000000000]]" }, { "input": "[[1000000000, 1000000000, 1000000000, 1000000000], 4000000000]", "o...
90
true
90
verified
10
10
1
11,264
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FourSum.Code.Funs /-! # Specifications of `Aegis.FourSum.four_sum` LeetCode problem `4sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FourSum def sliceVals (nums : Slice Std.I64) : List Int := nums.val.map (fun x => x.val) def ve...
11
remove-nth-node-from-end-of-list
19
Medium
[ "Linked List", "Two Pointers" ]
Given the head of a linked list, remove the nth node from the end of the list and return its head.   Example 1: Input: head = [1,2,3,4,5], n = 2 Output: [1,2,3,5] Example 2: Input: head = [1], n = 1 Output: [] Example 3: Input: head = [1,2], n = 1 Output: [1]   Constraints: The number of nodes in the list is sz...
removeNthFromEnd(head: linkedlist, n: int) -> linkedlist
pub fn remove_nth_from_end(head: &List, n: i64) -> List
Aegis.RemoveNthFromEnd.remove_nth_from_end
pub fn remove_nth_from_end(head: &List, n: i64) -> List { let size = list_len(head); let target = size - n; remove_at(head, 0, target) } fn list_len(l: &List) -> i64 { match l { List::Nil => 0, List::Cons(_, next) => 1 + list_len(next), } } fn remove_at(l: &List, idx: i64, target: ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_nth_from_end]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_nth_from_end]: function definitions module public import Aeneas public import Aegis.RemoveNthFromEnd.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.RemoveNthFromEnd.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving i...
[ { "input": "[[1, 2], 1]", "output": "[1]" }, { "input": "[[5, 10], 2]", "output": "[10]" }, { "input": "[[1, 2], 2]", "output": "[2]" }, { "input": "[[1, 2, 3], 3]", "output": "[2, 3]" }, { "input": "[[30, 20, 10], 2]", "output": "[30, 10]" }, { "input...
77
false
77
verified
10
10
1
1,602
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RemoveNthFromEnd.Code.Funs /-! # Specifications of `Aegis.RemoveNthFromEnd.remove_nth_from_end` LeetCode problem `remove-nth-node-from-end-of-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RemoveNthFromEnd def values : Aegis.Rem...
12
valid-parentheses
20
Easy
[ "Stack", "String" ]
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Every close bracket has a corresponding open bracket of the...
isValid(s: str) -> bool
pub fn is_valid(s: &[u8]) -> bool
Aegis.IsValid.is_valid
pub fn is_valid(s: &[u8]) -> bool { let mut stack: Vec<u8> = Vec::new(); let n = s.len(); let mut i: usize = 0; while i < n { let c = s[i]; if c == b'(' || c == b'[' || c == b'{' { stack.push(c); } else { if stack.len() == 0 { return fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_valid]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_valid]: function definitions module public import Aeneas public import Aegis.IsValid.Code.Types public import Aegis.IsValid.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_valid]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.IsValid.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option li...
import Aegis.IsValid.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[\"((((((()))))))\"]", "output": "true" }, { "input": "[\"{[()]}\"]", "output": "true" }, { "input": "[\"[[[[[[{{{{}}}}]]]]]]\"]", "output": "true" }, { "input": "[\"({[(])})\"]", "output": "false" }, { "input": "[\"([)]\"]", "output": "false" },...
148
false
148
verified
10
10
1
934
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsValid.Code.Funs /-! # Specifications of `Aegis.IsValid.is_valid` LeetCode problem `valid-parentheses`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsValid def openingBracket (b : Std.U8) : Prop := b = 40#u8 ∨ b = 91#u8 ∨ b...
12
merge-two-sorted-lists
21
Easy
[ "Recursion", "Linked List" ]
You are given the heads of two sorted linked lists list1 and list2. Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list.   Example 1: Input: list1 = [1,2,4], list2 = [1,3,4] Output: [1,1,2,3,4,4] Example 2:...
mergeTwoLists(list1: linkedlist, list2: linkedlist) -> linkedlist
pub fn merge_two_lists(list1: &List, list2: &List) -> List
Aegis.MergeTwoLists.merge_two_lists
fn copy_list(list: &List) -> List { match list { List::Nil => List::Nil, List::Cons(value, next) => { List::Cons(*value, Box::new(copy_list(&**next))) } } } pub fn merge_two_lists(list1: &List, list2: &List) -> List { match list1 { List::Nil => copy_list(list2), ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [merge_two_lists]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [merge_two_lists]: function definitions module public import Aeneas public import Aegis.MergeTwoLists.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opt...
import Aegis.MergeTwoLists.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving inst...
[ { "input": "[[], [0]]", "output": "[0]" }, { "input": "[[10], [10]]", "output": "[10, 10]" }, { "input": "[[5], [4]]", "output": "[4, 5]" }, { "input": "[[100], [-100]]", "output": "[-100, 100]" }, { "input": "[[100], [50, 75, 100]]", "output": "[50, 75, 100, ...
110
false
110
verified
10
10
1
1,798
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MergeTwoLists.Code.Funs /-! # Specifications of `Aegis.MergeTwoLists.merge_two_lists` LeetCode problem `merge-two-sorted-lists`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MergeTwoLists abbrev RList : Type := Aegis.MergeTwoList...
15
generate-parentheses
22
Medium
[ "String", "Dynamic Programming", "Backtracking" ]
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.   Example 1: Input: n = 3 Output: ["((()))","(()())","(())()","()(())","()()()"] Example 2: Input: n = 1 Output: ["()"]   Constraints: 1 <= n <= 8
generateParenthesis(n: int) -> list_str
pub fn generate_parenthesis(n: i64) -> Vec<Vec<u8>>
Aegis.GenerateParenthesis.generate_parenthesis
pub fn generate_parenthesis(n: i64) -> Vec<Vec<u8>> { let target: usize = (2 * n) as usize; let mut result: Vec<Vec<u8>> = Vec::new(); let mut cur: Vec<u8> = Vec::new(); let mut opens: Vec<i64> = Vec::new(); let mut closes: Vec<i64> = Vec::new(); let mut states: Vec<i64> = Vec::new(); ope...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [generate_parenthesis]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [generate_parenthesis]: function definitions module public import Aeneas public import Aegis.GenerateParenthesis.Code.Types public import Aegis.GenerateParenthesis.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [generate_parenthesis]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.GenerateParenthesis.Code.Types @[expose] public section open Aeneas Aeneas.Std Result Control...
import Aegis.GenerateParenthesis.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval a...
[ { "input": "[1]", "output": "[\"()\"]" }, { "input": "[2]", "output": "[\"(())\", \"()()\"]" }, { "input": "[3]", "output": "[\"((()))\", \"(()())\", \"(())()\", \"()(())\", \"()()()\"]" }, { "input": "[4]", "output": "[\"(((())))\", \"((()()))\", \"((())())\", \"((()))()...
7
false
7
verified_partial
7
5
1
4,232
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GenerateParenthesis.Code.Funs /-! # Specifications of `Aegis.GenerateParenthesis.generate_parenthesis` LeetCode problem `generate-parentheses`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GenerateParenthesis def countByte (s : L...
11
swap-nodes-in-pairs
24
Medium
[ "Recursion", "Linked List" ]
Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.)   Example 1: Input: head = [1,2,3,4] Output: [2,1,4,3] Explanation: Example 2: Input: head = [] Output: [] Example 3: In...
swapPairs(head: linkedlist) -> linkedlist
pub fn swap_pairs(head: &List) -> List
Aegis.SwapPairs.swap_pairs
pub fn swap_pairs(head: &List) -> List { match head { List::Nil => List::Nil, List::Cons(v1, next1) => { match &**next1 { List::Nil => List::Cons(*v1, Box::new(List::Nil)), List::Cons(v2, next2) => { let rest = swap_pairs(next2); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [swap_pairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [swap_pairs]: function definitions module public import Aeneas public import Aegis.SwapPairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.SwapPairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving instance...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[5]]", "output": "[5]" }, { "input": "[[42]]", "output": "[42]" }, { "input": "[[1, 2]]", "output": "[2, 1]" }, { "input": "[[42, 42]]", "output": "[42, 42]" }, { "input": "[[5, 4]]", "output": "[...
92
false
92
verified
10
10
1
739
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SwapPairs.Code.Funs /-! # Specifications of `Aegis.SwapPairs.swap_pairs` LeetCode problem `swap-nodes-in-pairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace Aegis.SwapPairs def List.val : List → _root_.List Aeneas.Std.I64 | List.Nil => [] ...
3
reverse-nodes-in-k-group
25
Hard
[ "Recursion", "Linked List" ]
Given the head of a linked list, reverse the nodes of the list k at a time, and return the modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes, in the end, should remain as it is. You may not alter the value...
reverseKGroup(head: linkedlist, k: int) -> linkedlist
pub fn reverse_k_group(head: &List, k: i64) -> List
Aegis.ReverseKGroup.reverse_k_group
pub fn reverse_k_group(head: &List, k: i64) -> List { // Collect the node values in reverse order using structural recursion // (no loop-carried reference rebinding, no match/break inside a loop). let rev: Vec<i64> = collect_reversed(head); let n: usize = rev.len(); // Turn the reversed collection ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reverse_k_group]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reverse_k_group]: function definitions module public import Aeneas public import Aegis.ReverseKGroup.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opt...
import Aegis.ReverseKGroup.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving inst...
[ { "input": "[[1], 1]", "output": "[1]" }, { "input": "[[1, 2], 2]", "output": "[2, 1]" }, { "input": "[[1, 2], 1]", "output": "[1, 2]" }, { "input": "[[1, 2, 3], 1]", "output": "[1, 2, 3]" }, { "input": "[[1, 2, 3], 3]", "output": "[3, 2, 1]" }, { "inp...
107
false
107
verified
10
10
2
23,115
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ReverseKGroup.Code.Funs /-! # Specifications of `Aegis.ReverseKGroup.reverse_k_group` LeetCode problem `reverse-nodes-in-k-group`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace Aegis.ReverseKGroup def List.val : List → _root_.List Int | List....
6
remove-duplicates-from-sorted-array
26
Easy
[ "Array", "Two Pointers" ]
Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Then return the number of unique elements in nums. Consider the number of unique elements of nums to be k, to get accept...
removeDuplicates(nums: list_int) -> int
pub fn remove_duplicates(nums: &[i64]) -> i64
Aegis.RemoveDuplicates.remove_duplicates
pub fn remove_duplicates(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut k: i64 = 1; let mut i: usize = 1; while i < n { if nums[i] != nums[i - 1] { k += 1; } i += 1; } k }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_duplicates]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_duplicates]: function definitions module public import Aeneas public import Aegis.RemoveDuplicates.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false se...
import Aegis.RemoveDuplicates.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[-100, 100]]", "output": "2" }, { "input": "[[-100, 0, 100]]", "output": "3" }, { "input": "[[1, 1, 2]]", "output": "2" }, { "input": "[[-1, -1, -1, -1, -1]]", "output": "1" }, { "input": "[[0, 0, 0, 0,...
127
false
127
verified
10
10
1
284
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RemoveDuplicates.Code.Funs /-! # Specifications of `Aegis.RemoveDuplicates.remove_duplicates` LeetCode problem `remove-duplicates-from-sorted-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.RemoveDuplicates set_option autoImplicit fals...
12
remove-element
27
Easy
[ "Array", "Two Pointers" ]
Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The order of the elements may be changed. Then return the number of elements in nums which are not equal to val. Consider the number of elements in nums which are not equal to val be k, to get accepted, you need to do the fo...
removeElement(nums: list_int, val: int) -> int
pub fn remove_element(nums: &[i64], val: i64) -> i64
Aegis.RemoveElement.remove_element
pub fn remove_element(nums: &[i64], val: i64) -> i64 { let mut k: i64 = 0; let mut i: usize = 0; let n: usize = nums.len(); while i < n { if nums[i] != val { k += 1; } i += 1; } k }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_element]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_element]: function definitions module public import Aeneas public import Aegis.RemoveElement.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.RemoveElement.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[], 1]", "output": "0" }, { "input": "[[42], 100]", "output": "1" }, { "input": "[[42], 42]", "output": "0" }, { "input": "[[3, 2, 2, 3], 3]", "output": "2" }, { "input": "[[0, 0, 0, 0, 0], 0]", "output": "0" }, { "input": "[[50, 49, 48, 4...
112
false
112
verified
10
10
1
295
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RemoveElement.Code.Funs /-! # Specifications of `Aegis.RemoveElement.remove_element` LeetCode problem `remove-element`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.RemoveElement namespace AegisSpec.RemoveElement def vals (nums : Slice Std.I6...
10
find-the-index-of-the-first-occurrence-in-a-string
28
Easy
[ "Two Pointers", "String", "String Matching" ]
Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.   Example 1: Input: haystack = "sadbutsad", needle = "sad" Output: 0 Explanation: "sad" occurs at index 0 and 6. The first occurrence is at index 0, so we return 0. Example 2...
strStr(haystack: str, needle: str) -> int
pub fn str_str(haystack: &[u8], needle: &[u8]) -> i64
Aegis.StrStr.str_str
pub fn str_str(haystack: &[u8], needle: &[u8]) -> i64 { let n = haystack.len(); let m = needle.len(); if m == 0 { return 0; } if m > n { return -1; } let mut i: usize = 0; while i + m <= n { let mut j: usize = 0; let mut matched: bool = true; wh...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [str_str]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [str_str]: function definitions module public import Aeneas public import Aegis.StrStr.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unus...
import Aegis.StrStr.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "eva...
[ { "input": "[\"ababcabcabababd\", \"ababd\"]", "output": "10" }, { "input": "[\"abcde\", \"f\"]", "output": "-1" }, { "input": "[\"mississippi\", \"issi\"]", "output": "1" }, { "input": "[\"sadbutsad\", \"sad\"]", "output": "0" }, { "input": "[\"abababa\", \"aba\"...
144
false
144
verified
10
10
1
475
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.StrStr.Code.Funs /-! # Specifications of `Aegis.StrStr.str_str` LeetCode problem `find-the-index-of-the-first-occurrence-in-a-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.StrStr namespace AegisSpec.StrStr def IsLowerByte (b : Std.U8)...
10
divide-two-integers
29
Medium
[ "Bit Manipulation", "Math" ]
Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod operator. The integer division should truncate toward zero, which means losing its fractional part. For example, 8.345 would be truncated to 8, and -2.7335 would be truncated to -2. Return the quotient after div...
divide(dividend: int, divisor: int) -> int
pub fn divide(dividend: i64, divisor: i64) -> i64
Aegis.Divide.divide
pub fn divide(dividend: i64, divisor: i64) -> i64 { let mut negative: bool = false; if dividend < 0 { if divisor > 0 { negative = true; } } else { if divisor < 0 { negative = true; } } let mut a: i64 = dividend; if a < 0 { a = -a; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [divide]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style.w...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [divide]: function definitions module public import Aeneas public import Aegis.Divide.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unuse...
import Aegis.Divide.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "eva...
[ { "input": "[10, 3]", "output": "3" }, { "input": "[-2147483648, 2]", "output": "-1073741824" }, { "input": "[-2147483648, -1]", "output": "2147483647" }, { "input": "[-1, -1]", "output": "1" }, { "input": "[2147483647, 1]", "output": "2147483647" }, { ...
135
false
135
verified
10
10
1
4,468
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Divide.Code.Funs /-! # Specifications of `Aegis.Divide.divide` LeetCode problem `divide-two-integers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Divide def clamp (x lo hi : ℤ) : ℤ := if x < lo then lo else if hi < x then hi else...
8
substring-with-concatenation-of-all-words
30
Hard
[ "Hash Table", "String", "Sliding Window" ]
You are given a string s and an array of strings words. All the strings of words are of the same length. A concatenated string is a string that exactly contains all the strings of any permutation of words concatenated. For example, if words = ["ab","cd","ef"], then "abcdef", "abefcd", "cdabef", "cdefab", "efabcd", and...
findSubstring(s: str, words: list_str) -> list_int
pub fn find_substring(s: &[u8], words: &[Vec<u8>]) -> Vec<i64>
Aegis.FindSubstring.find_substring
fn new_row() -> Vec<i64> { let mut row: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < 26 { row.push(-1); k += 1; } row } pub fn find_substring(s: &[u8], words: &[Vec<u8>]) -> Vec<i64> { let mut answer: Vec<i64> = Vec::new(); let nw: usize = words.len(); if nw =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_substring]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_substring]: function definitions module public import Aeneas public import Aegis.FindSubstring.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.FindSubstring.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[\"mississippi\", [\"issi\", \"ippi\"]]", "output": "[]" }, { "input": "[\"a\", [\"a\", \"a\", \"a\"]]", "output": "[]" }, { "input": "[\"oneonetwoonethreetwothreeonetwothreeone\", [\"one\", \"two\", \"three\"]]", "output": "[]" }, { "input": "[\"aabbccddeeff\", [...
94
true
94
verified
10
10
1
7,972
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindSubstring.Code.Funs /-! # Specifications of `Aegis.FindSubstring.find_substring` LeetCode problem `substring-with-concatenation-of-all-words`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindSubstring def IsAsciiLower (b : U8) :...
9
longest-valid-parentheses
32
Hard
[ "Stack", "String", "Dynamic Programming" ]
Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring.   Example 1: Input: s = "(()" Output: 2 Explanation: The longest valid parentheses substring is "()". Example 2: Input: s = ")()())" Output: 4 Explanation: The longest valid parenthe...
longestValidParentheses(s: str) -> int
pub fn longest_valid_parentheses(s: &[u8]) -> i64
Aegis.LongestValidParentheses.longest_valid_parentheses
pub fn longest_valid_parentheses(s: &[u8]) -> i64 { let n = s.len(); let mut dp: Vec<i64> = Vec::new(); let mut i = 0; while i < n { dp.push(0); i += 1; } let mut best: i64 = 0; let mut i = 0; while i < n { if s[i] == b')' { if i >= 1 && s[i - 1] ==...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_valid_parentheses]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_op...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_valid_parentheses]: function definitions module public import Aeneas public import Aegis.LongestValidParentheses.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashC...
import Aegis.LongestValidParentheses.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #ev...
[ { "input": "[\"(()())\"]", "output": "6" }, { "input": "[\"())\"]", "output": "2" }, { "input": "[\"())(()\"]", "output": "2" }, { "input": "[\"((((((()))))))\"]", "output": "14" }, { "input": "[\"((())()())()\"]", "output": "12" }, { "input": "[\")()(...
133
false
133
verified
10
10
1
3,267
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestValidParentheses.Code.Funs /-! # Specifications of `Aegis.LongestValidParentheses.longest_valid_parentheses` LeetCode problem `longest-valid-parentheses`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestValidParentheses ...
13
find-first-and-last-position-of-element-in-sorted-array
34
Medium
[ "Array", "Binary Search" ]
Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. If target is not found in the array, return [-1, -1]. You must write an algorithm with O(log n) runtime complexity.   Example 1: Input: nums = [5,7,7,8,8,10], target = 8 Output: [3,4] Example 2...
searchRange(nums: list_int, target: int) -> list_int
pub fn search_range(nums: &[i64], target: i64) -> Vec<i64>
Aegis.SearchRange.search_range
pub fn search_range(nums: &[i64], target: i64) -> Vec<i64> { let n = nums.len(); let mut res: Vec<i64> = Vec::new(); let mut lo: usize = 0; let mut hi: usize = n; while lo < hi { let mid = lo + (hi - lo) / 2; if nums[mid] < target { lo = mid + 1; } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [search_range]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [search_range]: function definitions module public import Aeneas public import Aegis.SearchRange.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.SearchRange.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[], 0]", "output": "[-1, -1]" }, { "input": "[[1], 1]", "output": "[0, 0]" }, { "input": "[[1], 0]", "output": "[-1, -1]" }, { "input": "[[1], 2]", "output": "[-1, -1]" }, { "input": "[[1, 2, 3, 4, 5], 5]", "output": "[4, 4]" }, { "input":...
137
false
137
verified
10
10
1
2,723
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SearchRange.Code.Funs /-! # Specifications of `Aegis.SearchRange.search_range` LeetCode problem `find-first-and-last-position-of-element-in-sorted-array`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SearchRange open Aegis.Search...
13
search-insert-position
35
Easy
[ "Array", "Binary Search" ]
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with O(log n) runtime complexity.   Example 1: Input: nums = [1,3,5,6], target = 5 Output: 2 Example 2: Input: nu...
searchInsert(nums: list_int, target: int) -> int
pub fn search_insert(nums: &[i64], target: i64) -> i64
Aegis.SearchInsert.search_insert
pub fn search_insert(nums: &[i64], target: i64) -> i64 { let mut lo: usize = 0; let mut hi: usize = nums.len(); while lo < hi { let mid: usize = lo + (hi - lo) / 2; if nums[mid] < target { lo = mid + 1; } else { hi = mid; } } lo as i64 }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [search_insert]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [search_insert]: function definitions module public import Aeneas public import Aegis.SearchInsert.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.SearchInsert.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[1], 1]", "output": "0" }, { "input": "[[1], 0]", "output": "0" }, { "input": "[[1], 2]", "output": "1" }, { "input": "[[10000], 9999]", "output": "0" }, { "input": "[[10000], 10001]", "output": "1" }, { "input": "[[1, 3], 2]", "output...
117
false
117
verified
10
10
1
314
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SearchInsert.Code.Funs /-! # Specifications of `Aegis.SearchInsert.search_insert` LeetCode problem `search-insert-position`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SearchInsert def valuesInBounds (nums : Slice I64) : Prop := ...
9
first-missing-positive
41
Hard
[ "Array", "Hash Table" ]
Given an unsorted integer array nums. Return the smallest positive integer that is not present in nums. You must implement an algorithm that runs in O(n) time and uses O(1) auxiliary space.   Example 1: Input: nums = [1,2,0] Output: 3 Explanation: The numbers in the range [1,2] are all in the array. Example 2: Input...
firstMissingPositive(nums: list_int) -> int
pub fn first_missing_positive(nums: &[i64]) -> i64
Aegis.FirstMissingPositive.first_missing_positive
pub fn first_missing_positive(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 1; } // seen[i] is true iff (i + 1) is present in nums. let mut seen: Vec<bool> = Vec::new(); let mut i = 0usize; while i < n { seen.push(false); i += 1; } i = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [first_missing_positive]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [first_missing_positive]: function definitions module public import Aeneas public import Aegis.FirstMissingPositive.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand...
import Aegis.FirstMissingPositive.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ...
[ { "input": "[[]]", "output": "1" }, { "input": "[[1]]", "output": "2" }, { "input": "[[2]]", "output": "1" }, { "input": "[[0]]", "output": "1" }, { "input": "[[2, 2]]", "output": "1" }, { "input": "[[1000000, -1000000, 500000]]", "output": "1" }...
126
false
126
verified
10
10
2
3,743
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FirstMissingPositive.Code.Funs /-! # Specifications of `Aegis.FirstMissingPositive.first_missing_positive` LeetCode problem `first-missing-positive`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.FirstMissingPositive (first_missing_positive) na...
14
trapping-rain-water
42
Hard
[ "Stack", "Array", "Two Pointers", "Dynamic Programming", "Monotonic Stack" ]
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.   Example 1: Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] Output: 6 Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In th...
trap(height: list_int) -> int
pub fn trap(height: &[i64]) -> i64
Aegis.Trap.trap
pub fn trap(height: &[i64]) -> i64 { let n = height.len(); if n == 0 { return 0; } let mut left: usize = 0; let mut right: usize = n - 1; let mut left_max: i64 = 0; let mut right_max: i64 = 0; let mut water: i64 = 0; while left < right { if height[left] < height[rig...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [trap]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style.whi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [trap]: function definitions module public import Aeneas public import Aegis.Trap.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVar...
import Aegis.Trap.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "eval/...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[2, 0, 2]]", "output": "2" }, { "input": "[[0, 0, 0, 0]]", "output": "0" }, { "input": "[[5, 4, 1, 2]]", "output": "1" }, { "input": "[[2, 1, 0, 2]]", "output": "3" }, { "input": "[[5, 4, 3, 2, 1]]", ...
128
false
128
verified
10
10
1
1,008
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Trap.Code.Funs /-! # Specifications of `Aegis.Trap.trap` LeetCode problem `trapping-rain-water`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Trap open scoped BigOperators def hts (height : Slice Std.I64) : List ℤ := height.va...
17
wildcard-matching
44
Hard
[ "Greedy", "Recursion", "String", "Dynamic Programming" ]
Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where: '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string (not partial).   Example 1: Input: s = "aa", ...
isMatch(s: str, p: str) -> bool
pub fn is_match(s: &[u8], p: &[u8]) -> bool
Aegis.IsMatch.is_match
pub fn is_match(s: &[u8], p: &[u8]) -> bool { let n = s.len(); let m = p.len(); // dp[j] currently represents dp[i][j] (whether s[0..i] matches p[0..j]). // We roll over i, so the array is reused each row. let mut dp: Vec<bool> = Vec::new(); let mut k: usize = 0; while k <= m { dp.p...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_match]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_match]: function definitions module public import Aeneas public import Aegis.IsMatch.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.IsMatch.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[\"abcde\", \"ab*e\"]", "output": "true" }, { "input": "[\"abcde\", \"*\"]", "output": "true" }, { "input": "[\"mississippi\", \"m??*ss*?i*pi\"]", "output": "false" }, { "input": "[\"aa\", \"a\"]", "output": "false" }, { "input": "[\"abcde\", \"?bcde\"...
209
false
209
verified
10
10
2
7,345
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsMatch.Code.Funs /-! # Specifications of `Aegis.IsMatch.is_match` LeetCode problem `wildcard-matching`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsMatch def starByte : Std.U8 := 42#u8 def questionByte : Std.U8 := 63#u8 ...
7
jump-game-ii
45
Medium
[ "Greedy", "Array", "Dynamic Programming" ]
You are given a 0-indexed array of integers nums of length n. You are initially positioned at nums[0]. Each element nums[i] represents the maximum length of a forward jump from index i. In other words, if you are at nums[i], you can jump to any nums[i + j] where: 0 <= j <= nums[i] and i + j < n Return the minimum num...
jump(nums: list_int) -> int
pub fn jump(nums: &[i64]) -> i64
Aegis.Jump.jump
pub fn jump(nums: &[i64]) -> i64 { let n: usize = nums.len(); if n <= 1 { return 0; } let mut jumps: i64 = 0; let mut current_end: usize = 0; let mut farthest: usize = 0; let mut i: usize = 0; while i + 1 < n { let reach: usize = i + nums[i] as usize; if reach >...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [jump]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style.whi...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [jump]: function definitions module public import Aeneas public import Aegis.Jump.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVar...
import Aegis.Jump.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "eval/...
[ { "input": "[[0]]", "output": "0" }, { "input": "[[1, 2, 3]]", "output": "2" }, { "input": "[[1, 1, 1, 1]]", "output": "3" }, { "input": "[[2, 3, 0, 1, 4]]", "output": "2" }, { "input": "[[2, 3, 1, 1, 4]]", "output": "2" }, { "input": "[[1, 2, 3, 4, 5]...
44
false
44
verified
10
10
1
3,506
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Jump.Code.Funs /-! # Specifications of `Aegis.Jump.jump` LeetCode problem `jump-game-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Jump def vals (nums : Slice Std.I64) : List Int := nums.val.map (fun x => x.val) def elem (a : Li...
10
permutations
46
Medium
[ "Array", "Backtracking" ]
Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.   Example 1: Input: nums = [1,2,3] Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] Example 2: Input: nums = [0,1] Output: [[0,1],[1,0]] Example 3: Input: nums = [1] Output: [[1]]   Constrai...
permute(nums: list_int) -> list_list_int
pub fn permute(nums: &[i64]) -> Vec<Vec<i64>>
Aegis.Permute.permute
pub fn permute(nums: &[i64]) -> Vec<Vec<i64>> { let n = nums.len(); let mut out: Vec<Vec<i64>> = Vec::new(); if n == 0 { let mut empty_row: Vec<i64> = Vec::new(); out.push(empty_row); return out; } // perm stores a permutation of indices 0..n-1 as i64 values. let mut pe...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [permute]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [permute]: function definitions module public import Aeneas public import Aegis.Permute.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unu...
import Aegis.Permute.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[[1]]", "output": "[[1]]" }, { "input": "[[0]]", "output": "[[0]]" }, { "input": "[[0, 1]]", "output": "[[0, 1], [1, 0]]" }, { "input": "[[4, 5, 6]]", "output": "[[4, 5, 6], [4, 6, 5], [5, 4, 6], [5, 6, 4], [6, 4, 5], [6, 5, 4]]" }, { "input": "[[1, 2,...
32
true
32
verified
10
10
1
18,018
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Permute.Code.Funs /-! # Specifications of `Aegis.Permute.permute` LeetCode problem `permutations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Permute def IsPermOf (nums p : List Std.I64) : Prop := ∃ (hlen : p.length = nums.length...
15
permutations-ii
47
Medium
[ "Array", "Backtracking", "Sorting" ]
Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order.   Example 1: Input: nums = [1,1,2] Output: [[1,1,2], [1,2,1], [2,1,1]] Example 2: Input: nums = [1,2,3] Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]   Constraints: 1 <= nums.leng...
permuteUnique(nums: list_int) -> list_list_int
pub fn permute_unique(nums: &[i64]) -> Vec<Vec<i64>>
Aegis.PermuteUnique.permute_unique
pub fn permute_unique(nums: &[i64]) -> Vec<Vec<i64>> { let n = nums.len(); let mut a: Vec<i64> = Vec::new(); let mut i = 0; while i < n { a.push(nums[i]); i += 1; } // Insertion sort the copied input in nondecreasing order. i = 1; while i < n { let key = a[i]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [permute_unique]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [permute_unique]: function definitions module public import Aeneas public import Aegis.PermuteUnique.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_opti...
import Aegis.PermuteUnique.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCa...
[ { "input": "[[1]]", "output": "[[1]]" }, { "input": "[[1, 1, 1]]", "output": "[[1, 1, 1]]" }, { "input": "[[4, 4, 4]]", "output": "[[4, 4, 4]]" }, { "input": "[[1, 1, 1, 1]]", "output": "[[1, 1, 1, 1]]" }, { "input": "[[5, 5, 5, 5]]", "output": "[[5, 5, 5, 5]]...
67
true
67
verified
10
10
1
3,030
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PermuteUnique.Code.Funs /-! # Specifications of `Aegis.PermuteUnique.permute_unique` LeetCode problem `permutations-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PermuteUnique def countVal (v : Int) (l : List Std.I64) : Nat := ...
11
n-queens-ii
52
Hard
[ "Backtracking" ]
The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. Given an integer n, return the number of distinct solutions to the n-queens puzzle.   Example 1: Input: n = 4 Output: 2 Explanation: There are two distinct solutions to the 4-queens puzzle as shown...
totalNQueens(n: int) -> int
pub fn total_n_queens(n: i64) -> i64
Aegis.TotalNQueens.total_n_queens
pub fn total_n_queens(n: i64) -> i64 { if n <= 0 { return 0; } let n_usize = n as usize; let m = 2 * n_usize; let mut cols: Vec<bool> = Vec::new(); let mut d1: Vec<bool> = Vec::new(); let mut d2: Vec<bool> = Vec::new(); let mut i: usize = 0; while i < n_usize { col...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [total_n_queens]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [total_n_queens]: function definitions module public import Aeneas public import Aegis.TotalNQueens.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_optio...
import Aegis.TotalNQueens.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[8]", "output": "92" }, { "input": "[3]", "output": "0" }, { "input": "[4]", "output": "2" }, { "input": "[9]", "output": "352" }, { "input": "[6]", "output": "4" }, { "input": "[2]", "output": "0" }, { "input": "[1]", "outp...
9
false
9
verified
9
9
1
8,943
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.TotalNQueens.Code.Funs /-! # Specifications of `Aegis.TotalNQueens.total_n_queens` LeetCode problem `n-queens-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.TotalNQueens def IsPlacement (n : ℤ) (q : List ℤ) : Prop := q.len...
15
maximum-subarray
53
Medium
[ "Array", "Divide and Conquer", "Dynamic Programming" ]
Given an integer array nums, find the subarray with the largest sum, and return its sum.   Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: The subarray [4,-1,2,1] has the largest sum 6. Example 2: Input: nums = [1] Output: 1 Explanation: The subarray [1] has the largest sum 1. Example 3: In...
maxSubArray(nums: list_int) -> int
pub fn max_sub_array(nums: &[i64]) -> i64
Aegis.MaxSubArray.max_sub_array
pub fn max_sub_array(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut best: i64 = nums[0]; let mut current: i64 = nums[0]; let mut i: usize = 1; while i < n { let x = nums[i]; if current < 0 { current = x; } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sub_array]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_sub_array]: function definitions module public import Aeneas public import Aegis.MaxSubArray.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option ...
import Aegis.MaxSubArray.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[-10000, 10000]]", "output": "10000" }, { "input": "[[-2, 0, -1]]", "output": "0" }, { "input": "[[10000, -10000, 10000]]", "output": "10000" }, { "input": "[[0, 0, 0, 0]]", "output": "0" }, { "input": ...
98
false
98
verified
10
10
1
432
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxSubArray.Code.Funs /-! # Specifications of `Aegis.MaxSubArray.max_sub_array` LeetCode problem `maximum-subarray`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxSubArray def vals (nums : Slice Std.I64) : List ℤ := nums.val.map (f...
12
spiral-matrix
54
Medium
[ "Array", "Matrix", "Simulation" ]
Given an m x n matrix, return all elements of the matrix in spiral order.   Example 1: Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,2,3,6,9,8,7,4,5] Example 2: Input: matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] Output: [1,2,3,4,8,12,11,10,9,5,6,7]   Constraints: m == matrix.length n == matrix[i].length 1...
spiralOrder(matrix: list_list_int) -> list_int
pub fn spiral_order(matrix: &[Vec<i64>]) -> Vec<i64>
Aegis.SpiralOrder.spiral_order
pub fn spiral_order(matrix: &[Vec<i64>]) -> Vec<i64> { let mut out: Vec<i64> = Vec::new(); let m = matrix.len(); if m == 0 { return out; } let n = matrix[0].len(); if n == 0 { return out; } let mut top: i64 = 0; let mut bottom: i64 = m as i64 - 1; let mut left:...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [spiral_order]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [spiral_order]: function definitions module public import Aeneas public import Aegis.SpiralOrder.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.SpiralOrder.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[[1]]]", "output": "[1]" }, { "input": "[[[7]]]", "output": "[7]" }, { "input": "[[[7], [9], [3]]]", "output": "[7, 9, 3]" }, { "input": "[[[1, 2], [3, 4]]]", "output": "[1, 2, 4, 3]" }, { "input": "[[[1], [2], [3], [4], [5]]]", "output": "[1, 2, ...
53
false
53
verified
10
10
1
2,518
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SpiralOrder.Code.Funs /-! # Specifications of `Aegis.SpiralOrder.spiral_order` LeetCode problem `spiral-matrix`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SpiralOrder def rows (matrix : Slice (alloc.vec.Vec I64)) : Nat := matrix.v...
7
jump-game
55
Medium
[ "Greedy", "Array", "Dynamic Programming" ]
You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position. Return true if you can reach the last index, or false otherwise.   Example 1: Input: nums = [2,3,1,1,4] Output: true Explanation: Jump 1 step...
canJump(nums: list_int) -> bool
pub fn can_jump(nums: &[i64]) -> bool
Aegis.CanJump.can_jump
pub fn can_jump(nums: &[i64]) -> bool { let n = nums.len(); let mut result: bool = true; if n > 1 { let mut i: usize = 0; let mut max_reach: i64 = 0; let mut ok: bool = true; while i < n { let pos: i64 = i as i64; if pos > max_reach { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_jump]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_jump]: function definitions module public import Aeneas public import Aegis.CanJump.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.CanJump.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[[0]]", "output": "true" }, { "input": "[[1, 2, 3]]", "output": "true" }, { "input": "[[2, 0, 0]]", "output": "true" }, { "input": "[[0, 2, 3]]", "output": "false" }, { "input": "[[2, 5, 0, 0]]", "output": "true" }, { "input": "[[1, 0, 1, 0...
66
false
66
verified
10
10
2
3,410
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanJump.Code.Funs /-! # Specifications of `Aegis.CanJump.can_jump` LeetCode problem `jump-game`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.CanJump def elem (nums : Slice Std.I64) (i : Nat) : Int := match nums.val[i]? with ...
11
merge-intervals
56
Medium
[ "Array", "Sorting" ]
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.   Example 1: Input: intervals = [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3...
merge(intervals: list_list_int) -> list_list_int
pub fn merge(intervals: &[Vec<i64>]) -> Vec<Vec<i64>>
Aegis.Merge.merge
pub fn merge(intervals: &[Vec<i64>]) -> Vec<Vec<i64>> { let n = intervals.len(); let mut starts: Vec<i64> = Vec::new(); let mut ends: Vec<i64> = Vec::new(); let mut i = 0; while i < n { starts.push(intervals[i][0]); ends.push(intervals[i][1]); i += 1; } // Insertio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [merge]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style.wh...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [merge]: function definitions module public import Aeneas public import Aegis.Merge.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedV...
import Aegis.Merge.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "eval...
[ { "input": "[[[1, 4], [2, 3]]]", "output": "[[1, 4]]" }, { "input": "[[[1, 4], [4, 5]]]", "output": "[[1, 5]]" }, { "input": "[[[1, 10], [2, 6], [9, 12]]]", "output": "[[1, 12]]" }, { "input": "[[[1, 10], [10, 20], [20, 30]]]", "output": "[[1, 30]]" }, { "input": ...
91
false
91
verified
10
10
1
1,600
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Merge.Code.Funs import Mathlib.Basic.Real.Basic /-! # Specifications of `Aegis.Merge.merge` LeetCode problem `merge-intervals`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Merge def rowOf (v : alloc.vec.Vec Std.I64) : Option (Int × ...
14
insert-interval
57
Medium
[ "Array" ]
You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval and intervals is sorted in ascending order by starti. You are also given an interval newInterval = [start, end] that represents the start and end of another interval. Ins...
insert(intervals: list_list_int, newInterval: list_int) -> list_list_int
pub fn insert(intervals: &[Vec<i64>], newInterval: &[i64]) -> Vec<Vec<i64>>
Aegis.Insert.insert
pub fn insert(intervals: &[Vec<i64>], newInterval: &[i64]) -> Vec<Vec<i64>> { let mut out: Vec<Vec<i64>> = Vec::new(); let mut ns: i64 = newInterval[0]; let mut ne: i64 = newInterval[1]; let mut placed: bool = false; let n: usize = intervals.len(); let mut i: usize = 0; while i < n { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [insert]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style.w...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [insert]: function definitions module public import Aeneas public import Aegis.Insert.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unuse...
import Aegis.Insert.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "eva...
[ { "input": "[[], [5, 7]]", "output": "[[5, 7]]" }, { "input": "[[], [0, 0]]", "output": "[[0, 0]]" }, { "input": "[[], [1, 5]]", "output": "[[1, 5]]" }, { "input": "[[], [1, 2]]", "output": "[[1, 2]]" }, { "input": "[[[1, 5]], [2, 3]]", "output": "[[1, 5]]" ...
166
false
166
verified
10
10
1
1,945
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Insert.Code.Funs import Mathlib.Data.Real.Basic /-! # Specifications of `Aegis.Insert.insert` LeetCode problem `insert-interval`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aeneas.Std.Result namespace AegisSpec.Insert def lower (l : List I64) : ℤ...
12
length-of-last-word
58
Easy
[ "String" ]
Given a string s consisting of words and spaces, return the length of the last word in the string. A word is a maximal substring consisting of non-space characters only.   Example 1: Input: s = "Hello World" Output: 5 Explanation: The last word is "World" with length 5. Example 2: Input: s = " fly me to the mo...
lengthOfLastWord(s: str) -> int
pub fn length_of_last_word(s: &[u8]) -> i64
Aegis.LengthOfLastWord.length_of_last_word
pub fn length_of_last_word(s: &[u8]) -> i64 { let mut i = s.len(); let mut length: i64 = 0; while i > 0 { if s[i - 1] == b' ' { i -= 1; } else { break; } } while i > 0 { if s[i - 1] != b' ' { length += 1; i -= 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [length_of_last_word]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [length_of_last_word]: function definitions module public import Aeneas public import Aegis.LengthOfLastWord.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.LengthOfLastWord.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[\"Hello World\"]", "output": "5" }, { "input": "[\" fly me to the moon \"]", "output": "4" }, { "input": "[\"luffy is still joyboy\"]", "output": "6" }, { "input": "[\" a \"]", "output": "1" }, { "input": "[\"multiple spaces between ...
48
false
48
verified
10
10
1
361
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LengthOfLastWord.Code.Funs /-! # Specifications of `Aegis.LengthOfLastWord.length_of_last_word` LeetCode problem `length-of-last-word`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LengthOfLastWord def byteAt (s : Slice U8) (i : Nat)...
12
spiral-matrix-ii
59
Medium
[ "Array", "Matrix", "Simulation" ]
Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order.   Example 1: Input: n = 3 Output: [[1,2,3],[8,9,4],[7,6,5]] Example 2: Input: n = 1 Output: [[1]]   Constraints: 1 <= n <= 20
generateMatrix(n: int) -> list_list_int
pub fn generate_matrix(n: i64) -> Vec<Vec<i64>>
Aegis.GenerateMatrix.generate_matrix
pub fn generate_matrix(n: i64) -> Vec<Vec<i64>> { let n_usize = n as usize; let mut matrix: Vec<Vec<i64>> = Vec::new(); let mut i = 0; while i < n_usize { let mut row: Vec<i64> = Vec::new(); let mut j = 0; while j < n_usize { row.push(0); j += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [generate_matrix]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [generate_matrix]: function definitions module public import Aeneas public import Aegis.GenerateMatrix.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_op...
import Aegis.GenerateMatrix.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[1]", "output": "[[1]]" }, { "input": "[2]", "output": "[[1, 2], [4, 3]]" }, { "input": "[3]", "output": "[[1, 2, 3], [8, 9, 4], [7, 6, 5]]" }, { "input": "[4]", "output": "[[1, 2, 3, 4], [12, 13, 14, 5], [11, 16, 15, 6], [10, 9, 8, 7]]" }, { "input": ...
20
false
20
verified
10
10
1
3,484
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GenerateMatrix.Code.Funs /-! # Specifications of `Aegis.GenerateMatrix.generate_matrix` LeetCode problem `spiral-matrix-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GenerateMatrix def entry (M : alloc.vec.Vec (alloc.vec.Vec Std....
16
rotate-list
61
Medium
[ "Linked List", "Two Pointers" ]
Given the head of a linked list, rotate the list to the right by k places.   Example 1: Input: head = [1,2,3,4,5], k = 2 Output: [4,5,1,2,3] Example 2: Input: head = [0,1,2], k = 4 Output: [2,0,1]   Constraints: The number of nodes in the list is in the range [0, 500]. -100 <= Node.val <= 100 0 <= k <= 2 * 109
rotateRight(head: linkedlist, k: int) -> linkedlist
pub fn rotate_right(head: &List, k: i64) -> List
Aegis.RotateRight.rotate_right
fn collect_vals(l: &List, out: &mut Vec<i64>) { match l { List::Nil => {} List::Cons(v, next) => { out.push(*v); collect_vals(next, out); } } } pub fn rotate_right(head: &List, k: i64) -> List { let mut vals: Vec<i64> = Vec::new(); collect_vals(head, &mut...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rotate_right]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [rotate_right]: function definitions module public import Aeneas public import Aegis.RotateRight.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.RotateRight.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving instan...
[ { "input": "[[1], 0]", "output": "[1]" }, { "input": "[[1], 1]", "output": "[1]" }, { "input": "[[1], 100]", "output": "[1]" }, { "input": "[[0], 500]", "output": "[0]" }, { "input": "[[0], 0]", "output": "[0]" }, { "input": "[[1], 1000000000]", "o...
97
false
97
verified
10
10
2
9,117
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RotateRight.Code.Funs /-! # Specifications of `Aegis.RotateRight.rotate_right` LeetCode problem `rotate-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace Aegis.RotateRight def List.val : List → _root_.List ℤ | List.Nil => [] | List.Cons ...
11
unique-paths
62
Medium
[ "Math", "Dynamic Programming", "Combinatorics" ]
There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time. Given the two integers m and n, return the number of possible uni...
uniquePaths(m: int, n: int) -> int
pub fn unique_paths(m: i64, n: i64) -> i64
Aegis.UniquePaths.unique_paths
pub fn unique_paths(m: i64, n: i64) -> i64 { if m <= 0 || n <= 0 { return 0; } let rows: usize = m as usize; let cols: usize = n as usize; let mut dp: Vec<i64> = Vec::new(); let mut j: usize = 0; while j < cols { dp.push(1); j += 1; } let mut i: usize = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [unique_paths]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [unique_paths]: function definitions module public import Aeneas public import Aegis.UniquePaths.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.UniquePaths.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[20, 30]", "output": "11541847896480" }, { "input": "[1, 100]", "output": "1" }, { "input": "[3, 7]", "output": "28" }, { "input": "[5, 5]", "output": "70" }, { "input": "[10, 10]", "output": "48620" }, { "input": "[5, 3]", "output": "1...
32
false
32
verified
10
10
1
1,176
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.UniquePaths.Code.Funs /-! # Specifications of `Aegis.UniquePaths.unique_paths` LeetCode problem `unique-paths`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.UniquePaths def pathsCount (m n : ℤ) : ℤ := ((m + n - 2).toNat.choos...
9
unique-paths-ii
63
Medium
[ "Array", "Dynamic Programming", "Matrix" ]
You are given an m x n integer array grid. There is a robot initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time. An obstacle and space are marked as 1 or 0 respective...
uniquePathsWithObstacles(obstacleGrid: list_list_int) -> int
pub fn unique_paths_with_obstacles(obstacleGrid: &[Vec<i64>]) -> i64
Aegis.UniquePathsWithObstacles.unique_paths_with_obstacles
pub fn unique_paths_with_obstacles(obstacleGrid: &[Vec<i64>]) -> i64 { let m = obstacleGrid.len(); if m == 0 { return 0; } let n = obstacleGrid[0].len(); if n == 0 { return 0; } if obstacleGrid[0][0] == 1 { return 0; } let mut dp: Vec<i64> = Vec::new(); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [unique_paths_with_obstacles]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [unique_paths_with_obstacles]: function definitions module public import Aeneas public import Aegis.UniquePathsWithObstacles.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.ha...
import Aegis.UniquePathsWithObstacles.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #e...
[ { "input": "[[[1]]]", "output": "0" }, { "input": "[[[0]]]", "output": "1" }, { "input": "[[[1, 0], [0, 0]]]", "output": "0" }, { "input": "[[[0, 0], [0, 0]]]", "output": "2" }, { "input": "[[[0, 0], [0, 1]]]", "output": "0" }, { "input": "[[[0, 1], [0...
102
false
102
verified
10
10
1
871
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.UniquePathsWithObstacles.Code.Funs /-! # Specifications of `Aegis.UniquePathsWithObstacles.unique_paths_with_obstacles` LeetCode problem `unique-paths-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.UniquePathsWithObstacles (unique_paths_wi...
8
minimum-path-sum
64
Medium
[ "Array", "Dynamic Programming", "Matrix" ]
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. Note: You can only move either down or right at any point in time.   Example 1: Input: grid = [[1,3,1],[1,5,1],[4,2,1]] Output: 7 Explanation: Because the path 1 → 3 →...
minPathSum(grid: list_list_int) -> int
pub fn min_path_sum(grid: &[Vec<i64>]) -> i64
Aegis.MinPathSum.min_path_sum
pub fn min_path_sum(grid: &[Vec<i64>]) -> i64 { let m = grid.len(); if m == 0 { return 0; } let n = grid[0].len(); if n == 0 { return 0; } let mut dp: Vec<i64> = Vec::new(); let mut j = 0; while j < n { dp.push(0); j += 1; } dp[0] = grid[0][...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_path_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_path_sum]: function definitions module public import Aeneas public import Aegis.MinPathSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option li...
import Aegis.MinPathSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[[1]]]", "output": "1" }, { "input": "[[[7]]]", "output": "7" }, { "input": "[[[1, 2], [3, 4]]]", "output": "7" }, { "input": "[[[1], [1], [1], [1], [1]]]", "output": "5" }, { "input": "[[[1, 2, 3], [4, 5, 6]]]", "output": "12" }, { "input...
77
false
77
verified
10
10
1
697
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinPathSum.Code.Funs /-! # Specifications of `Aegis.MinPathSum.min_path_sum` LeetCode problem `minimum-path-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinPathSum open Aegis.MinPathSum def numRows (grid : Slice (alloc.vec.Vec...
13
valid-number
65
Hard
[ "String" ]
Given a string s, return whether s is a valid number. For example, all the following are valid numbers: "2", "0089", "-0.1", "+3.14", "4.", "-.9", "2e10", "-90E3", "3e+7", "+6e-1", "53.5e93", "-123.456e789", while the following are not valid numbers: "abc", "1a", "1e", "e3", "99e2.5", "--6", "-+3", "95a54e53". Formall...
isNumber(s: str) -> bool
pub fn is_number(s: &[u8]) -> bool
Aegis.IsNumber.is_number
pub fn is_number(s: &[u8]) -> bool { let n: usize = s.len(); if n == 0 { return false; } let mut i: usize = 0; if s[i] == b'+' || s[i] == b'-' { i += 1; } let mut digits: usize = 0; while i < n && s[i] >= b'0' && s[i] <= b'9' { digits += 1; i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_number]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_number]: function definitions module public import Aeneas public import Aegis.IsNumber.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.IsNumber.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[\"0089\"]", "output": "true" }, { "input": "[\"-123.456e789\"]", "output": "true" }, { "input": "[\"95a54e53\"]", "output": "false" }, { "input": "[\"e3\"]", "output": "false" }, { "input": "[\"4.\"]", "output": "true" }, { "input": "[\"2e...
306
false
306
verified
10
10
1
2,002
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsNumber.Code.Funs /-! # Specifications of `Aegis.IsNumber.is_number` LeetCode problem `valid-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsNumber def contents (s : Slice U8) : List U8 := s.list.toList def byteAt (l : List...
16
plus-one
66
Easy
[ "Array", "Math" ]
You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading 0's. Increment the large integer by one and return the resu...
plusOne(digits: list_int) -> list_int
pub fn plus_one(digits: &[i64]) -> Vec<i64>
Aegis.PlusOne.plus_one
pub fn plus_one(digits: &[i64]) -> Vec<i64> { let n = digits.len(); let mut out: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { out.push(digits[i]); i += 1; } let mut j: usize = n; let mut carry: i64 = 1; while j > 0 && carry == 1 { let idx: usize = ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [plus_one]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [plus_one]: function definitions module public import Aeneas public import Aegis.PlusOne.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.PlusOne.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[[0]]", "output": "[1]" }, { "input": "[[9]]", "output": "[1, 0]" }, { "input": "[[1, 2, 3]]", "output": "[1, 2, 4]" }, { "input": "[[1, 2, 9]]", "output": "[1, 3, 0]" }, { "input": "[[2, 9, 9]]", "output": "[3, 0, 0]" }, { "input": "[[1, 0...
77
false
77
verified
10
10
1
1,000
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PlusOne.Code.Funs /-! # Specifications of `Aegis.PlusOne.plus_one` LeetCode problem `plus-one`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PlusOne def val (l : List Std.I64) : Int := ((List.range l.length).map (fun i => l[i...
12
text-justification
68
Hard
[ "Array", "String", "Simulation" ]
Given an array of strings words and a width maxWidth, format the text such that each line has exactly maxWidth characters and is fully (left and right) justified. You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces ' ' when necessary so that each line h...
fullJustify(words: list_str, maxWidth: int) -> list_str
pub fn full_justify(words: &[Vec<u8>], maxWidth: i64) -> Vec<Vec<u8>>
Aegis.FullJustify.full_justify
pub fn full_justify(words: &[Vec<u8>], maxWidth: i64) -> Vec<Vec<u8>> { let n = words.len(); let mut result: Vec<Vec<u8>> = Vec::new(); let mut i: usize = 0; while i < n { let mut j: usize = i; let mut total_chars: i64 = 0; while j < n { let wlen = words[j].len() as...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [full_justify]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [full_justify]: function definitions module public import Aeneas public import Aegis.FullJustify.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.FullJustify.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[\"a\"], 2]", "output": "[\"a \"]" }, { "input": "[[\"OneWordHereIsVeryLongIndeedAndItWillCauseSomeIssuesWithTheAlgorithmIfNotHandledProperly\"], 50]", "output": "[\"OneWordHereIsVeryLongIndeedAndItWillCauseSomeIssuesWithTheAlgorithmIfNotHandledProperly\"]" }, { "input": "[[...
107
false
107
verified
10
10
1
4,362
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FullJustify.Code.Funs /-! # Specifications of `Aegis.FullJustify.full_justify` LeetCode problem `text-justification`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FullJustify def spaceByte : Nat := 32 def vecBytes (v : alloc.vec.Vec...
15
climbing-stairs
70
Easy
[ "Memoization", "Math", "Dynamic Programming" ]
You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?   Example 1: Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps Example 2: Input: n = 3 Output: 3 Ex...
climbStairs(n: int) -> int
pub fn climb_stairs(n: i64) -> i64
Aegis.ClimbStairs.climb_stairs
pub fn climb_stairs(n: i64) -> i64 { if n == 1 { return 1; } if n == 2 { return 2; } let mut prev: i64 = 1; let mut cur: i64 = 2; let mut i: i64 = 3; while i <= n { let next: i64 = prev + cur; prev = cur; cur = next; i = i + 1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [climb_stairs]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [climb_stairs]: function definitions module public import Aeneas public import Aegis.ClimbStairs.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.ClimbStairs.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[3]", "output": "3" }, { "input": "[45]", "output": "1836311903" }, { "input": "[4]", "output": "5" }, { "input": "[20]", "output": "10946" }, { "input": "[2]", "output": "2" }, { "input": "[1]", "output": "1" }, { "input": "[10...
16
false
16
verified
10
10
1
606
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ClimbStairs.Code.Funs /-! # Specifications of `Aegis.ClimbStairs.climb_stairs` LeetCode problem `climbing-stairs`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ClimbStairs def IsCompOf (n : Nat) (l : List Nat) : Prop := l ≠ [...
10
edit-distance
72
Medium
[ "String", "Dynamic Programming" ]
Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You have the following three operations permitted on a word: Insert a character Delete a character Replace a character   Example 1: Input: word1 = "horse", word2 = "ros" Output: 3 Explanation: horse -> ror...
minDistance(word1: str, word2: str) -> int
pub fn min_distance(word1: &[u8], word2: &[u8]) -> i64
Aegis.MinDistance.min_distance
pub fn min_distance(word1: &[u8], word2: &[u8]) -> i64 { let n = word1.len(); let m = word2.len(); let mut prev: Vec<i64> = Vec::new(); let mut j: usize = 0; while j <= m { prev.push(j as i64); j += 1; } let mut i: usize = 1; while i <= n { let mut cur: Vec<i64>...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_distance]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_distance]: function definitions module public import Aeneas public import Aegis.MinDistance.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option l...
import Aegis.MinDistance.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[\"park\", \"spake\"]", "output": "3" }, { "input": "[\"algorithm\", \"altruistic\"]", "output": "6" }, { "input": "[\"abc\", \"\"]", "output": "3" }, { "input": "[\"horse\", \"ros\"]", "output": "3" }, { "input": "[\"a\", \"b\"]", "output": "1" ...
132
false
132
verified
10
10
1
715
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinDistance.Code.Funs /-! # Specifications of `Aegis.MinDistance.min_distance` LeetCode problem `edit-distance`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinDistance def IsLowercaseByte (b : Aeneas.Std.U8) : Prop := 97 ≤ b.va...
16
combinations
77
Medium
[ "Backtracking" ]
Given two integers n and k, return all possible combinations of k numbers chosen from the range [1, n]. You may return the answer in any order.   Example 1: Input: n = 4, k = 2 Output: [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]] Explanation: There are 4 choose 2 = 6 total combinations. Note that combinations are unordered, ...
combine(n: int, k: int) -> list_list_int
pub fn combine(n: i64, k: i64) -> Vec<Vec<i64>>
Aegis.Combine.combine
pub fn combine(n: i64, k: i64) -> Vec<Vec<i64>> { let mut res: Vec<Vec<i64>> = Vec::new(); if k <= 0 || k > n { return res; } let ku: usize = k as usize; let mut cur: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < ku { cur.push((i as i64) + 1); i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [combine]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [combine]: function definitions module public import Aeneas public import Aegis.Combine.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unu...
import Aegis.Combine.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[1, 1]", "output": "[[1]]" }, { "input": "[6, 1]", "output": "[[1], [2], [3], [4], [5], [6]]" }, { "input": "[9, 9]", "output": "[[1, 2, 3, 4, 5, 6, 7, 8, 9]]" }, { "input": "[4, 2]", "output": "[[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]" }, { "i...
32
true
32
verified
10
10
1
5,177
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Combine.Code.Funs /-! # Specifications of `Aegis.Combine.combine` LeetCode problem `combinations`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Combine def entries (row : alloc.vec.Vec Std.I64) : List ℤ := row.val.map (fun x ...
13
subsets
78
Medium
[ "Bit Manipulation", "Array", "Backtracking" ]
Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order.   Example 1: Input: nums = [1,2,3] Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] Example 2: Input: nums = [0] Output: [[],[0]]   Co...
subsets(nums: list_int) -> list_list_int
pub fn subsets(nums: &[i64]) -> Vec<Vec<i64>>
Aegis.Subsets.subsets
pub fn subsets(nums: &[i64]) -> Vec<Vec<i64>> { let n = nums.len(); let mut res: Vec<Vec<i64>> = Vec::new(); res.push(Vec::new()); let mut processed: usize = 0; while processed < n { let idx: usize = n - 1 - processed; let num: i64 = nums[idx]; let current_len: usize = res.l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subsets]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subsets]: function definitions module public import Aeneas public import Aegis.Subsets.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unu...
import Aegis.Subsets.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[[10]]", "output": "[[], [10]]" }, { "input": "[[1]]", "output": "[[], [1]]" }, { "input": "[[0]]", "output": "[[], [0]]" }, { "input": "[[7]]", "output": "[[], [7]]" }, { "input": "[[-10, 10]]", "output": "[[], [10], [-10], [-10, 10]]" }, { ...
70
true
70
verified
10
10
1
9,401
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Subsets.Code.Funs /-! # Specifications of `Aegis.Subsets.subsets` LeetCode problem `subsets`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Subsets def ivec (v : alloc.vec.Vec Std.I64) : List Int := v.val.map (fun x => x.val) d...
11
remove-duplicates-from-sorted-array-ii
80
Medium
[ "Array", "Two Pointers" ]
Given an integer array nums sorted in non-decreasing order, remove some duplicates in-place such that each unique element appears at most twice. The relative order of the elements should be kept the same. Since it is impossible to change the length of the array in some languages, you must instead have the result be pla...
removeDuplicates(nums: list_int) -> int
pub fn remove_duplicates(nums: &[i64]) -> i64
Aegis.RemoveDuplicates.remove_duplicates
pub fn remove_duplicates(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut k: i64 = 0; let mut i: usize = 0; while i < n { // Find the end of the current run of equal elements. let mut j: usize = i; while j < n && nums[j] == nums[i] { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_duplicates]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [remove_duplicates]: function definitions module public import Aeneas public import Aegis.RemoveDuplicates.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false se...
import Aegis.RemoveDuplicates.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 1]]", "output": "2" }, { "input": "[[1, 1, 1]]", "output": "2" }, { "input": "[[1, 1, 2]]", "output": "3" }, { "input": "[[1, 1, 1, 1]]", "output": "2" }, { "input": "[[1, 2, 3, 4, 5]]", "output...
128
false
128
verified
10
10
1
573
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RemoveDuplicates.Code.Funs /-! # Specifications of `Aegis.RemoveDuplicates.remove_duplicates` LeetCode problem `remove-duplicates-from-sorted-array-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RemoveDuplicates def vals (nums...
15
remove-duplicates-from-sorted-list-ii
82
Medium
[ "Linked List", "Two Pointers" ]
Given the head of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Return the linked list sorted as well.   Example 1: Input: head = [1,2,3,3,4,4,5] Output: [1,2,5] Example 2: Input: head = [1,1,1,2,3] Output: [2,3]   Constraints: The numbe...
deleteDuplicates(head: linkedlist) -> linkedlist
pub fn delete_duplicates(head: &List) -> List
Aegis.DeleteDuplicates.delete_duplicates
fn collect_rev(l: &List) -> Vec<i64> { match l { List::Nil => Vec::new(), List::Cons(v, next) => { let mut rest: Vec<i64> = collect_rev(&**next); rest.push(*v); rest } } } pub fn delete_duplicates(head: &List) -> List { let vals_rev: Vec<i64> = co...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [delete_duplicates]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [delete_duplicates]: function definitions module public import Aeneas public import Aegis.DeleteDuplicates.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false se...
import Aegis.DeleteDuplicates.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving i...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[-100, 100]]", "output": "[-100, 100]" }, { "input": "[[1, 1, 1, 2, 3]]", "output": "[2, 3]" }, { "input": "[[-100, 100, -100, 100]]", "output": "[-100, 100, -100, 100]" }, { "input": "[[1, 2, 3, 4, 5]]", "ou...
69
false
69
verified
10
10
1
6,903
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DeleteDuplicates.Code.Funs /-! # Specifications of `Aegis.DeleteDuplicates.delete_duplicates` LeetCode problem `remove-duplicates-from-sorted-list-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DeleteDuplicates def vals (l : A...
14
remove-duplicates-from-sorted-list
83
Easy
[ "Linked List" ]
Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well.   Example 1: Input: head = [1,1,2] Output: [1,2] Example 2: Input: head = [1,1,2,3,3] Output: [1,2,3]   Constraints: The number of nodes in the list is in the range [0, 3...
deleteDuplicates(head: linkedlist) -> linkedlist
pub fn delete_duplicates(head: &List) -> List
Aegis.DeleteDuplicates.delete_duplicates
pub fn delete_duplicates(head: &List) -> List { match head { List::Nil => List::Nil, List::Cons(v, next) => { let rest = delete_duplicates(&**next); match rest { List::Cons(rv, tail) => { if rv == *v { List::Cons(rv,...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [delete_duplicates]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [delete_duplicates]: function definitions module public import Aeneas public import Aegis.DeleteDuplicates.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false se...
import Aegis.DeleteDuplicates.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving i...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[100, 100, 100]]", "output": "[100]" }, { "input": "[[-100, 100]]", "output": "[-100, 100]" }, { "input": "[[0, 0, 0, 0]]", "output": "[0]" }, { "input": "[[1, 1, 2]]", "output": "[1, 2]" }, { "input"...
110
false
110
verified
10
10
1
4,180
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.DeleteDuplicates.Code.Funs /-! # Specifications of `Aegis.DeleteDuplicates.delete_duplicates` LeetCode problem `remove-duplicates-from-sorted-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.DeleteDuplicates def vals : Aegis.D...
9
largest-rectangle-in-histogram
84
Hard
[ "Stack", "Array", "Monotonic Stack" ]
Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram.   Example 1: Input: heights = [2,1,5,6,2,3] Output: 10 Explanation: The above is a histogram where width of each bar is 1. The largest rectangle is sh...
largestRectangleArea(heights: list_int) -> int
pub fn largest_rectangle_area(heights: &[i64]) -> i64
Aegis.LargestRectangleArea.largest_rectangle_area
pub fn largest_rectangle_area(heights: &[i64]) -> i64 { let n = heights.len(); let mut best: i64 = 0; let mut stack: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { let cur = heights[i]; while stack.len() > 0 { let top_i64 = stack[stack.len() - 1]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_rectangle_area]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_optio...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_rectangle_area]: function definitions module public import Aeneas public import Aegis.LargestRectangleArea.Code.Types public import Aegis.LargestRectangleArea.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_opt...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [largest_rectangle_area]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.LargestRectangleArea.Code.Types @[expose] public section open Aeneas Aeneas.Std Result Cont...
import Aegis.LargestRectangleArea.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[0]]", "output": "0" }, { "input": "[[3]]", "output": "3" }, { "input": "[[2, 4]]", "output": "4" }, { "input": "[[2, 1, 2]]", "output": "3" }, { "input": "[[10000, 10000, 10000, 10000]]", "output":...
96
false
96
verified
10
10
1
3,298
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LargestRectangleArea.Code.Funs /-! # Specifications of `Aegis.LargestRectangleArea.largest_rectangle_area` LeetCode problem `largest-rectangle-in-histogram`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LargestRectangleArea set_option autoImpl...
13
partition-list
86
Medium
[ "Linked List", "Two Pointers" ]
Given the head of a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of the nodes in each of the two partitions.   Example 1: Input: head = [1,4,3,2,5,2], x = 3 Output: [1,2,2,4,3,5] Example 2: Input...
partition(head: linkedlist, x: int) -> linkedlist
pub fn partition(head: &List, x: i64) -> List
Aegis.Partition.partition
// Recursively walk the linked list (allowed: recursion on the enum) and // push values into a Vec. No loop here, and the recursive call is not // inside any loop. fn collect(l: &List, out: &mut Vec<i64>) { match l { List::Nil => {} List::Cons(v, next) => { out.push(*v); coll...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [partition]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [partition]: function definitions module public import Aeneas public import Aegis.Partition.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter...
import Aegis.Partition.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving instance...
[ { "input": "[[2, 1], 2]", "output": "[1, 2]" }, { "input": "[[-100, 100, 0], 0]", "output": "[-100, 100, 0]" }, { "input": "[[5, 4, 3, 2, 1], 3]", "output": "[2, 1, 5, 4, 3]" }, { "input": "[[100, -100, 50, 0, -50], 0]", "output": "[-100, -50, 100, 50, 0]" }, { "i...
100
false
100
verified
10
10
2
8,227
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Partition.Code.Funs /-! # Specifications of `Aegis.Partition.partition` LeetCode problem `partition-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Partition def nodes : Aegis.Partition.List → List Std.I64 | .Nil => [] | .Con...
11
gray-code
89
Medium
[ "Bit Manipulation", "Math", "Backtracking" ]
An n-bit gray code sequence is a sequence of 2n integers where: Every integer is in the inclusive range [0, 2n - 1], The first integer is 0, An integer appears no more than once in the sequence, The binary representation of every pair of adjacent integers differs by exactly one bit, and The binary representation of th...
grayCode(n: int) -> list_int
pub fn gray_code(n: i64) -> Vec<i64>
Aegis.GrayCode.gray_code
pub fn gray_code(n: i64) -> Vec<i64> { let mut total: i64 = 1; let mut k: i64 = 0; while k < n { total = total * 2; k = k + 1; } let mut out: Vec<i64> = Vec::new(); let mut i: i64 = 0; while i < total { let value: i64 = i ^ (i >> 1); out.push(value); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [gray_code]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [gray_code]: function definitions module public import Aeneas public import Aegis.GrayCode.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.GrayCode.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[1]", "output": "[0, 1]" }, { "input": "[2]", "output": "[0, 1, 3, 2]" }, { "input": "[3]", "output": "[0, 1, 3, 2, 6, 7, 5, 4]" }, { "input": "[4]", "output": "[0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8]" }, { "input": "[5]", "output": ...
9
false
9
verified
9
9
1
1,035
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GrayCode.Code.Funs /-! # Specifications of `Aegis.GrayCode.gray_code` LeetCode problem `gray-code`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GrayCode def contents (v : alloc.vec.Vec Std.I64) : List ℤ := v.val.map (fun x => x....
13
subsets-ii
90
Medium
[ "Bit Manipulation", "Array", "Backtracking" ]
Given an integer array nums that may contain duplicates, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order.   Example 1: Input: nums = [1,2,2] Output: [[],[1],[1,2],[1,2,2],[2],[2,2]] Example 2: Input: nums = [0] Output: [[],[0]]   Constr...
subsetsWithDup(nums: list_int) -> list_list_int
pub fn subsets_with_dup(nums: &[i64]) -> Vec<Vec<i64>>
Aegis.SubsetsWithDup.subsets_with_dup
pub fn subsets_with_dup(nums: &[i64]) -> Vec<Vec<i64>> { let n = nums.len(); let mut a: Vec<i64> = Vec::new(); let mut i0 = 0; while i0 < n { a.push(nums[i0]); i0 += 1; } // Insertion sort. let mut i = 1; while i < a.len() { let key = a[i]; let mut j = i...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subsets_with_dup]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lint...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [subsets_with_dup]: function definitions module public import Aeneas public import Aegis.SubsetsWithDup.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_o...
import Aegis.SubsetsWithDup.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisC...
[ { "input": "[[0]]", "output": "[[0], []]" }, { "input": "[[5]]", "output": "[[5], []]" }, { "input": "[[10, 10, 10]]", "output": "[[10, 10, 10], [10, 10], [10], []]" }, { "input": "[[2, 1, 2]]", "output": "[[1, 2, 2], [1, 2], [1], [2, 2], [2], []]" }, { "input": "...
93
true
93
verified
10
10
1
9,095
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SubsetsWithDup.Code.Funs /-! # Specifications of `Aegis.SubsetsWithDup.subsets_with_dup` LeetCode problem `subsets-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SubsetsWithDup open Classical def cnt (a : List Std.I64) (x : ℤ) : ...
15
decode-ways
91
Medium
[ "String", "Dynamic Programming" ]
You have intercepted a secret message encoded as a string of numbers. The message is decoded via the following mapping: "1" -> 'A' "2" -> 'B' ... "25" -> 'Y' "26" -> 'Z' However, while decoding the message, you realize that there are many different ways you can decode the message because some codes are contained in oth...
numDecodings(s: str) -> int
pub fn num_decodings(s: &[u8]) -> i64
Aegis.NumDecodings.num_decodings
pub fn num_decodings(s: &[u8]) -> i64 { let n = s.len(); if n == 0 { return 0; } let mut dp: Vec<i64> = Vec::new(); let mut k: usize = 0; while k <= n { dp.push(0); k += 1; } dp[0] = 1; let mut i: usize = 1; while i <= n { let cur = s[i - 1]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_decodings]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_decodings]: function definitions module public import Aeneas public import Aegis.NumDecodings.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.NumDecodings.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[\"100100100\"]", "output": "0" }, { "input": "[\"101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010\"]", "output": "1" }, { "input": "[\"1111001111001111001111001111001111001111001111001111001111\"]", "output": "0" }, { ...
176
false
176
verified
10
10
1
1,400
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumDecodings.Code.Funs /-! # Specifications of `Aegis.NumDecodings.num_decodings` LeetCode problem `decode-ways`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.NumDecodings (num_decodings) namespace AegisSpec.NumDecodings def lvals (l : ...
11
reverse-linked-list-ii
92
Medium
[ "Linked List" ]
Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to position right, and return the reversed list.   Example 1: Input: head = [1,2,3,4,5], left = 2, right = 4 Output: [1,4,3,2,5] Example 2: Input: head = [5], left = 1, right ...
reverseBetween(head: linkedlist, left: int, right: int) -> linkedlist
pub fn reverse_between(head: &List, left: i64, right: i64) -> List
Aegis.ReverseBetween.reverse_between
fn collect_values(l: &List, acc: Vec<i64>) -> Vec<i64> { match l { List::Nil => acc, List::Cons(v, next) => { let mut new_acc = acc; new_acc.push(*v); collect_values(next, new_acc) } } } pub fn reverse_between(head: &List, left: i64, right: i64) -> Li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reverse_between]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linte...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [reverse_between]: function definitions module public import Aeneas public import Aegis.ReverseBetween.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_op...
import Aegis.ReverseBetween.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving ins...
[ { "input": "[[5], 1, 1]", "output": "[5]" }, { "input": "[[1, 2, 3], 1, 3]", "output": "[3, 2, 1]" }, { "input": "[[1, 2, 3, 4, 5], 3, 4]", "output": "[1, 2, 4, 3, 5]" }, { "input": "[[1, 2, 3, 4, 5], 2, 4]", "output": "[1, 4, 3, 2, 5]" }, { "input": "[[1, 2, 3, 4...
99
false
99
verified
10
10
1
9,172
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ReverseBetween.Code.Funs /-! # Specifications of `Aegis.ReverseBetween.reverse_between` LeetCode problem `reverse-linked-list-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ReverseBetween def vals : Aegis.ReverseBetween.List →...
3
restore-ip-addresses
93
Medium
[ "String", "Backtracking" ]
A valid IP address consists of exactly four integers separated by single dots. Each integer is between 0 and 255 (inclusive) and cannot have leading zeros. For example, "0.1.2.201" and "192.168.1.1" are valid IP addresses, but "0.011.255.245", "192.168.1.312" and "192.168@1.1" are invalid IP addresses. Given a string...
restoreIpAddresses(s: str) -> list_str
pub fn restore_ip_addresses(s: &[u8]) -> Vec<Vec<u8>>
Aegis.RestoreIpAddresses.restore_ip_addresses
// The grading harness compares the result against `vec![]` for cases whose // expected output is empty. For `Vec<Vec<u8>>` that comparison is ambiguous // (the element `Vec<u8>` implements `PartialEq` against several types), which // makes `vec![]` impossible to infer. Shadowing `vec!` with a version whose // empty fo...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [restore_ip_addresses]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [restore_ip_addresses]: function definitions module public import Aeneas public import Aegis.RestoreIpAddresses.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.RestoreIpAddresses.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.RestoreIpAddresses.restore_ip_addresses (Slice.from [57#u8, 56#u8, 55#u8, 54#u8, 53#u8, 52#u8, 51#u8, 50#u8, 49#u8, 48#u8] (by scalar_tac) : S...
[ { "input": "[\"9876543210\"]", "output": "[]" }, { "input": "[\"00000000000000000000\"]", "output": "[]" }, { "input": "[\"256256256256\"]", "output": "[]" }, { "input": "[\"99999999999999999999\"]", "output": "[]" }, { "input": "[\"11111111111111111111\"]", "...
143
true
143
verified
10
10
2
47,705
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.RestoreIpAddresses.Code.Funs /-! # Specifications of `Aegis.RestoreIpAddresses.restore_ip_addresses` LeetCode problem `restore-ip-addresses`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.RestoreIpAddresses set_option autoImplicit...
12
binary-tree-inorder-traversal
94
Easy
[ "Stack", "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the inorder traversal of its nodes' values.   Example 1: Input: root = [1,null,2,3] Output: [1,3,2] Explanation: Example 2: Input: root = [1,2,3,4,5,null,8,null,null,6,7,9] Output: [4,2,6,5,7,1,3,9,8] Explanation: Example 3: Input: root = [] Output: [] Example 4: Input: ...
inorderTraversal(root: tree) -> list_int
pub fn inorder_traversal(root: &Tree) -> Vec<i64>
Aegis.InorderTraversal.inorder_traversal
fn inorder(node: &Tree) -> Vec<i64> { match node { Tree::Null => Vec::new(), Tree::Node(value, left, right) => { let mut out = inorder(left); out.push(*value); let right_values = inorder(right); let mut i: usize = 0; while i < right_values...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [inorder_traversal]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [inorder_traversal]: function definitions module public import Aeneas public import Aegis.InorderTraversal.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false se...
import Aegis.InorderTraversal.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegi...
[ { "input": "[[]]", "output": "[]" }, { "input": "[[1]]", "output": "[1]" }, { "input": "[[3, 1, 2]]", "output": "[1, 3, 2]" }, { "input": "[[2, 1, 3, 4, 5]]", "output": "[4, 1, 5, 2, 3]" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "[4, 2, 5, 1, 6, 3, 7]...
24
false
24
verified
10
10
1
1,348
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.InorderTraversal.Code.Funs /-! # Specifications of `Aegis.InorderTraversal.inorder_traversal` LeetCode problem `binary-tree-inorder-traversal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.InorderTraversal namespace AegisSpec.InorderTraversal ...
10
unique-binary-search-trees
96
Medium
[ "Tree", "Binary Search Tree", "Math", "Dynamic Programming", "Binary Tree" ]
Given an integer n, return the number of structurally unique BST's (binary search trees) which has exactly n nodes of unique values from 1 to n.   Example 1: Input: n = 3 Output: 5 Example 2: Input: n = 1 Output: 1   Constraints: 1 <= n <= 19
numTrees(n: int) -> int
pub fn num_trees(n: i64) -> i64
Aegis.NumTrees.num_trees
pub fn num_trees(n: i64) -> i64 { if n <= 0 { return 1; } let m: usize = n as usize; let mut dp: Vec<i64> = Vec::new(); let mut idx: usize = 0; while idx <= m { dp.push(0); idx += 1; } dp[0] = 1; let mut len: usize = 1; while len <= m { let mut...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_trees]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [num_trees]: function definitions module public import Aeneas public import Aegis.NumTrees.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.NumTrees.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[3]", "output": "5" }, { "input": "[4]", "output": "14" }, { "input": "[19]", "output": "1767263190" }, { "input": "[1]", "output": "1" }, { "input": "[10]", "output": "16796" }, { "input": "[5]", "output": "42" }, { "input": "[...
14
false
14
verified
10
10
1
2,334
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.NumTrees.Code.Funs /-! # Specifications of `Aegis.NumTrees.num_trees` LeetCode problem `unique-binary-search-trees`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.NumTrees def shapeTable : Nat → List Nat | 0 => [] | k + 1 => l...
10
interleaving-string
97
Medium
[ "String", "Dynamic Programming" ]
Given strings s1, s2, and s3, find whether s3 is formed by an interleaving of s1 and s2. An interleaving of two strings s and t is a configuration where s and t are divided into n and m substrings respectively, such that: s = s1 + s2 + ... + sn t = t1 + t2 + ... + tm |n - m| <= 1 The interleaving is s1 + t1 + s2 + t2 ...
isInterleave(s1: str, s2: str, s3: str) -> bool
pub fn is_interleave(s1: &[u8], s2: &[u8], s3: &[u8]) -> bool
Aegis.IsInterleave.is_interleave
pub fn is_interleave(s1: &[u8], s2: &[u8], s3: &[u8]) -> bool { let m = s1.len(); let n = s2.len(); if m + n != s3.len() { return false; } let mut dp: Vec<bool> = Vec::new(); let mut j: usize = 0; while j <= n { dp.push(false); j += 1; } dp[0] = true; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_interleave]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_interleave]: function definitions module public import Aeneas public import Aegis.IsInterleave.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.IsInterleave.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[\"abc\", \"abc\", \"aabbcc\"]", "output": "true" }, { "input": "[\"\", \"a\", \"a\"]", "output": "true" }, { "input": "[\"\", \"b\", \"b\"]", "output": "true" }, { "input": "[\"a\", \"\", \"a\"]", "output": "true" }, { "input": "[\"abc\", \"\", \"abc\...
132
false
132
verified
10
10
1
2,386
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsInterleave.Code.Funs /-! # Specifications of `Aegis.IsInterleave.is_interleave` LeetCode problem `interleaving-string`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsInterleave def listNOfList : (l : List α) → Aeneas.Data.List...
14
validate-binary-search-tree
98
Medium
[ "Tree", "Depth-First Search", "Binary Search Tree", "Binary Tree" ]
Given the root of a binary tree, determine if it is a valid binary search tree (BST). A valid BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than the node's key. Both the left and right subt...
isValidBST(root: tree) -> bool
pub fn is_valid_bst(root: &Tree) -> bool
Aegis.IsValidBst.is_valid_bst
const NEG_INF: i64 = -2147483649; const POS_INF: i64 = 2147483648; fn is_valid_bst_helper(t: &Tree, lo: i64, hi: i64) -> bool { match t { Tree::Null => true, Tree::Node(v, left, right) => { let value = *v; if value <= lo { return false; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_valid_bst]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_valid_bst]: function definitions module public import Aeneas public import Aegis.IsValidBst.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option li...
import Aegis.IsValidBst.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[2147483647]]", "output": "true" }, { "input": "[[1]]", "output": "true" }, { "input": "[[0, -1]]", "output": "true" }, { "input": "[[1, 2]]", "output": "false" }, { "input": "[[2147483646, 2147483647]]", "output": "false" }, { "input": "[...
26
false
26
verified
10
10
1
2,066
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsValidBst.Code.Funs /-! # Specifications of `Aegis.IsValidBst.is_valid_bst` LeetCode problem `validate-binary-search-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsValidBst open Aegis.IsValidBst open Aeneas.Std.Result (ok) d...
12
same-tree
100
Easy
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given the roots of two binary trees p and q, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical, and the nodes have the same value.   Example 1: Input: p = [1,2,3], q = [1,2,3] Output: true Example 2: Input: p = [1,2], q = [1,null,2] O...
isSameTree(p: tree, q: tree) -> bool
pub fn is_same_tree(p: &Tree, q: &Tree) -> bool
Aegis.IsSameTree.is_same_tree
pub fn is_same_tree(p: &Tree, q: &Tree) -> bool { match (p, q) { (Tree::Null, Tree::Null) => true, (Tree::Node(v1, l1, r1), Tree::Node(v2, l2, r2)) => { if *v1 != *v2 { false } else { is_same_tree(&**l1, &**l2) && is_same_tree(&**r1, &**r2) ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_same_tree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_same_tree]: function definitions module public import Aeneas public import Aegis.IsSameTree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option li...
import Aegis.IsSameTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[], []]", "output": "true" }, { "input": "[[1], [1]]", "output": "true" }, { "input": "[[1], [2]]", "output": "false" }, { "input": "[[1, 2, 3], [1, 2, 3]]", "output": "true" }, { "input": "[[1, 2, 1], [1, 1, 2]]", "output": "false" }, { "...
17
false
17
verified
10
10
1
1,239
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsSameTree.Code.Funs /-! # Specifications of `Aegis.IsSameTree.is_same_tree` LeetCode problem `same-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsSameTree open Aegis.IsSameTree def nodes : Tree → Nat | .Null => 0 | .Node...
15
symmetric-tree
101
Easy
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).   Example 1: Input: root = [1,2,2,3,4,4,3] Output: true Example 2: Input: root = [1,2,2,null,3,null,3] Output: false   Constraints: The number of nodes in the tree is in the range [1, 1000]. -100 <= Node....
isSymmetric(root: tree) -> bool
pub fn is_symmetric(root: &Tree) -> bool
Aegis.IsSymmetric.is_symmetric
fn is_mirror(a: &Tree, b: &Tree) -> bool { match a { Tree::Null => { match b { Tree::Null => true, Tree::Node(_, _, _) => false, } } Tree::Node(av, al, ar) => { match b { Tree::Null => false, ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_symmetric]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_symmetric]: function definitions module public import Aeneas public import Aegis.IsSymmetric.Code.Types public import Aegis.IsSymmetric.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace fals...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_symmetric]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.IsSymmetric.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_o...
import Aegis.IsSymmetric.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase...
[ { "input": "[[1]]", "output": "true" }, { "input": "[[1, 2]]", "output": "false" }, { "input": "[[1, 2, 3]]", "output": "false" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "false" }, { "input": "[[1, 2, 2, 3, 4, 4, 3]]", "output": "true" }, { "i...
17
false
17
verified
10
10
2
3,389
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsSymmetric.Code.Funs /-! # Specifications of `Aegis.IsSymmetric.is_symmetric` LeetCode problem `symmetric-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsSymmetric open Aegis.IsSymmetric (Tree) def size : Tree → Nat ...
15
binary-tree-level-order-traversal
102
Medium
[ "Tree", "Breadth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level).   Example 1: Input: root = [3,9,20,null,null,15,7] Output: [[3],[9,20],[15,7]] Example 2: Input: root = [1] Output: [[1]] Example 3: Input: root = [] Output: []   Constraints: The ...
levelOrder(root: tree) -> list_list_int
pub fn level_order(root: &Tree) -> Vec<Vec<i64>>
Aegis.LevelOrder.level_order
pub fn level_order(root: &Tree) -> Vec<Vec<i64>> { collect_levels(root) } // Returns the level-order traversal of the subtree rooted at `node`. // Each element of the result is one level, left-to-right. fn collect_levels(node: &Tree) -> Vec<Vec<i64>> { match node { Tree::Null => { let empty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [level_order]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [level_order]: function definitions module public import Aeneas public import Aegis.LevelOrder.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.LevelOrder.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.LevelOrder.level_order ((.Null) : Aegis.LevelOrder.Tree)) ((alloc.vec.Vec.from [] (by scalar_tac) : alloc.vec.Vec (alloc.vec.Vec Std.I64))))}") #eval ...
[ { "input": "[[]]", "output": "[]" }, { "input": "[[1]]", "output": "[[1]]" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "[[1], [2, 3], [4, 5, 6, 7]]" }, { "input": "[[1, 2, 2, 3, 4, 4, 3]]", "output": "[[1], [2, 2], [3, 4, 4, 3]]" }, { "input": "[[3, 9, 20, ...
11
false
11
verified
10
10
3
85,623
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LevelOrder.Code.Funs /-! # Specifications of `Aegis.LevelOrder.level_order` LeetCode problem `binary-tree-level-order-traversal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LevelOrder namespace AegisSpec.LevelOrder abbrev Levels := al...
12
binary-tree-zigzag-level-order-traversal
103
Medium
[ "Tree", "Breadth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level and alternate between).   Example 1: Input: root = [3,9,20,null,null,15,7] Output: [[3],[20,9],[15,7]] Example 2: Input: root = [1] Output: [[1]] Example 3...
zigzagLevelOrder(root: tree) -> list_list_int
pub fn zigzag_level_order(root: &Tree) -> Vec<Vec<i64>>
Aegis.ZigzagLevelOrder.zigzag_level_order
// Some harnesses emit `assert_eq!(zigzag_level_order(...), vec![])` for the // empty-tree case. In plain Rust the element type of that bare `vec![]` // cannot be inferred when the left side is `Vec<Vec<i64>>` (E0282), because // `Vec<i64>` implements `PartialEq` against `Vec<i64>`, `&[i64]`, `[i64; N]`, // ... . This ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [zigzag_level_order]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [zigzag_level_order]: function definitions module public import Aeneas public import Aegis.ZigzagLevelOrder.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false s...
import Aegis.ZigzagLevelOrder.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.ZigzagLevelOrder.zigzag_level_order ((.Null) : Aegis.ZigzagLevelOrder.Tree)) ((alloc.vec.Vec.from [] (by scalar_tac) : alloc.vec.Vec (alloc.vec....
[ { "input": "[[]]", "output": "[]" }, { "input": "[[1]]", "output": "[[1]]" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "[[1], [3, 2], [4, 5, 6, 7]]" }, { "input": "[[1, 2, 2, 3, 4, 4, 3]]", "output": "[[1], [2, 2], [3, 4, 4, 3]]" }, { "input": "[[10, 9, 8, ...
12
false
12
verified
10
10
2
64,533
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.ZigzagLevelOrder.Code.Funs /-! # Specifications of `Aegis.ZigzagLevelOrder.zigzag_level_order` LeetCode problem `binary-tree-zigzag-level-order-traversal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.ZigzagLevelOrder open Aegis....
11
maximum-depth-of-binary-tree
104
Easy
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.   Example 1: Input: root = [3,9,20,null,null,15,7] Output: 3 Example 2: Input: root = [1,null,2] Output: 2   Constraints: The nu...
maxDepth(root: tree) -> int
pub fn max_depth(root: &Tree) -> i64
Aegis.MaxDepth.max_depth
pub fn max_depth(root: &Tree) -> i64 { match root { Tree::Null => { return 0; } Tree::Node(_, left, right) => { let dl = max_depth(&**left); let dr = max_depth(&**right); if dl > dr { return dl + 1; } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_depth]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_depth]: function definitions module public import Aeneas public import Aegis.MaxDepth.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.MaxDepth.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[]]", "output": "0" }, { "input": "[[0]]", "output": "1" }, { "input": "[[1]]", "output": "1" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "3" }, { "input": "[[0, -1, -2, -3, -4, -5, -6]]", "output": "3" }, { "input": "[[1, 2, 2, 3, ...
15
false
15
verified
10
10
4
7,610
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxDepth.Code.Funs /-! # Specifications of `Aegis.MaxDepth.max_depth` LeetCode problem `maximum-depth-of-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxDepth open Aegis.MaxDepth def nodes : Tree → Nat | Tree...
11
construct-binary-tree-from-preorder-and-inorder-traversal
105
Medium
[ "Tree", "Array", "Hash Table", "Divide and Conquer", "Binary Tree" ]
Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the same tree, construct and return the binary tree.   Example 1: Input: preorder = [3,9,20,15,7], inorder = [9,3,15,20,7] Output: [3,9,20,null,null,15,7] Example 2: Input:...
buildTree(preorder: list_int, inorder: list_int) -> tree
pub fn build_tree(preorder: &[i64], inorder: &[i64]) -> Tree
Aegis.BuildTree.build_tree
pub fn build_tree(preorder: &[i64], inorder: &[i64]) -> Tree { let n = preorder.len(); build_range(preorder, inorder, 0, n, 0, n, n) } fn build_range( preorder: &[i64], inorder: &[i64], pre_l: usize, pre_r: usize, in_l: usize, in_r: usize, fuel: usize, ) -> Tree { if fuel == 0 {...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [build_tree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [build_tree]: function definitions module public import Aeneas public import Aegis.BuildTree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.BuildTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving instance...
[ { "input": "[[-1], [-1]]", "output": "[-1]" }, { "input": "[[1, 2], [2, 1]]", "output": "[1, 2]" }, { "input": "[[1, 2, 3], [2, 1, 3]]", "output": "[1, 2, 3]" }, { "input": "[[3, 9, 20, 15, 7], [9, 3, 15, 20, 7]]", "output": "[3, 9, 20, null, null, 15, 7]" }, { "i...
61
false
61
verified
10
10
1
7,217
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BuildTree.Code.Funs /-! # Specifications of `Aegis.BuildTree.build_tree` LeetCode problem `construct-binary-tree-from-preorder-and-inorder-traversal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.BuildTree namespace AegisSpec.BuildTree def pr...
10
construct-binary-tree-from-inorder-and-postorder-traversal
106
Medium
[ "Tree", "Array", "Hash Table", "Divide and Conquer", "Binary Tree" ]
Given two integer arrays inorder and postorder where inorder is the inorder traversal of a binary tree and postorder is the postorder traversal of the same tree, construct and return the binary tree.   Example 1: Input: inorder = [9,3,15,20,7], postorder = [9,15,7,20,3] Output: [3,9,20,null,null,15,7] Example 2: In...
buildTree(inorder: list_int, postorder: list_int) -> tree
pub fn build_tree(inorder: &[i64], postorder: &[i64]) -> Tree
Aegis.BuildTree.build_tree
pub fn build_tree(inorder: &[i64], postorder: &[i64]) -> Tree { let n = inorder.len(); if n == 0 { return Tree::Null; } // pos[v + 3000] = index of value v in inorder. let mut pos: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < 6001 { pos.push(-1); i += 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [build_tree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [build_tree]: function definitions module public import Aeneas public import Aegis.BuildTree.Code.Types public import Aegis.BuildTree.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [build_tree]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.BuildTree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_optio...
import Aegis.BuildTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving instance...
[ { "input": "[[-1], [-1]]", "output": "[-1]" }, { "input": "[[1, 2], [2, 1]]", "output": "[1, null, 2]" }, { "input": "[[3, 2, 1], [3, 2, 1]]", "output": "[1, 2, null, 3]" }, { "input": "[[1, 2, 3, 4], [1, 2, 4, 3]]", "output": "[3, 2, 4, 1]" }, { "input": "[[1, 2,...
42
false
42
verified_partial
10
3
1
13,160
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.BuildTree.Code.Funs /-! # Specifications of `Aegis.BuildTree.build_tree` LeetCode problem `construct-binary-tree-from-inorder-and-postorder-traversal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.BuildTree open Aeneas Aeneas.Std Aen...
13
convert-sorted-array-to-binary-search-tree
108
Easy
[ "Tree", "Binary Search Tree", "Array", "Divide and Conquer", "Binary Tree" ]
Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree.   Example 1: Input: nums = [-10,-3,0,5,9] Output: [0,-3,9,-10,null,5] Explanation: [0,-10,5,null,-3,null,9] is also accepted: Example 2: Input: nums = [1,3] Output: [3,1] Explanation: ...
sortedArrayToBST(nums: list_int) -> tree
pub fn sorted_array_to_bst(nums: &[i64]) -> Tree
Aegis.SortedArrayToBst.sorted_array_to_bst
fn build_bst(nums: &[i64], lo: usize, hi: usize) -> Tree { if lo >= hi { return Tree::Null; } let mid = (lo + hi - 1) / 2; let left = build_bst(nums, lo, mid); let right = build_bst(nums, mid + 1, hi); Tree::Node(nums[mid], Box::new(left), Box::new(right)) } pub fn sorted_array_to_bst...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sorted_array_to_bst]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sorted_array_to_bst]: function definitions module public import Aeneas public import Aegis.SortedArrayToBst.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.SortedArrayToBst.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving i...
[ { "input": "[[0]]", "output": "[0]" }, { "input": "[[1, 3]]", "output": "[1, null, 3]" }, { "input": "[[-1, 0, 1]]", "output": "[0, -1, 1]" }, { "input": "[[-1, 0, 1, 2]]", "output": "[0, -1, 1, null, null, null, 2]" }, { "input": "[[-10, -3, 0, 5, 9]]", "outp...
69
false
69
verified
10
10
2
2,870
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SortedArrayToBst.Code.Funs /-! # Specifications of `Aegis.SortedArrayToBst.sorted_array_to_bst` LeetCode problem `convert-sorted-array-to-binary-search-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SortedArrayToBst open Aeg...
10
convert-sorted-list-to-binary-search-tree
109
Medium
[ "Tree", "Binary Search Tree", "Linked List", "Divide and Conquer", "Binary Tree" ]
Given the head of a singly linked list where elements are sorted in ascending order, convert it to a height-balanced binary search tree.   Example 1: Input: head = [-10,-3,0,5,9] Output: [0,-3,9,-10,null,5] Explanation: One possible answer is [0,-3,9,-10,null,5], which represents the shown height balanced BST. Examp...
sortedListToBST(head: linkedlist) -> tree
pub fn sorted_list_to_bst(head: &List) -> Tree
Aegis.SortedListToBst.sorted_list_to_bst
pub fn sorted_list_to_bst(head: &List) -> Tree { let mut values: Vec<i64> = Vec::new(); let mut cur = head; loop { match cur { List::Nil => break, List::Cons(v, next) => { values.push(*v); cur = &**next; } } } let ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sorted_list_to_bst]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sorted_list_to_bst]: function definitions module public import Aeneas public import Aegis.SortedListToBst.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false se...
import Aegis.SortedListToBst.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving in...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[100000]]", "output": "[100000]" }, { "input": "[[0]]", "output": "[0]" }, { "input": "[[-100000]]", "output": "[-100000]" }, { "input": "[[1, 3]]", "output": "[1, null, 3]" }, { "input": "[[-1, 0, 1,...
72
false
72
verified
10
10
1
10,681
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SortedListToBst.Code.Funs /-! # Specifications of `Aegis.SortedListToBst.sorted_list_to_bst` LeetCode problem `convert-sorted-list-to-binary-search-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SortedListToBst def listLen :...
5
balanced-binary-tree
110
Easy
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given a binary tree, determine if it is height-balanced.   Example 1: Input: root = [3,9,20,null,null,15,7] Output: true Example 2: Input: root = [1,2,2,3,3,null,null,4,4] Output: false Example 3: Input: root = [] Output: true   Constraints: The number of nodes in the tree is in the range [0, 5000]. -104 <= No...
isBalanced(root: tree) -> bool
pub fn is_balanced(root: &Tree) -> bool
Aegis.IsBalanced.is_balanced
fn imax(a: i64, b: i64) -> i64 { let mut r: i64 = a; if b > a { r = b; } r } fn iabs(a: i64) -> i64 { let mut r: i64 = a; if a < 0 { r = 0 - a; } r } fn combine(lh: i64, rh: i64) -> i64 { if lh < 0 { return -1; } if rh < 0 { return -1; } ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_balanced]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_balanced]: function definitions module public import Aeneas public import Aegis.IsBalanced.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.IsBalanced.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[]]", "output": "true" }, { "input": "[[1]]", "output": "true" }, { "input": "[[1, 2, 2, 3, 4, 4, 3]]", "output": "true" }, { "input": "[[1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9]]", "output": "true" }, { "input": "[[1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5...
15
false
15
verified
10
10
3
14,406
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsBalanced.Code.Funs /-! # Specifications of `Aegis.IsBalanced.is_balanced` LeetCode problem `balanced-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsBalanced open Aegis.IsBalanced (Tree) def size : Tree → Nat | Tree...
5
minimum-depth-of-binary-tree
111
Easy
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A leaf is a node with no children.   Example 1: Input: root = [3,9,20,null,null,15,7] Output: 2 Example 2: Input: root = [2,null,3,null,4,null,5,null,...
minDepth(root: tree) -> int
pub fn min_depth(root: &Tree) -> i64
Aegis.MinDepth.min_depth
fn min_depth_helper(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(_, l, r) => { let left = &**l; let right = &**r; match (left, right) { (Tree::Null, Tree::Null) => 1, (Tree::Null, _) => 1 + min_depth_helper(right), ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_depth]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_depth]: function definitions module public import Aeneas public import Aegis.MinDepth.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.MinDepth.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[]]", "output": "0" }, { "input": "[[0]]", "output": "1" }, { "input": "[[1]]", "output": "1" }, { "input": "[[42]]", "output": "1" }, { "input": "[[1, 2]]", "output": "2" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "3" }, {...
12
false
12
verified
10
10
1
972
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinDepth.Code.Funs /-! # Specifications of `Aegis.MinDepth.min_depth` LeetCode problem `minimum-depth-of-binary-tree`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinDepth open Aegis.MinDepth def nodeCount : Tree → Nat | Tree.Nul...
15
path-sum
112
Easy
[ "Tree", "Depth-First Search", "Breadth-First Search", "Binary Tree" ]
Given the root of a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that adding up all the values along the path equals targetSum. A leaf is a node with no children.   Example 1: Input: root = [5,4,8,11,null,13,4,7,2,null,null,null,1], targetSum = 22 Output: true Explanation...
hasPathSum(root: tree, targetSum: int) -> bool
pub fn has_path_sum(root: &Tree, targetSum: i64) -> bool
Aegis.HasPathSum.has_path_sum
fn has_path_sum_rec(node: &Tree, remaining: i64) -> bool { match node { Tree::Null => false, Tree::Node(value, left, right) => { let next_remaining = remaining - *value; let left_is_null = match &**left { Tree::Null => true, _ => false, ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [has_path_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [has_path_sum]: function definitions module public import Aeneas public import Aegis.HasPathSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option li...
import Aegis.HasPathSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[], 0]", "output": "false" }, { "input": "[[1, 2], 3]", "output": "true" }, { "input": "[[1, 2], 1]", "output": "false" }, { "input": "[[1, 2, 3], 5]", "output": "false" }, { "input": "[[1, 2, 3, 4, 5, 6, 7], 10]", "output": "true" }, { "i...
42
false
42
verified
10
10
1
1,407
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.HasPathSum.Code.Funs /-! # Specifications of `Aegis.HasPathSum.has_path_sum` LeetCode problem `path-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.HasPathSum open Aegis.HasPathSum def nodeCount : Tree → Nat | Tree.Null => 0 ...
6
pascals-triangle
118
Easy
[ "Array", "Dynamic Programming" ]
Given an integer numRows, return the first numRows of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown:   Example 1: Input: numRows = 5 Output: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]] Example 2: Input: numRows = 1 Output: [[1]]   Constraints: 1 <= numRow...
generate(numRows: int) -> list_list_int
pub fn generate(numRows: i64) -> Vec<Vec<i64>>
Aegis.Generate.generate
pub fn generate(numRows: i64) -> Vec<Vec<i64>> { let mut out: Vec<Vec<i64>> = Vec::new(); if numRows <= 0 { return out; } let n = numRows as usize; let mut r: usize = 0; while r < n { let len: usize = r + 1; let mut row: Vec<i64> = Vec::new(); let mut c: usize =...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [generate]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [generate]: function definitions module public import Aeneas public import Aegis.Generate.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.u...
import Aegis.Generate.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[1]", "output": "[[1]]" }, { "input": "[2]", "output": "[[1], [1, 1]]" }, { "input": "[3]", "output": "[[1], [1, 1], [1, 2, 1]]" }, { "input": "[4]", "output": "[[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]]" }, { "input": "[5]", "output": "[[1], [1, 1], [...
16
false
16
verified
10
10
1
1,195
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Generate.Code.Funs /-! # Specifications of `Aegis.Generate.generate` LeetCode problem `pascals-triangle`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.Generate abbrev Matrix : Type := Aeneas.Std.alloc.vec.Vec (Aeneas.Std.alloc.ve...
13
pascals-triangle-ii
119
Easy
[ "Array", "Dynamic Programming" ]
Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown:   Example 1: Input: rowIndex = 3 Output: [1,3,3,1] Example 2: Input: rowIndex = 0 Output: [1] Example 3: Input: rowIndex = 1 Output: [1,...
getRow(rowIndex: int) -> list_int
pub fn get_row(rowIndex: i64) -> Vec<i64>
Aegis.GetRow.get_row
pub fn get_row(rowIndex: i64) -> Vec<i64> { let n: usize = rowIndex as usize; let mut row: Vec<i64> = Vec::new(); row.push(1); let mut k: usize = 1; while k <= n { let prev: i64 = row[k - 1]; let factor: i64 = n as i64 - k as i64 + 1; let value: i64 = (prev * factor) / (k as...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_row]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [get_row]: function definitions module public import Aeneas public import Aegis.GetRow.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unus...
import Aegis.GetRow.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "eva...
[ { "input": "[0]", "output": "[1]" }, { "input": "[1]", "output": "[1, 1]" }, { "input": "[3]", "output": "[1, 3, 3, 1]" }, { "input": "[5]", "output": "[1, 5, 10, 10, 5, 1]" }, { "input": "[7]", "output": "[1, 7, 21, 35, 35, 21, 7, 1]" }, { "input": "[...
20
false
20
verified
10
10
1
2,138
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.GetRow.Code.Funs /-! # Specifications of `Aegis.GetRow.get_row` LeetCode problem `pascals-triangle-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.GetRow def entry? (r : alloc.vec.Vec Std.I64) (j : Nat) : Option Int := (r.val[j]?...
13
best-time-to-buy-and-sell-stock
121
Easy
[ "Array", "Dynamic Programming" ]
You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any...
maxProfit(prices: list_int) -> int
pub fn max_profit(prices: &[i64]) -> i64
Aegis.MaxProfit.max_profit
pub fn max_profit(prices: &[i64]) -> i64 { let n = prices.len(); if n == 0 { return 0; } let mut min_price: i64 = prices[0]; let mut best: i64 = 0; let mut i: usize = 1; while i < n { let p = prices[i]; if p < min_price { min_price = p; } else { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_profit]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_profit]: function definitions module public import Aeneas public import Aegis.MaxProfit.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.MaxProfit.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[2, 1]]", "output": "0" }, { "input": "[[1, 2]]", "output": "1" }, { "input": "[[10, 9, 8, 2]]", "output": "0" }, { "input": "[[7, 6, 4, 3, 1]]", "output": "0" }, { "input": "[[1, 2, 3, 4, 5]]", "ou...
99
false
99
verified
10
10
1
169
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxProfit.Code.Funs /-! # Specifications of `Aegis.MaxProfit.max_profit` LeetCode problem `best-time-to-buy-and-sell-stock`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxProfit def vals (prices : Slice Std.I64) : List Int := p...
12
best-time-to-buy-and-sell-stock-ii
122
Medium
[ "Greedy", "Array", "Dynamic Programming" ]
You are given an integer array prices where prices[i] is the price of a given stock on the ith day. On each day, you may decide to buy and/or sell the stock. You can only hold at most one share of the stock at any time. However, you can buy it then immediately sell it on the same day. Find and return the maximum profit...
maxProfit(prices: list_int) -> int
pub fn max_profit(prices: &[i64]) -> i64
Aegis.MaxProfit.max_profit
pub fn max_profit(prices: &[i64]) -> i64 { let mut profit: i64 = 0; let n = prices.len(); let mut i: usize = 1; while i < n { let diff = prices[i] - prices[i - 1]; if diff > 0 { profit += diff; } i += 1; } profit }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_profit]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_profit]: function definitions module public import Aeneas public import Aegis.MaxProfit.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.MaxProfit.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "...
[ { "input": "[[1]]", "output": "0" }, { "input": "[[1, 2]]", "output": "1" }, { "input": "[[1, 100]]", "output": "99" }, { "input": "[[10, 9, 8, 2]]", "output": "0" }, { "input": "[[7, 6, 4, 3, 1]]", "output": "0" }, { "input": "[[1, 1, 1, 1, 1]]", ...
125
false
125
verified
10
10
1
213
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxProfit.Code.Funs /-! # Specifications of `Aegis.MaxProfit.max_profit` LeetCode problem `best-time-to-buy-and-sell-stock-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxProfit def priceAt (prices : Slice Std.I64) (i : ℕ) : ℤ :...
10
best-time-to-buy-and-sell-stock-iii
123
Hard
[ "Array", "Dynamic Programming" ]
You are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete at most two transactions. Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).   Example 1: Input: pric...
maxProfit(prices: list_int) -> int
pub fn max_profit(prices: &[i64]) -> i64
Aegis.MaxProfit.max_profit
pub fn max_profit(prices: &[i64]) -> i64 { let n = prices.len(); if n == 0 { return 0; } let neg_inf: i64 = -1000000000000000000; let mut buy1 = neg_inf; let mut sell1 = 0; let mut buy2 = neg_inf; let mut sell2 = 0; let mut i = 0; while i < n { let p = prices[i]...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_profit]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_profit]: function definitions module public import Aeneas public import Aegis.MaxProfit.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.MaxProfit.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "...
[ { "input": "[[1, 2]]", "output": "1" }, { "input": "[[7, 6, 4, 3, 1]]", "output": "0" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "4" }, { "input": "[[3, 3, 3, 3, 3]]", "output": "0" }, { "input": "[[10, 22, 5, 75, 65, 80]]", "output": "87" }, { "inpu...
117
false
117
verified
10
10
1
3,313
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxProfit.Code.Funs /-! # Specifications of `Aegis.MaxProfit.max_profit` LeetCode problem `best-time-to-buy-and-sell-stock-iii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxProfit open Aegis.MaxProfit def vals (prices : Slice I6...
11
binary-tree-maximum-path-sum
124
Hard
[ "Tree", "Depth-First Search", "Dynamic Programming", "Binary Tree" ]
A path in a binary tree is a sequence of nodes where each pair of adjacent nodes in the sequence has an edge connecting them. A node can only appear in the sequence at most once. Note that the path does not need to pass through the root. The path sum of a path is the sum of the node's values in the path. Given the root...
maxPathSum(root: tree) -> int
pub fn max_path_sum(root: &Tree) -> i64
Aegis.MaxPathSum.max_path_sum
const NEG: i64 = -1_000_000_000_000; fn max_i64(a: i64, b: i64) -> i64 { if a >= b { a } else { b } } fn positive(x: i64) -> i64 { if x > 0 { x } else { 0 } } fn gain(t: &Tree) -> i64 { match t { Tree::Null => 0, Tree::Node(v, l, r) => { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_path_sum]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.s...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [max_path_sum]: function definitions module public import Aeneas public import Aegis.MaxPathSum.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option li...
import Aegis.MaxPathSum.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[-3]]", "output": "-3" }, { "input": "[[0]]", "output": "0" }, { "input": "[[-1]]", "output": "-1" }, { "input": "[[1]]", "output": "1" }, { "input": "[[2, -1]]", "output": "2" }, { "input": "[[-2, 1]]", "output": "1" }, { "inp...
27
false
27
verified
10
10
4
22,377
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MaxPathSum.Code.Funs /-! # Specifications of `Aegis.MaxPathSum.max_path_sum` LeetCode problem `binary-tree-maximum-path-sum`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MaxPathSum open Aegis.MaxPathSum def nodeVal : Tree → Int |...
16
valid-palindrome
125
Easy
[ "Two Pointers", "String" ]
A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward. Alphanumeric characters include letters and numbers. Given a string s, return true if it is a palindrome, or false otherwise.   Example 1: Inp...
isPalindrome(s: str) -> bool
pub fn is_palindrome(s: &[u8]) -> bool
Aegis.IsPalindrome.is_palindrome
fn is_alnum(c: u8) -> bool { (c >= b'a' && c <= b'z') || (c >= b'A' && c <= b'Z') || (c >= b'0' && c <= b'9') } fn to_lower(c: u8) -> u8 { if c >= b'A' && c <= b'Z' { c + 32 } else { c } } pub fn is_palindrome(s: &[u8]) -> bool { let n = s.len(); if n == 0 { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_palindrome]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [is_palindrome]: function definitions module public import Aeneas public import Aegis.IsPalindrome.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.IsPalindrome.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[\"Able was I ere I saw Elba\"]", "output": "true" }, { "input": "[\"__Level__, __level__\"]", "output": "true" }, { "input": "[\"No lemon, no melon\"]", "output": "true" }, { "input": "[\"0P\"]", "output": "false" }, { "input": "[\"_a!a_\"]", "out...
19
false
19
verified
10
10
1
3,223
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.IsPalindrome.Code.Funs /-! # Specifications of `Aegis.IsPalindrome.is_palindrome` LeetCode problem `valid-palindrome`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.IsPalindrome def IsAlnum (b : Std.U8) : Prop := (48 ≤ b.val ∧ b.val...
9
word-ladder
127
Hard
[ "Breadth-First Search", "Hash Table", "String" ]
A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that: Every adjacent pair of words differs by a single letter. Every si for 1 <= i <= k is in wordList. Note that beginWord does not need to be in wordList. sk == end...
ladderLength(beginWord: str, endWord: str, wordList: list_str) -> int
pub fn ladder_length(beginWord: &[u8], endWord: &[u8], wordList: &[Vec<u8>]) -> i64
Aegis.LadderLength.ladder_length
pub fn ladder_length(beginWord: &[u8], endWord: &[u8], wordList: &[Vec<u8>]) -> i64 { if bytes_equal(beginWord, endWord) { return 1; } let n: usize = wordList.len(); // Locate the end word in the dictionary (sentinel n means "absent"). let mut end_index: usize = n; let mut i: usize = 0...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ladder_length]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [ladder_length]: function definitions module public import Aeneas public import Aegis.LadderLength.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.LadderLength.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[\"talk\", \"tell\", [\"talk\", \"tell\", \"tall\", \"toll\", \"toll\"]]", "output": "3" }, { "input": "[\"hit\", \"cog\", [\"hot\", \"dot\", \"dog\", \"lot\", \"log\"]]", "output": "0" }, { "input": "[\"cat\", \"dog\", [\"bat\", \"rat\", \"hat\", \"hot\", \"dot\", \"dog\"]]"...
13
false
13
verified
10
10
2
15,584
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LadderLength.Code.Funs /-! # Specifications of `Aegis.LadderLength.ladder_length` LeetCode problem `word-ladder`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.LadderLength namespace AegisSpec.LadderLength def IsLowerByte (b : Std.U8) : Prop :...
12
longest-consecutive-sequence
128
Medium
[ "Union Find", "Array", "Hash Table" ]
Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. You must write an algorithm that runs in O(n) time.   Example 1: Input: nums = [100,4,200,1,3,2] Output: 4 Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4. Exampl...
longestConsecutive(nums: list_int) -> int
pub fn longest_consecutive(nums: &[i64]) -> i64
Aegis.LongestConsecutive.longest_consecutive
pub fn longest_consecutive(nums: &[i64]) -> i64 { let n = nums.len(); if n == 0 { return 0; } let mut sorted: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { sorted.push(nums[i]); i += 1; } sorted.sort(); let mut best: i64 = 1; let mut curren...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_consecutive]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_consecutive]: function definitions module public import Aeneas public import Aegis.LongestConsecutive.Code.Types public import Aegis.LongestConsecutive.Code.FunsExternal @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option lin...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [longest_consecutive]: external functions. -- This is a template file: rename it to "FunsExternal.lean" and fill the holes. module public import Aeneas public import Aegis.LongestConsecutive.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFl...
import Aegis.LongestConsecutive.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[]]", "output": "0" }, { "input": "[[1]]", "output": "1" }, { "input": "[[5]]", "output": "1" }, { "input": "[[1000000000, -1000000000, 0]]", "output": "1" }, { "input": "[[-1, 0, 1]]", "output": "3" }, { "input": "[[-1, -2, -3, -4]]", ...
138
false
138
verified
10
10
1
1,014
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.LongestConsecutive.Code.Funs /-! # Specifications of `Aegis.LongestConsecutive.longest_consecutive` LeetCode problem `longest-consecutive-sequence`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.LongestConsecutive open Aeneas.Std.Resu...
14
sum-root-to-leaf-numbers
129
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
You are given the root of a binary tree containing digits from 0 to 9 only. Each root-to-leaf path in the tree represents a number. For example, the root-to-leaf path 1 -> 2 -> 3 represents the number 123. Return the total sum of all root-to-leaf numbers. Test cases are generated so that the answer will fit in a 32-b...
sumNumbers(root: tree) -> int
pub fn sum_numbers(root: &Tree) -> i64
Aegis.SumNumbers.sum_numbers
fn sum_numbers_helper(node: &Tree, prefix: i64) -> i64 { match node { Tree::Null => 0, Tree::Node(value, left, right) => { let current = prefix * 10 + *value; let left_is_null = match &**left { Tree::Null => true, _ => false, }; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_numbers]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.st...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sum_numbers]: function definitions module public import Aeneas public import Aegis.SumNumbers.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option lin...
import Aegis.SumNumbers.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase ...
[ { "input": "[[0]]", "output": "0" }, { "input": "[[1, 0]]", "output": "10" }, { "input": "[[1, 2, 3]]", "output": "25" }, { "input": "[[1, 0, 0]]", "output": "20" }, { "input": "[[1, 0, 1]]", "output": "21" }, { "input": "[[4, 9, 0, 5, 1]]", "outpu...
37
false
37
verified
10
10
1
1,016
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SumNumbers.Code.Funs /-! # Specifications of `Aegis.SumNumbers.sum_numbers` LeetCode problem `sum-root-to-leaf-numbers`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SumNumbers open Aegis.SumNumbers (Tree sum_numbers) def nodeValue ...
11
palindrome-partitioning-ii
132
Hard
[ "String", "Dynamic Programming" ]
Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.   Example 1: Input: s = "aab" Output: 1 Explanation: The palindrome partitioning ["aa","b"] could be produced using 1 cut. Example 2: Input: s = "a" Output: 0 ...
minCut(s: str) -> int
pub fn min_cut(s: &[u8]) -> i64
Aegis.MinCut.min_cut
pub fn min_cut(s: &[u8]) -> i64 { let n = s.len(); if n <= 1 { return 0; } let mut pal: Vec<Vec<bool>> = Vec::new(); let mut i = 0usize; while i < n { let mut row: Vec<bool> = Vec::new(); let mut j = 0usize; while j < n { row.push(false); ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cut]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [min_cut]: function definitions module public import Aeneas public import Aegis.MinCut.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unus...
import Aegis.MinCut.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "eva...
[ { "input": "[\"abcba\"]", "output": "0" }, { "input": "[\"aabbaa\"]", "output": "0" }, { "input": "[\"abcdcba\"]", "output": "0" }, { "input": "[\"abababab\"]", "output": "1" }, { "input": "[\"a\"]", "output": "0" }, { "input": "[\"ab\"]", "output"...
158
false
158
verified
10
10
1
4,150
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.MinCut.Code.Funs /-! # Specifications of `Aegis.MinCut.min_cut` LeetCode problem `palindrome-partitioning-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.MinCut def byteAt (s : Slice U8) (i : Nat) : Nat := match s.val[i]? with ...
11
gas-station
134
Medium
[ "Greedy", "Array" ]
There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from the ith station to its next (i + 1)th station. You begin the journey with an empty tank at one of the gas stations. Given two intege...
canCompleteCircuit(gas: list_int, cost: list_int) -> int
pub fn can_complete_circuit(gas: &[i64], cost: &[i64]) -> i64
Aegis.CanCompleteCircuit.can_complete_circuit
pub fn can_complete_circuit(gas: &[i64], cost: &[i64]) -> i64 { let n = gas.len(); if n == 0 { return -1; } let mut start = n - 1; let mut end = 0usize; let mut tank = gas[start] - cost[start]; while start > end { if tank >= 0 { tank += gas[end] - cost[end]; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_complete_circuit]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [can_complete_circuit]: function definitions module public import Aeneas public import Aegis.CanCompleteCircuit.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fal...
import Aegis.CanCompleteCircuit.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[2, 3, 4], [3, 4, 3]]", "output": "-1" }, { "input": "[[3, 1, 1], [1, 2, 2]]", "output": "0" }, { "input": "[[3, 3, 4], [3, 4, 4]]", "output": "-1" }, { "input": "[[1, 1, 1, 1], [1, 1, 1, 1]]", "output": "3" }, { "input": "[[5, 8, 2, 8], [6, 5, 6, 6]]...
96
false
96
verified
10
10
1
2,185
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.CanCompleteCircuit.Code.Funs /-! # Specifications of `Aegis.CanCompleteCircuit.can_complete_circuit` LeetCode problem `gas-station`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result open Aegis.CanCompleteCircuit namespace AegisSpec.CanCompleteCircuit def ge...
5
candy
135
Hard
[ "Greedy", "Array" ]
There are n children standing in a line. Each child is assigned a rating value given in the integer array ratings. You are giving candies to these children subjected to the following requirements: Each child must have at least one candy. Children with a higher rating get more candies than their neighbors. Return the ...
candy(ratings: list_int) -> int
pub fn candy(ratings: &[i64]) -> i64
Aegis.Candy.candy
pub fn candy(ratings: &[i64]) -> i64 { let n = ratings.len(); if n == 0 { return 0; } let mut candies: Vec<i64> = Vec::new(); let mut i: usize = 0; while i < n { candies.push(1); i += 1; } i = 1; while i < n { if ratings[i] > ratings[i - 1] { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [candy]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style.wh...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [candy]: function definitions module public import Aeneas public import Aegis.Candy.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedV...
import Aegis.Candy.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "eval...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 2, 2]]", "output": "4" }, { "input": "[[1, 0, 2]]", "output": "5" }, { "input": "[[1, 1, 1, 1]]", "output": "4" }, { "input": "[[50, 40, 30, 20, 10]]", "output": "15" }, { "input": "[[1, 3, 4, 5, 2]...
112
false
112
verified
10
10
1
772
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.Candy.Code.Funs /-! # Specifications of `Aegis.Candy.candy` LeetCode problem `candy`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result set_option autoImplicit false namespace AegisSpec.Candy def vals (s : Slice Std.I64) : List ℤ := s.val.map (fun x => x.va...
14
single-number
136
Easy
[ "Bit Manipulation", "Array" ]
Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space.   Example 1: Input: nums = [2,2,1] Output: 1 Example 2: Input: nums = [4,1,2,1,2] Output: 4 Example 3: Input:...
singleNumber(nums: list_int) -> int
pub fn single_number(nums: &[i64]) -> i64
Aegis.SingleNumber.single_number
pub fn single_number(nums: &[i64]) -> i64 { let mut result: i64 = 0; let mut i: usize = 0; while i < nums.len() { result = result ^ nums[i]; i += 1; } result }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [single_number]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter....
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [single_number]: function definitions module public import Aeneas public import Aegis.SingleNumber.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option...
import Aegis.SingleNumber.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCas...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[-1, -1, -2]]", "output": "-2" }, { "input": "[[100000, 100000, 50000]]", "output": "50000" }, { "input": "[[100000, 100000, -100000]]", "output": "-100000" }, { "input": "[[100000, -100000, 100000]]", "output"...
108
false
108
verified
10
10
1
8,796
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SingleNumber.Code.Funs /-! # Specifications of `Aegis.SingleNumber.single_number` LeetCode problem `single-number`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SingleNumber def count (nums : Slice Std.I64) (x : Std.I64) : Nat :=...
12
word-break
139
Medium
[ "Trie", "Memoization", "Array", "Hash Table", "String", "Dynamic Programming" ]
Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Note that the same word in the dictionary may be reused multiple times in the segmentation.   Example 1: Input: s = "leetcode", wordDict = ["leet","code"] Output: tr...
wordBreak(s: str, wordDict: list_str) -> bool
pub fn word_break(s: &[u8], wordDict: &[Vec<u8>]) -> bool
Aegis.WordBreak.word_break
pub fn word_break(s: &[u8], wordDict: &[Vec<u8>]) -> bool { let n = s.len(); let mut dp: Vec<bool> = Vec::new(); let mut i = 0; while i <= n { dp.push(false); i += 1; } dp[0] = true; let mut end = 1; while end <= n { let mut w = 0; while w < wordDict.len...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [word_break]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [word_break]: function definitions module public import Aeneas public import Aegis.WordBreak.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.WordBreak.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "...
[ { "input": "[\"leetcode\", [\"leet\", \"code\"]]", "output": "true" }, { "input": "[\"applepenapple\", [\"apple\", \"pen\"]]", "output": "true" }, { "input": "[\"aaaaaaa\", [\"aa\", \"aaa\"]]", "output": "true" }, { "input": "[\"cars\", [\"car\", \"ca\", \"rs\"]]", "outpu...
87
false
87
verified
10
10
1
744
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.WordBreak.Code.Funs /-! # Specifications of `Aegis.WordBreak.word_break` LeetCode problem `word-break`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.WordBreak def dictWord (wordDict : Slice (alloc.vec.Vec U8)) (i : Nat) : List U8...
8
word-break-ii
140
Hard
[ "Trie", "Memoization", "Array", "Hash Table", "String", "Dynamic Programming", "Backtracking" ]
Given a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences in any order. Note that the same word in the dictionary may be reused multiple times in the segmentation.   Example 1: Input: s = "catsanddog", w...
wordBreak(s: str, wordDict: list_str) -> list_str
pub fn word_break(s: &[u8], wordDict: &[Vec<u8>]) -> Vec<Vec<u8>>
Aegis.WordBreak.word_break
#[allow(unused_macros)] macro_rules! vec { () => { ::std::vec::Vec::<Vec<u8>>::new() }; ($($x:expr),+ $(,)?) => {{ let mut __v: ::std::vec::Vec<_> = ::std::vec::Vec::new(); $( __v.push($x); )+ __v }}; } fn wb_eq(a: &[u8], b: &[u8]) -> bool { if a.len() != b.len() { ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [word_break]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.sty...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [word_break]: function definitions module public import Aeneas public import Aegis.WordBreak.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linte...
import Aegis.WordBreak.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 #eval (s!"CASE 0 {(Result.reducesTo (Aegis.WordBreak.word_break (Slice.from [97#u8] (by scalar_tac) : Slice Std.U8) (Slice.from [(alloc.vec.Vec.from [97#u8] (by scalar_tac) : alloc.vec.Vec Std.U...
[ { "input": "[\"a\", [\"a\"]]", "output": "[\"a\"]" }, { "input": "[\"leetcodeleet\", [\"leet\", \"code\"]]", "output": "[\"leet code leet\"]" }, { "input": "[\"aaaaaaa\", [\"aa\", \"aaa\"]]", "output": "[\"aa aa aaa\", \"aa aaa aa\", \"aaa aa aa\"]" }, { "input": "[\"catsando...
59
true
59
verified
10
10
6
148,081
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.WordBreak.Code.Funs /-! # Specifications of `Aegis.WordBreak.word_break` LeetCode problem `word-break-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.WordBreak abbrev ByteVec : Type := alloc.vec.Vec Std.U8 abbrev SentenceVec...
12
linked-list-cycle
141
Easy
[ "Hash Table", "Linked List", "Two Pointers" ]
Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected t...
hasCycle(head: linkedlist) -> bool
pub fn has_cycle(head: &List) -> bool
Aegis.HasCycle.has_cycle
pub fn has_cycle(head: &List) -> bool { // The harness represents lists as an owned `List` enum with `Box` links, // which cannot encode an actual cycle (no shared references possible). // Therefore every input list is finite and acyclic. let _ = head; false }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [has_cycle]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [has_cycle]: function definitions module public import Aeneas public import Aegis.HasCycle.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.HasCycle.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "e...
[ { "input": "[[]]", "output": "false" }, { "input": "[[1]]", "output": "false" }, { "input": "[[1, 2]]", "output": "false" }, { "input": "[[3, 2, 0, -4]]", "output": "false" }, { "input": "[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]", "output": "false" }, { "inpu...
6
false
6
verified
6
6
1
429
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.HasCycle.Code.Funs /-! # Specifications of `Aegis.HasCycle.has_cycle` LeetCode problem `linked-list-cycle`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.HasCycle def nodeVals : Aegis.HasCycle.List → List Int | .Nil => [] | .Cons ...
2
binary-tree-preorder-traversal
144
Easy
[ "Stack", "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the preorder traversal of its nodes' values.   Example 1: Input: root = [1,null,2,3] Output: [1,2,3] Explanation: Example 2: Input: root = [1,2,3,4,5,null,8,null,null,6,7,9] Output: [1,2,4,5,6,7,3,8,9] Explanation: Example 3: Input: root = [] Output: [] Example 4: Input:...
preorderTraversal(root: tree) -> list_int
pub fn preorder_traversal(root: &Tree) -> Vec<i64>
Aegis.PreorderTraversal.preorder_traversal
fn preorder_helper(t: &Tree, out: &mut Vec<i64>) { match t { Tree::Null => {} Tree::Node(v, left, right) => { out.push(*v); preorder_helper(left, out); preorder_helper(right, out); } } } pub fn preorder_traversal(root: &Tree) -> Vec<i64> { let mut...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [preorder_traversal]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option li...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [preorder_traversal]: function definitions module public import Aeneas public import Aegis.PreorderTraversal.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false ...
import Aegis.PreorderTraversal.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aeg...
[ { "input": "[[]]", "output": "[]" }, { "input": "[[1]]", "output": "[1]" }, { "input": "[[1, 2]]", "output": "[1, 2]" }, { "input": "[[8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15]]", "output": "[8, 4, 2, 1, 3, 6, 5, 7, 12, 10, 9, 11, 14, 13, 15]" }, { "input...
12
false
12
verified
10
10
1
626
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PreorderTraversal.Code.Funs /-! # Specifications of `Aegis.PreorderTraversal.preorder_traversal` LeetCode problem `binary-tree-preorder-traversal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PreorderTraversal open Aegis.Preorde...
4
binary-tree-postorder-traversal
145
Easy
[ "Stack", "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree, return the postorder traversal of its nodes' values.   Example 1: Input: root = [1,null,2,3] Output: [3,2,1] Explanation: Example 2: Input: root = [1,2,3,4,5,null,8,null,null,6,7,9] Output: [4,6,7,5,2,9,8,3,1] Explanation: Example 3: Input: root = [] Output: [] Example 4: Input...
postorderTraversal(root: tree) -> list_int
pub fn postorder_traversal(root: &Tree) -> Vec<i64>
Aegis.PostorderTraversal.postorder_traversal
fn postorder_helper(t: &Tree) -> Vec<i64> { match t { Tree::Null => { let empty: Vec<i64> = Vec::new(); empty } Tree::Node(v, l, r) => { let mut result = postorder_helper(&**l); let right = postorder_helper(&**r); let mut i = 0; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [postorder_traversal]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [postorder_traversal]: function definitions module public import Aeneas public import Aegis.PostorderTraversal.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand fals...
import Aegis.PostorderTraversal.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval ae...
[ { "input": "[[]]", "output": "[]" }, { "input": "[[1]]", "output": "[1]" }, { "input": "[[1, 2]]", "output": "[2, 1]" }, { "input": "[[3, 1, 2]]", "output": "[1, 2, 3]" }, { "input": "[[3, 1, 2, 4]]", "output": "[4, 1, 2, 3]" }, { "input": "[[8, 5, 1, ...
20
false
20
verified
10
10
1
3,060
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.PostorderTraversal.Code.Funs /-! # Specifications of `Aegis.PostorderTraversal.postorder_traversal` LeetCode problem `binary-tree-postorder-traversal`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.PostorderTraversal open Aegis.Postor...
8
insertion-sort-list
147
Medium
[ "Linked List", "Sorting" ]
Given the head of a singly linked list, sort the list using insertion sort, and return the sorted list's head. The steps of the insertion sort algorithm: Insertion sort iterates, consuming one input element each repetition and growing a sorted output list. At each iteration, insertion sort removes one element from the...
insertionSortList(head: linkedlist) -> linkedlist
pub fn insertion_sort_list(head: &List) -> List
Aegis.InsertionSortList.insertion_sort_list
fn copy_values(l: &List, out: &mut Vec<i64>) { match l { List::Nil => {} List::Cons(v, next) => { out.push(*v); let next_ref: &List = &**next; copy_values(next_ref, out); } } } pub fn insertion_sort_list(head: &List) -> List { let mut vals: Vec<i6...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [insertion_sort_list]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option l...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [insertion_sort_list]: function definitions module public import Aeneas public import Aegis.InsertionSortList.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false...
import Aegis.InsertionSortList.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving ...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[0, 0, 0, 0]]", "output": "[0, 0, 0, 0]" }, { "input": "[[4, 2, 1, 3]]", "output": "[1, 2, 3, 4]" }, { "input": "[[-5000, 5000, -4999, 4999]]", "output": "[-5000, -4999, 4999, 5000]" }, { "input": "[[5, 4, 3, 2, ...
122
false
122
verified
10
10
1
3,129
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.InsertionSortList.Code.Funs /-! # Specifications of `Aegis.InsertionSortList.insertion_sort_list` LeetCode problem `insertion-sort-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.InsertionSortList abbrev NList : Type := Aegis...
10
sort-list
148
Medium
[ "Linked List", "Two Pointers", "Divide and Conquer", "Sorting", "Merge Sort" ]
Given the head of a linked list, return the list after sorting it in ascending order.   Example 1: Input: head = [4,2,1,3] Output: [1,2,3,4] Example 2: Input: head = [-1,5,3,4,0] Output: [-1,0,3,4,5] Example 3: Input: head = [] Output: []   Constraints: The number of nodes in the list is in the range [0, 5 * 1...
sortList(head: linkedlist) -> linkedlist
pub fn sort_list(head: &List) -> List
Aegis.SortList.sort_list
fn collect_values(l: &List, mut out: Vec<i64>) -> Vec<i64> { match l { List::Nil => out, List::Cons(v, next) => { out.push(*v); collect_values(&**next, out) } } } fn merge_sort_vec(mut v: Vec<i64>) -> Vec<i64> { let n = v.len(); let mut width: usize = 1; ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_list]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.styl...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [sort_list]: function definitions module public import Aeneas public import Aegis.SortList.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter....
import Aegis.SortList.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" deriving instance ...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[5]]", "output": "[5]" }, { "input": "[[100000, -100000, 0]]", "output": "[-100000, 0, 100000]" }, { "input": "[[0, 0, 0, 0]]", "output": "[0, 0, 0, 0]" }, { "input": "[[-100000, 100000, -100000, 100000]]", "...
108
false
108
verified
10
10
1
10,305
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.SortList.Code.Funs /-! # Specifications of `Aegis.SortList.sort_list` LeetCode problem `sort-list`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.SortList def vals : Aegis.SortList.List → List Int | .Nil => [] | .Cons v next => v....
12
evaluate-reverse-polish-notation
150
Medium
[ "Stack", "Array", "Math" ]
You are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation. Evaluate the expression. Return an integer that represents the value of the expression. Note that: The valid operators are '+', '-', '*', and '/'. Each operand may be an integer or another expression. The di...
evalRPN(tokens: list_str) -> int
pub fn eval_rpn(tokens: &[Vec<u8>]) -> i64
Aegis.EvalRpn.eval_rpn
pub fn eval_rpn(tokens: &[Vec<u8>]) -> i64 { let n = tokens.len(); let mut stack: Vec<i64> = Vec::new(); let mut k: usize = 0; while k < n { stack.push(0); k += 1; } let mut sp: usize = 0; let mut i: usize = 0; while i < n { let tok = &tokens[i]; let m...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [eval_rpn]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [eval_rpn]: function definitions module public import Aeneas public import Aegis.EvalRpn.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.EvalRpn.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[[\"20\", \"5\", \"*\"]]", "output": "100" }, { "input": "[[\"12\", \"3\", \"*\"]]", "output": "36" }, { "input": "[[\"18\", \"4\", \"-\"]]", "output": "14" }, { "input": "[[\"-1\", \"-2\", \"*\"]]", "output": "2" }, { "input": "[[\"5\", \"-2\", \"*\"]...
96
false
96
verified
10
10
1
2,312
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.EvalRpn.Code.Funs /-! # Specifications of `Aegis.EvalRpn.eval_rpn` LeetCode problem `evaluate-reverse-polish-notation`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result Aegis.EvalRpn namespace AegisSpec.EvalRpn abbrev Token : Type := Aeneas.Std.alloc.vec.Ve...
11
find-minimum-in-rotated-sorted-array-ii
154
Hard
[ "Array", "Binary Search" ]
Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,4,4,5,6,7] might become: [4,5,6,7,0,1,4] if it was rotated 4 times. [0,1,4,4,5,6,7] if it was rotated 7 times. Notice that rotating an array [a[0], a[1], a[2], ..., a[n-1]] 1 time results in the...
findMin(nums: list_int) -> int
pub fn find_min(nums: &[i64]) -> i64
Aegis.FindMin.find_min
pub fn find_min(nums: &[i64]) -> i64 { let mut min_val = nums[0]; let n = nums.len(); let mut i: usize = 1; while i < n { if nums[i] < min_val { min_val = nums[i]; } i += 1; } min_val }
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_min]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_option linter.style...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [find_min]: function definitions module public import Aeneas public import Aegis.FindMin.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.un...
import Aegis.FindMin.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" #eval aegisCase "ev...
[ { "input": "[[1]]", "output": "1" }, { "input": "[[1, 3, 5]]", "output": "1" }, { "input": "[[15, 17, 11, 13]]", "output": "11" }, { "input": "[[11, 13, 15, 17]]", "output": "11" }, { "input": "[[2, 2, 2, 0, 1]]", "output": "0" }, { "input": "[[5, 1, 2...
120
false
120
verified
10
10
1
513
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.FindMin.Code.Funs /-! # Specifications of `Aegis.FindMin.find_min` LeetCode problem `find-minimum-in-rotated-sorted-array-ii`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.FindMin open Aegis.FindMin def vals (nums : Slice Std.I64) :...
8
binary-tree-upside-down
156
Medium
[ "Tree", "Depth-First Search", "Binary Tree" ]
Given the root of a binary tree, turn the tree upside down and return the new root. You can turn a binary tree upside down with the following steps: The original left child becomes the new root. The original root becomes the new right child. The original right child becomes the new left child. The mentioned steps ar...
upsideDownBinaryTree(root: tree) -> tree
pub fn upside_down_binary_tree(root: &Tree) -> Tree
Aegis.UpsideDownBinaryTree.upside_down_binary_tree
fn clone_tree(t: &Tree) -> Tree { match t { Tree::Null => Tree::Null, Tree::Node(v, left, right) => Tree::Node( *v, Box::new(clone_tree(&**left)), Box::new(clone_tree(&**right)), ), } } fn attach_rightmost(t: Tree, new_left: Tree, parent_val: i64) -> ...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [upside_down_binary_tree]: type definitions module public import Aeneas @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashCommand false set_option linter.unusedVariables false set_opti...
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [upside_down_binary_tree]: function definitions module public import Aeneas public import Aegis.UpsideDownBinaryTree.Code.Types @[expose] public section open Aeneas Aeneas.Std Result ControlFlow Error set_option linter.dupNamespace false set_option linter.hashComman...
import Aegis.UpsideDownBinaryTree.Code.Funs open Aeneas Aeneas.Std Result set_option maxHeartbeats 4000000 set_option maxRecDepth 4096 def aegisCase (path : String) (i : Nat) (b : Bool) : IO Unit := do let h ← IO.FS.Handle.mk path .append h.putStrLn s!"CASE {i} {b}" h.flush IO.println s!"CASE {i} {b}" derivi...
[ { "input": "[[1]]", "output": "[1]" }, { "input": "[[1, 2]]", "output": "[2, null, 1]" }, { "input": "[[1, 2, 3, 4, 5]]", "output": "[4, 5, 2, null, null, 3, 1]" }, { "input": "[[1, 2, 3, 4, 5, 6, 7]]", "output": "[4, 5, 2, null, null, 3, 1, 6, 7]" }, { "input": "...
7
false
7
verified
7
7
1
21,563
[ { "type": "run_start", "phase": "", "model": null, "messages": null, "response": null, "reasoning": null, "finish_reason": null, "prompt_tokens": null, "completion_tokens": null, "cached_prompt_tokens": null, "command": null, "exit_code": null, "timed_out": null, ...
import Aegis.UpsideDownBinaryTree.Code.Funs /-! # Specifications of `Aegis.UpsideDownBinaryTree.upside_down_binary_tree` LeetCode problem `binary-tree-upside-down`. Each `spec_<n>` theorem states one property of the function. -/ open Aeneas Aeneas.Std Result namespace AegisSpec.UpsideDownBinaryTree open Aegis....
12