```On Fri, 03 Aug 2007 13:46:16 +0000, Paul Novak wrote:

> There is no end of numerological[0,1] variations that could be used by
> anyone who feels the need for an additional challenge this week.

Well then, along those lines I have a Hebrew gematria counter. Give it
words on the commandline, and it will tell you what the gematria is of
those words, and what the total gematria.

I use this to check when converting Hebrew citations of Jewish books into
English for the benefit of those reading English newsgroups.

#!/usr/bin/env ruby
\$KCODE = "u"
require "jcode"
require 'generator'
class String
def u_reverse; split(//).reverse.join; end
end

LETTERVALUES=Hash.new(0).merge \
Hash['' => 1, '' => 2, '' => 3, '' => 4, '' => 5,
'' => 6, '' => 7, '' => 8, '' => 9, '' => 10, '' => 20
'' => 30, '' => 40, '' => 50, '' => 60, '' => 70, '' => 80,
'' => 90, '' => 100, '' => 200, '' => 300, '' => 400,
'' => 40, '' => 20 , '' => 50, '' => 80, '' => 90]
gematrias=ARGV.collect do |word|
word.split(//).inject(0) do |t,l|
t+LETTERVALUES[l]
end
end

SyncEnumerator.new(ARGV, gematrias).each do |word,value|
#reverse the word to print it RTL if all of the characters in it
#are hebrew letters

#note that this doesn't find nikudot, but then we don't care
#anyway because the terminal mangles nikudot -- the result will be
#so mangled anyway that we don't care whether it's reversed
word=word.u_reverse if word.split(//)-LETTERVALUES.keys==[]
printf "%s %d\n", word, value
end

printf "Total %d\n", gematrias.inject {|t,l| t+l}

--
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/

```