DEV Community

Discussion on: Can you solve this interview problem?

Collapse
 
choroba profile image
E. Choroba

A Perl solution I was able to write in less than 5 minutes:

#!/usr/bin/perl
use warnings;
use strict;
use feature qw{ say };

use MIME::Base64 qw{ decode_base64 };
use List::Util qw{ shuffle };

my $cipher = '[ "6Ly9kZXYudG", "9jb21tZW5", "8vMHNodXZvMC", "aHR0cHM", "0LzFqZTFt" ]';

my @strings = $cipher =~ /"([^"]+)"/g;

my $string = "";
until ($string =~ /^[ -~]+$/) {
    @strings = shuffle(@strings);
    $string = decode_base64(join "", @strings);
}
say $string;
Enter fullscreen mode Exit fullscreen mode
Collapse
 
0shuvo0 profile image
Shuvo

Nice