13
1
Introduction
In the land of [Insert cool name here], people don't buy things with money, because everyone has a severe allergy to paper. They pay eachother with words! But how is that? Well, they give each letter number values:
a=1,b=2,c=3,etc.
(With some other special rules that will be described later)
In this challenge, your task will be to calculate the value of sentences.
Challenge
You will take an input which will be a sentence. You may assume the input has no newlines or trailing spaces. The challenge will be to calculate the value of the sentence, using these rules:
a=1,b=2,c=3,etc.
- A capital letter is worth 1.5 times it's corresponding lowercase letter
H=h*1.5
So, the word
cab
Would be worth c+a+b = 3+1+2 = 6
But the word Cab
with a capital c would be worth (c*1.5)+a+b = 4.5+1+2 = 7.5
So if your program input was "Cab" your program would output 7.5
- All non alphabetic characters are worth 1.
This is code golf, so shortest answer in bytes wins. Good luck!
4Wait, money is paper?? I always thought it was either shiny metal discs or some sort of magic invoked by swiping the sacred card. – Geobits – 2015-08-21T14:08:54.987
2Even U.S. banknotes are actually made of cotton and linen..but I guess the people of [Insert cool name here] hadn't thought of that yet. – jcai – 2015-08-21T14:31:15.400
Are trailing zeros allowed? E.g., printing
7.0
instead of7
? – kirbyfan64sos – 2015-08-21T16:37:55.667@kirbyfan64sos Trailing 0s are allowed. – Nico A – 2015-08-21T21:32:51.350
What about spaces? – juniorRubyist – 2018-06-03T04:56:27.087
@juniorRubyist All non-alphabetic characters are worth 1. – Nico A – 2018-06-03T13:12:41.947