fn has_repeating_sequence(values: &[u32]) -> Option<usize> {
  let value = match values.last() {
    Some(&x) => x,
    None => return None,
  };
  if let Some(f) = values.iter().rev().skip(2).position(|&v| v == value) {
    // Current value was generated earlier; check if there’s a
    // repeating sequence placed back to back
    let border = values.len() - 2 - f;
    let expected_len = values.len() - border;
    // check if it’s repeating ignoring small sequences
    if (expected_len > 2)
      && (border >= expected_len)
      && (values[(border - expected_len)..border] == values[border..])
    {
      return Some(expected_len);
    }
  }
  None
}
/** Checks if `values` has a repeating sequence at the end;
returns its length if found */
Checks if `values` has a repeating sequence at the end;
returns its length if found
Checks if ` values ` has a repeating sequence at the end ; returns its length if found
fn has_repeating_sequence(values: &[u32]) -> Option<usize> {
  let value = match values.last() {
    Some(&x) => x,
    None => return None,
  };
  if let Some(f) = values.iter().rev().skip(2).position(|&v| v == value) {
    // Current value was generated earlier; check if there’s a
    // repeating sequence placed back to back
    let border = values.len() - 2 - f;
    let expected_len = values.len() - border;
    // check if it’s repeating ignoring small sequences
    if (expected_len > 2)
      && (border >= expected_len)
      && (values[(border - expected_len)..border] == values[border..])
    {
      return Some(expected_len);
    }
  }
  None
}
fn has_repeating_sequence ( values : & [ u32 ] ) -> Option < usize > { let value = match values . last ( ) { Some ( & x ) => x , None => return None , } ; if let Some ( f ) = values . iter ( ) . rev ( ) . skip ( 2 ) . position ( | & v | v == value ) { // Current value was generated earlier; check if there’s a // repeating sequence placed back to back let border = values . len ( ) - 2 - f ; let expected_len = values . len ( ) - border ; // check if it’s repeating ignoring small sequences if ( expected_len > 2 ) && ( border >= expected_len ) && ( values [ ( border - expected_len ) .. border ] == values [ border .. ] ) { return Some ( expected_len ) ; } } None }
Checks if `values` has a repeating sequence at the end;
returns its length if found
Checks if ` values ` has a repeating sequence at the end ; returns its length if found
values
&[u32]