-- -*- mode: eiffel -*-
-- $Id: hash.se,v 1.3 2001/01/18 20:57:05 doug Exp $
-- http://www.bagley.org/~doug/shootout/

class HASH
   
creation make
   
feature -- Initialization
   
   make is
      local
     n : INTEGER
     i, j, c : INTEGER
     s : STRING
     ht : DICTIONARY[INTEGER, STRING]
     
     arg: ARGUMENTS
      do
     n := argument(1).to_integer

     !!ht.with_capacity(n);
     
     from  i := 1
     until i > n
     loop
        s := i.to_hexadecimal
        from  j := 1
        until s @ j /= '0'
        loop  j := j + 1
        end
        ht.put (i, s.substring(j,s.count))
        i := i+1
     end
     
     from  i := n
     until i = 0
     loop
        s := i.to_string
         if ht.has (s) then
           c := c + 1
        end
        i := i - 1
     end
     
     print (c.out + "%N")

      end

end -- class HASH