SHARE
TWEET

Untitled

a guest Jan 18th, 2019 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fn one() {
  2.     let mut count : u64 = 0;
  3.     let until = 1e8 as u64;
  4.     for i in 1..until {
  5.         let s = i.to_string();
  6.         if s.contains("3") {
  7.             count+=1;
  8.         }
  9.     }
  10.     println!("Count until {}: {}", until, count);
  11.  
  12. }
  13.  
  14. fn two() {
  15.     let mut count : u64 = 0;
  16.     let until = 1e8 as u64;
  17.     let mut s = String::with_capacity(10);
  18.     for i in 1..until {
  19.         s.clear();
  20.         use std::fmt::Write;
  21.         write!(s, "{}", i).unwrap();
  22.         if s.contains("3") {
  23.             count+=1;
  24.         }
  25.     }
  26.     println!("Count until {}: {}", until, count);
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top