Skip to content

Instantly share code, notes, and snippets.

@RandyMcMillan
Forked from rust-play/playground.rs
Last active February 18, 2026 13:15
Show Gist options
  • Select an option

  • Save RandyMcMillan/7fc9c9a24e491001597182f2117fc6db to your computer and use it in GitHub Desktop.

Select an option

Save RandyMcMillan/7fc9c9a24e491001597182f2117fc6db to your computer and use it in GitHub Desktop.
nonce_gaps.rs
fn main() {
let mut nonces = vec![0u128];
let mut counter = 0u64;
nonces.pop();
// First Gap: 1.5 x 10^9 to 2.0 x 10^9
//counter += (2.0e9 - 1.5e9) as u64;
for nonce in 1_500/*_000_000*/..=3_000/*_000_000*/ {
nonces.push(nonce*1_000_000);
counter = counter+1;
};
//for nonce in nonces.clone() {println!("{}",nonce);}
// Second Gap: 2.5 x 10^9 to 3.0 x 10^9
//counter += (3.0e9 - 2.5e9) as u64;
for nonce in 2_500/*_000_000*/..=3_000/*_000_000*/ {
nonces.push(nonce*1_000_000);
counter = counter+1;
};
//for nonce in nonces.clone() {println!("{}",nonce);}
// Third Gap: 3.5 x 10^9 to 4.0 x 10^9
//counter += (4.0e9 - 3.5e9) as u64;
for nonce in 3_500/*_000_000*/..=4_000/*_000_000*/ {
nonces.push(nonce*1_000_000);
counter = counter+1;
};
for nonce in nonces.clone() {print!("{} ",nonce);}
print!("\ncount={} ", counter);
// Each gap has a size of 0.5 x 10^9
// A more concise way to represent the total count is to sum the number of gaps and multiply by the gap size.
// let gap_size = 0.5e9 as u64;
// let number_of_gaps = 3;
// let total_count = gap_size * number_of_gaps;
// println!("Total count from the first method: {}", counter);
// println!("Total count from the second method: {}", total_count);
}
@RandyMcMillan
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment