use strict;
use warnings;
use feature 'say';
my $s = substr join('', map { int rand 2 } 0..40), 0, int rand 41;
say "'$s'";
my $a =()= $s =~ /01/g;
say "01 x $a";
my $b =()= $s =~ /10/g;
say "10 x $b";
say $s =~ /^(|1+(0+1+)*|0+(1+0+)*)$/ ? 'yes' : 'no';