Python Find Patterns In 1d Shapes