REBOL [
    Title:   "Hash"
    Author:  "Aldo Calpini"
    Date:    05-Jul-2001
    File:    %hash.r
]

NUM: to-integer to-string system/script/args
NUM: either NUM < 1 [ 1 ] [ NUM ]

myhex: func [ N /local k flag c r ] [
    k: to-hex N
    k: to-string k
    flag: 0
    r: copy ""
    forall k [
        c: first k
        if (c <> #"0") or (flag = 1) [
            append r c
            flag: 1
        ]
    ]
    return r
]

X: make hash! []
c: 0
for i 1 NUM 1 [
    append X myhex i
    append X i
]

for i NUM 1 -1 [
    s: to-string i
    if select/skip X s 2 [
        c: c + 1
    ]
]
print c

write %output.rebol c