≈ the.bay.news

Get all sums of array values, along with the indices of the elements

The Rust Programming Language Forum
Get all sums of array values, along with the indices of the elements
fn main() { let data: [u8;4] = [2, 5, 7, 8]; let dlen: usize = data.len(); // 4 let cnt_data_comb: u8 = 2_u8.pow(4) - 1; // 2^4 -1 = 15 // [A] // I can get the quantities in the groups like this: let mut c; for i in 0..dlen { println!(); c = cnt(dlen as u8, i as u8 + 1); for j in 0..c { println!("{}. ", j+1); } } // code ... } fn cnt(dlen: u8, cnt_n: u8) -> usize { let cnt_1: u8 = (1..=dlen).produ...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.