You are viewing a single comment's thread. Return to all comments →
Perl solution:
sub marsExploration { my $s = shift; my @arr = split("", $s); my $cnt = 0; for (my $i = 0; $i <= scalar(@arr) - 1; $i += 3) { $cnt++ if ($arr[$i] ne "S"); $cnt++ if ($arr[$i+1] ne "O"); $cnt++ if ($arr[$i+2] ne "S"); } return $cnt }
Seems like cookies are disabled on this browser, please enable them to open this website
Mars Exploration
You are viewing a single comment's thread. Return to all comments →
Perl solution: