START ESCWYP MUSIC VIDEOS
------------------------------------------------- permut.rs -----------------------
fn freespot(ind :u32, minfree: &mut u32, num :u32, f :&mut Vec){
   if ind < num {
      f[ind as usize] = true;
      if ind < *minfree {
         *minfree = ind;
      }
   }
}
fn takespot(ind :u32, minfree: &mut u32, num :u32, f :&mut Vec){
   if ind < num {
      f[ind as usize] = false;
      if ind == *minfree {
         for i in (ind+1)..num{
            if f[i as usize] == true {
               *minfree = i as u32;
               break;
            }
         }
      }
   }
}

fn main(){
   let mut num:u32 = 4;
   let mut index:u32 = 0;
   let mut old:u32 = 0;
   let mut minfree:u32 = 0;
   let ar:Vec = std::env::args().collect();
   if ar.len() > 1 {
      let tmp = ar[1].parse::();
      if true == tmp.is_ok() {
         let tmp2 = tmp.unwrap();
         if tmp2 > 1 {
            num = tmp2;
         }
      }
   }
   let mut f : Vec = vec![true; num as usize];
   let mut c : Vec = vec![-1; num as usize];
   println!("Init fertig {}", num);

   let mut count :u32 = 1;
   loop {
      let mut start :u32 = (c[index as usize]+1) as u32;
      if start == 0 {
         start = minfree;
      }
      for i in start..num {
         if f[i as usize] == true {
            freespot(c[index as usize] as u32, &mut minfree, num, &mut f);
            takespot(i, &mut minfree, num, &mut f);
            c[index as usize] = i as i32;
            if index < num-1 {
               index = index+1;
            } else {
               freespot(i, &mut minfree, num, &mut f);
               if num > 100 {
                  for j in 0..10 {
                     print!("{} ", c[j as usize]);
                  }
                  print!("... ");
                  for j in num-10..num {
                     print!("{} ", c[j as usize]);
                  }
               } else {
                  for j in 0..num {
                     print!("{} ", c[j as usize]);
                  }
               }
               println!(" | {}", count);
               count = count+1;
            } 
            break;
         }
      }
      if index == old {
         freespot(c[index as usize] as u32, &mut minfree, num, &mut f);
         c[index as usize] = -1;
         if index == 0 {
            break;
         }else{
            index = index-1;
         }
      }
      old = index;
   }
}


START ESCWYP MUSIC VIDEOS