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/lc1480/code_spec.rs from Gax-c/VeriContest_Lite: direct link, hf CLI and curl.
- Browser
- Download file 917 Bytes
-
https://huggingface.co/datasets/Gax-c/VeriContest_Lite/resolve/main/leetcode/lc1480/code_spec.rs
- Command line
-
hf download hf://datasets/Gax-c/VeriContest_Lite/leetcode/lc1480/code_spec.rs
-
curl -L -o code_spec.rs https://huggingface.co/datasets/Gax-c/VeriContest_Lite/resolve/main/leetcode/lc1480/code_spec.rs
917 Bytes
| use vstd::prelude::*; | |
| fn main() {} | |
| verus! { | |
| pub struct Solution; | |
| impl Solution { | |
| pub open spec fn spec_sum(s: Seq<i32>, end: int) -> int | |
| decreases end, | |
| { | |
| if end <= 0 { | |
| 0 | |
| } else { | |
| Self::spec_sum(s, end - 1) + s[end - 1] as int | |
| } | |
| } | |
| pub fn running_sum(nums: Vec<i32>) -> (result: Vec<i32>) | |
| requires | |
| 1 <= nums.len() <= 1000, | |
| forall |i: int| 0 <= i < nums.len() ==> -1_000_000 <= nums[i] <= 1_000_000, | |
| ensures | |
| result.len() == nums.len(), | |
| forall |i: int| 0 <= i < result.len() as int ==> result[i] == Self::spec_sum(nums@, i + 1), | |
| { | |
| let mut result = nums; | |
| let n = result.len(); | |
| let mut i: usize = 1; | |
| while i < n | |
| { | |
| result.set(i, result[i] + result[i - 1]); | |
| i = i + 1; | |
| } | |
| result | |
| } | |
| } | |
| } | |