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:
File size: 449 Bytes
b2a430f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | use vstd::prelude::*;
fn main() {}
verus! {
pub struct Solution;
pub open spec fn count_odds_up_to(n: int) -> int {
(n + 1) / 2
}
impl Solution {
pub fn count_odds(low: i32, high: i32) -> (res: i32)
requires
0 <= low <= high <= 1_000_000_000,
ensures
0 <= res,
res == count_odds_up_to(high as int) - count_odds_up_to(low as int - 1),
{
(high + 1) / 2 - low / 2
}
}
}
|