5318008 - Fun with Calculators

Bash + coreutils, 54

Again, thanks to @TobySpeight for the golfing help.

rev|tr oizehsglb 0-8|sed '/.\{11\}\|[^0-9]/d;s/^0/&./'

Input wordlist is taken from STDIN:

$ ./5318008.sh < /usr/share/dict/words | head
8
38
338
5338
638
5638
36138
31738
531738
7738
$ 

CJam, 44 42 bytes

r{el"oizehsglb"f#W%"0."a.e|N+_,B<*_W&!*r}h

Try it online in the CJam interpreter.

To run the program from the command line, download the Java interpreter and execute:

java -jar cjam-0.6.5.jar 5318008.cjam < /usr/share/dict/words

How it works

r            e# Read a whitespace-separated token from STDIN.
{            e# While loop:
 el          e#   Convert to lowercase.
 "oizehsglb" e#   Push that string.
 f#          e#   Get the index of each character from the input in that string.
             e#   This pushes -1 for "not found".
 W%          e#   Reverse the resulting array.
 "0."a       e#   Push ["0."].
 .e|         e#   Vectorized logical NOT. This replaces an initial 0 with "0.".
 N+          e#   Append a linefeed.
 _,B<*       e#   Repeat the array (array.length < 11) times.
 _W&!*       e#   Repeat the array !(array.intersection(-1)) times.
 r           e#   Read a whitespace-separated token from STDIN.
}h           e# If the token is not empty, repeat the loop.

Python 2, 271 216 211 205 Bytes

This is the only idea I've had so far.. I will update this once I think of something else! I assumed we needed to read from a file, but if not let me know so I can update :)

Big thanks to Dennis for saving me 55 bytes :)

Also thanks to Sp3000 for saving 6 bytes :)

d,f,g='oizehsglb',[x.lower()for x in open('w.txt').read().split('\n')if len(x)<10],[]
for x in f:
 c=x[::-1]
 for b in d:c=c.replace(b,`d.find(b)`)
 g=[g,g+[['0.'+c[1:],c][c[0]!='0']]][c.isdigit()]
print g

Tags:

Code Golf