Best shuffle: Difference between revisions

m
→‎{{header|Perl}}: future-proof for 5.36, use new bitwise string operator
m (BaCon and BBC BASIC moved to the BASIC section.)
m (→‎{{header|Perl}}: future-proof for 5.36, use new bitwise string operator)
Line 2,957:
<syntaxhighlight lang="perl">use strict;
use warnings;
use feature 'bitwise';
use List::Util qw(shuffle);
use Algorithm::Permute;
Line 2,975 ⟶ 2,976:
# there will be a \x00 in the "^" of the two words.
# The tr operator is then used to count the "\x00"s.
my $score = ($original_word ^. $word) =~ tr/\x00//;
next if $score >= $best_score;
($best_word, $best_score) = ($word, $score);
Line 3,010 ⟶ 3,011:
swaps which will improve the score.
 
{{trans|goGo}}
<syntaxhighlight lang="perl">use strict;
use warnings;
use feature 'bitwise';
use List::Util qw(shuffle);
 
Line 3,035 ⟶ 3,037:
my $word = join '', @t;
 
my $score = ($original_word ^. $word) =~ tr/\x00//;
print "$original_word, $word, $score\n";
}
Line 3,042 ⟶ 3,044:
The output has the same format as the first perl implementation,
but only takes quadratic time per word.
 
=={{header|Phix}}==
<!--<syntaxhighlight lang="phix">(phixonline)-->
2,392

edits