Convert a string of digits from words to an integer Convert a string containing digits as words into an integer, ignoring leading zeros.

Examples


"four two" -> 42.
"zero zero zero one" -> 1.


Assumptions

Submissions can assume that:


The input string is comprised of space-separated digit words.
All words are valid (in the range "zero".."nine") and lowercase. Behaviour for empty input is undefined.
The input string always represents an unsigned number within the range of int and is never an empty string.


Scoring

Answers will be scored in bytes with fewer bytes being better.
PHP, 74 bytes



foreach(explode(' ',$argn)as$w)$n.='793251_8640'[crc32($w)%20%11];echo+$n;


Try it online!

Tried to get a solution which doesn't copy existing answers. I get cyclic redundancy checksum polynomial of 32-bit lengths (crc32) for each word and then do a mod 20 and mod 11 on it to get mixed up unique values from 0 to 10 (missing 6) for each digit. Then using that unique value I find the actual digit.



| Word  | CRC32      | %20 | %11 | Equivalent digit |
|-------|------------|-----|-----|------------------|
| zero  | 2883514770 | 10  | 10  | 0                |
| one   | 2053932785 | 5   | 5   | 1                |
| two   | 298486374  | 14  | 3   | 2                |
| three | 1187371253 | 13  | 2   | 3                |
| four  | 2428593789 | 9   | 9   | 4                |
| five  | 1018350795 | 15  | 4   | 5                |
| six   | 1125590779 | 19  | 8   | 6                |
| seven | 2522131820 | 0   | 0   | 7                |
| eight | 1711947398 | 18  | 7   | 8                |
| nine  | 2065529981 | 1   | 1   | 9                |


Another 74 bytes CRC32 alternative using %493%10: Try it online!

Another 74 bytes CRC32 alternative using %2326%11: Try it online!



PHP, 74 bytes



foreach(explode(' ',$argn)as$w)$n.=strpos(d07bfe386c,md5($w)[21]);echo+$n;


Try it online!

Another alternative with same length, takes 22nd character in the md5 of the word (only character which gives a unique value for each word) and then uses that character to map to a digit.