34
2
My first code golf post, apologies for any mistakes...
Context
In rock climbing (bouldering specifically), the V/Vermin (USA) climbing grades start at 'VB' (the easiest grade), and then go 'V0', 'V0+', 'V1', 'V2', 'V3', 'V4', 'V5' etc. up to 'V17' (the hardest grade).
Task
You will take as input a list/array of climbing grades and you have to to return or print a list/array of the grades sorted from easiest to hardest.
If the input is empty, return an empty data structure; otherwise the input will always be a valid.
Test cases
Input | Output
[] | []
['V1'] | ['V1']
['V7', 'V12', 'V1'] | ['V1', 'V7', 'V12']
['V13', 'V14', 'VB', 'V0'] | ['VB', 'V0', 'V13', 'V14']
['V0+', 'V0', 'V16', 'V2', 'VB', 'V6'] | ['VB', 'V0', 'V0+', 'V2', 'V6', 'V16']
This is a code-golf challenge.
Next time, post this on the sandbox to get feedback before posting it. Secondly, should you really answer your own challenge?
– Ian H. – 2017-08-02T08:55:54.360Will duplicate grades appear in the input? – Mr. Xcoder – 2017-08-02T09:01:13.580
@Mr.Xcoder No duplicates – Chris_Rands – 2017-08-02T09:02:17.267
@IanH. I see, thanks for the tips, well I deleted my own solution and will post it again in a few days (based on the feedback from others) – Chris_Rands – 2017-08-02T09:06:23.167
7Welcome to PPCG! Pretty clear and nice for a first question. (y) – officialaimm – 2017-08-02T09:33:48.730
3Very nice first question! The answers it has lead to are so varying and creative. :) – Lynn – 2017-08-02T10:04:44.570
A good variation would be if you could handle both Vermin and Font grades – Jimmy – 2017-08-02T19:28:37.613