Datasets:
Tasks:
Text Generation
Modalities:
Text
Formats:
json
Languages:
English
Size:
< 1K
ArXiv:
Tags:
competitive-programming
code-generation
specification-generation
proof-generation
verification
rust
License:
Download leetcode/lc153/code_spec.rs from Gax-c/VeriContest_Lite: direct link, hf CLI and curl.
- Browser
- Download file 1.31 kB
-
https://huggingface.co/datasets/Gax-c/VeriContest_Lite/resolve/main/leetcode/lc153/code_spec.rs
- Command line
-
hf download hf://datasets/Gax-c/VeriContest_Lite/leetcode/lc153/code_spec.rs
-
curl -L -o code_spec.rs https://huggingface.co/datasets/Gax-c/VeriContest_Lite/resolve/main/leetcode/lc153/code_spec.rs
1.31 kB
| use vstd::prelude::*; | |
| fn main() {} | |
| verus! { | |
| pub struct Solution; | |
| impl Solution { | |
| pub open spec fn is_rotation_point(nums: Seq<i32>, k: int) -> bool { | |
| 0 <= k < nums.len() | |
| && (forall |a: int, b: int| k <= a < b < nums.len() ==> nums[a] < nums[b]) | |
| && (forall |a: int, b: int| 0 <= a < b < k ==> nums[a] < nums[b]) | |
| && (k == 0 || forall |a: int, b: int| 0 <= a < k && k <= b < nums.len() ==> nums[a] > nums[b]) | |
| } | |
| pub fn find_min(nums: Vec<i32>) -> (result: i32) | |
| requires | |
| 1 <= nums.len() <= 5000, | |
| forall |i: int| 0 <= i < nums.len() ==> -5000 <= nums[i] <= 5000, | |
| forall |i: int, j: int| 0 <= i < j < nums.len() ==> nums[i] != nums[j], | |
| exists |k: int| Self::is_rotation_point(nums@, k), | |
| ensures | |
| forall |i: int| 0 <= i < nums.len() ==> result <= nums[i], | |
| exists |i: int| 0 <= i < nums.len() && result == nums[i], | |
| { | |
| let mut left: usize = 0; | |
| let mut right: usize = nums.len() - 1; | |
| while left < right | |
| { | |
| let mid = left + (right - left) / 2; | |
| if nums[mid] > nums[right] { | |
| left = mid + 1; | |
| } else { | |
| right = mid; | |
| } | |
| } | |
| nums[left] | |
| } | |
| } | |
| } | |