Ejemplo n.º 1
0
bool division_bad_parity_hack( const method &m, const change &c, 
                               size_t div_start, size_t cur_div_len )
{
  // It should be possible to do this easily without calculating rows.

  row r( c.bells() );

  vector< row > rows( 1, r );
  rows.reserve( cur_div_len );

  for ( int i = div_start; i < m.length(); ++i )
  {
    r *= m[i];
    rows.push_back( r );
  }
  
  rows.push_back( r * c );

  assert( rows.size() == cur_div_len );

  size_t even[2] = { 0u, 0u }, odd[2] = { 0u, 0u };
  
  for ( unsigned int i = 0; i < rows.size(); ++i )
    {
      if ( rows[i].sign() == +1 )
	++even[i%2];
      else
	++odd[i%2];
    } 

  if ( even[0] != odd[0] || even[1] != odd[1] )
    return true; // Bad
    
  return false; // OK
}
Ejemplo n.º 2
0
bool is_too_many_places( const method &m, const change &c, size_t max, 
                         size_t stopoff )
{
  for ( int i=0; i<c.bells(); ++i )
    if ( c.findplace(i) )
      {
	size_t count(2u);

	for ( ; count <= size_t(m.length())+1; ++count ) {
          size_t o = m.length() - count + 1;
          if ( o == stopoff || !m[o].findplace(i) )
	    break;
        }

	if ( count > max )
	  return true;
      }

  return false;
}
Ejemplo n.º 3
0
bool is_division_false( const method &m, const change &c, 
                        size_t div_start, size_t cur_div_len )
{
  size_t const len = m.length();
  if ( len - div_start < 3 || len - div_start == cur_div_len-1 )
    return false;

  row r( c.bells() );

  vector< row > rows( 1, r );
  rows.reserve( cur_div_len );

  for ( int i = div_start; i < len; ++i )
    {
      r *= m[i];
      rows.push_back( r );
    }

  if ( find( rows.begin(), rows.end(), r * c ) != rows.end() )
    return true;

  return false;
}