Word Scoring - Solution and Thoughts About Optimization
I was watching a video today where they had a theoretical word scoring game. The scoring rules were as follows
- 2 for a,i,e,o
- 3 for f
- 5 for t
- 6 for j
- 12 for x
I wrote this code to do the scoring:
My biggest gripe at the moment is this line of code:
There must be a simpler and better way to do this. I am going to dig into the different Ruby collections over the next few days to fix that line of code. Thereafter I would like to jump into the loop I do in these lines:
Again there must be a more Ruby way of doing this kind of thing, not only that but there must be a more efficient way of calculating the score.
As an aside I didn’t get a chance to write more code in converting DbScriptomate to Ruby so that is left for tomorrow.