titlecase {ana,rando}gram output and consistently quote
parent
44d9e638f5
commit
3e3fcd77b7
|
@ -76,13 +76,13 @@ handle remainder => sub {
|
|||
|
||||
if($full_word) {
|
||||
if(@output) {
|
||||
my $ana = "anagram: ";
|
||||
$ana = "anagrams: " if scalar(@output) > 1;
|
||||
my $ana = "Anagram of \"$in\": ";
|
||||
$ana = "Anagrams of \"$in\": " if scalar(@output) > 1;
|
||||
return $ana.join(', ', @output);
|
||||
}
|
||||
return $garbledAnswer;
|
||||
}
|
||||
return "Anagrams of $in of size $n: ".join(', ', @output) if @output;
|
||||
return "Anagrams of \"$in\" of size $n: ".join(', ', @output) if @output;
|
||||
return $garbledAnswer;
|
||||
};
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ handle remainder => sub {
|
|||
my @chars = split(//, $_); #convert each character of the query to an array element
|
||||
my @garbledChars = shuffle(@chars); #randomly reorder the array
|
||||
my $garbledAnswer = join('',@garbledChars); #convert array to string
|
||||
return "randagram: $garbledAnswer";
|
||||
return "Randagram: $garbledAnswer";
|
||||
};
|
||||
|
||||
zci is_cached => 0;
|
||||
|
|
18
t/Anagram.t
18
t/Anagram.t
|
@ -10,15 +10,15 @@ zci is_cached => 0;
|
|||
|
||||
ddg_goodie_test(
|
||||
[qw(DDG::Goodie::Anagram)],
|
||||
'anagram filter' => test_zci("anagram: trifle"),
|
||||
'anagrams events' => test_zci("anagram: Steven"),
|
||||
'anagram of algorithm' => test_zci("anagram: logarithm"),
|
||||
'anagrams of favorite' => test_zci(qr/\"favorite\" scrambled: [favorite]{8}/),
|
||||
'anagram of' => test_zci(qr/\"of\" scrambled: (of|fo)/),
|
||||
'anagram filter 5' => test_zci("Anagrams of filter of size 5: filet, flier, flirt, lifer, liter, refit, rifle"),
|
||||
'anagram times' => test_zci("anagrams: emits, items, mites, smite"),
|
||||
'anagram Mixing it up' => test_zci(qr/\"Mixing it up\" scrambled: [ Mixngtup]{12}/),
|
||||
'anagram algorithm 14' => test_zci("anagram: logarithm")
|
||||
'Anagram filter' => test_zci('Anagram of "filter": trifle'),
|
||||
'anagrams events' => test_zci('Anagram of "events": Steven'),
|
||||
'anagram of algorithm' => test_zci('Anagram of "algorithm": logarithm'),
|
||||
'anagrams of favorite' => test_zci(qr/"favorite" scrambled: [favorite]{8}/),
|
||||
'anagram of' => test_zci(qr/"of" scrambled: (of|fo)/),
|
||||
'anagram filter 5' => test_zci('Anagrams of "filter" of size 5: filet, flier, flirt, lifer, liter, refit, rifle'),
|
||||
'anagram times' => test_zci('Anagrams of "times": emits, items, mites, smite'),
|
||||
'anagram Mixing it up' => test_zci(qr/"Mixing it up" scrambled: [ Mixngtup]{12}/),
|
||||
'anagram algorithm 14' => test_zci('Anagram of "algorithm": logarithm')
|
||||
);
|
||||
|
||||
done_testing;
|
||||
|
|
|
@ -10,7 +10,7 @@ zci is_cached => 0;
|
|||
|
||||
ddg_goodie_test(
|
||||
[qw(DDG::Goodie::Randagram)],
|
||||
'randagram algorithm' => test_zci(qr/randagram: [algorithm]/)
|
||||
'randagram algorithm' => test_zci(qr/Randagram: [algorithm]/)
|
||||
);
|
||||
|
||||
done_testing;
|
||||
|
|
Loading…
Reference in New Issue