DEV Community

Discussion on: Daily Challenge #5 - Ten Minute Walk

Collapse
 
choroba profile image
E. Choroba

Just make sure the number of s's and n's is the same, and the same for w's and e's.

Perl solution:

use List::Util qw{ shuffle };

sub walk {
    shuffle map { int rand 2 ? ('n', 's') : ('w', 'e') } 1 .. $_[0] / 2
}