--nextPart1896260.BgATiusI6Z
Content-Type: text/plain;
charset so-8859-6"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
Thanks for catching the "pangram" versus "panagram" issue, I had never noticed
it. Thanks to everyone for your great solutions, they are very interesting
and I have learned a lot from reading them.
In the interest of completeness, here is my original script that prompted me
to suggest this quiz. Those that read the Perl solution will recognize it is
very similar. This code is limited because (like the perl script) it will
barf if the count of any one letter is > 99, however, I have not found this
to be a practical problem with any seeds I have tried (I think the greatest
letter count was ~35).
This code produced two solutions using the same seed, something I thought not
possible (at least when using a reasonable short seed):
Only a fool would check that this sentence contains exactly six 'a's, one 'b',
six 'c's, three 'd's, thirty-four 'e's, five 'f's, two 'g's, ten 'h's,
thirteen 'i's, one 'j', two 'k's, five 'l's, one 'm', twenty-two 'n's,
seventeen 'o's, one 'p', one 'q', seven 'r's, thirty-two 's's,
twenty-six 't's, three 'u's, seven 'v's, eight 'w's, six 'x's, seven 'y's,
and one 'z'.
and:
Only a fool would check that this sentence contains exactly six 'a's, one 'b',
six 'c's, three 'd's, thirty-three 'e's, four 'f's, two 'g's, ten 'h's,
twelve 'i's, one 'j', two 'k's, six 'l's, one 'm', twenty 'n's, sixteen 'o's,
one 'p', one 'q', seven 'r's, thirty-two 's's, twenty-five 't's, three 'u's,
six 'v's, eight 'w's, seven 'x's, seven 'y's, and one 'z'
And the code:
#################
$snum = {
1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five', 6
=> 'six',
7 => 'seven', 8 => 'eight', 9 => 'nine', 10 => 'ten', 11 => 'eleven',
12 => 'twelve', 13 => 'thirteen', 14 => 'fourteen', 15 => 'fifteen',
16 => 'sixteen', 17 => 'seventeen', 18 => 'eighteen', 19 => 'nineteen',
20 => 'twenty', 30 => 'thirty', 40 => 'forty', 50 => 'fifty', 60
=> 'sixty',
70 => 'seventy', 80 => 'eighty', 90 => 'ninety'
}
def spelledNumber(x)
if x >= 100
print "must be 99 or less"
exit
elsif x <= 20
$snum[x]
else
tens = (x / 10).to_i * 10
if x - tens == 0
$snum[x]
else
$snum[tens] + "-" + $snum[x - tens]
end
end
end
def checkIfTrue(s)
realCount = {}
LETTERS.each do |c|
realCount[c] = s.count(c)
end
if $fixedCount == realCount
puts "Found it:"
puts s
exit
end
$fixedCount.each do |key, value|
x = s.count(key)
y = value
$fixedCount[key] = randomizer(x, y)
end
$fixedCount
end
def randomizer(x, y)
if x == y then return x end
if x > y then x, y = y, x end
rand(y-x+1)+x
end
LETTERS = ('a'..'z').to_a
seed = %q/darrens ruby panagram program found this sentence which contains
exactly and /
$fixedCount = {}
LETTERS.each { |c| $fixedCount[c] = rand(50) }
while 1
(1..10000).each do
s = seed
LETTERS.each do |c|
s += spelledNumber($fixedCount[c])
s += " '#{c}'"
s += $fixedCount[c] >= 2 ? "s, " : ", "
end
$fixedCount = checkIfTrue(s)
end
print "\t10K blip...\n"
end
###################
--
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972
--nextPart1896260.BgATiusI6Z
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (GNU/Linux)
iD8DBQBEtXMMwPD5Cr/3CJgRAmefAKDikB6co/gqVVEAup14QJcsQiaByQCgyviB
Czkk2hO3MzIyq3LHjyEmMf8 cs
-----END PGP SIGNATURE-----
--nextPart1896260.BgATiusI6Z--