7 kyu

TV Remote

394 of 2,825dinglemouse

Description:

Background

My TV remote control has arrow buttons and an OK button.

I can use these to move a "cursor" on a logical screen keyboard to type "words"...

The screen "keyboard" layout looks like this

abcde123
fghij456
klmno789
pqrst.@0
uvwxyz_/

Kata task

How many button presses on my remote are required to type a given word?

Notes

  • The cursor always starts on the letter a (top left)
  • Remember to also press OK to "accept" each character.
  • Take a direct route from one character to the next
  • The cursor does not wrap (e.g. you cannot leave one edge and reappear on the opposite edge)
  • A "word" (for the purpose of this Kata) is any sequence of characters available on my virtual "keyboard"

Example

word = codewars

  • c => a-b-c-OK = 3
  • o => c-d-e-j-o-OK = 5
  • d => o-j-e-d-OK = 4
  • e => d-e-OK = 2
  • w => e-j-o-t-y-x-w-OK = 7
  • a => w-r-m-h-c-b-a-OK = 7
  • r => a-f-k-p-q-r-OK = 6
  • s => r-s-OK = 2

Answer = 3 + 5 + 4 + 2 + 7 + 7 + 6 + 2 = 36


*Good Luck!
DM.*

Series

Algorithms

Stats:

CreatedJan 6, 2018
PublishedJun 17, 2018
Warriors Trained6516
Total Skips138
Total Code Submissions11722
Total Times Completed2825
Java Completions394
JavaScript Completions894
Python Completions892
Ruby Completions90
C++ Completions237
C Completions129
PHP Completions64
Dart Completions97
Julia Completions12
C# Completions146
Total Stars205
% of votes with a positive feedback rating92% of 610
Total "Very Satisfied" Votes531
Total "Somewhat Satisfied" Votes63
Total "Not Satisfied" Votes16
Total Rank Assessments4
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • dinglemouse Avatar
  • kazk Avatar
  • adrian.eyre Avatar
  • Blind4Basics Avatar
  • KataSideKick Avatar
  • clcraig Avatar
  • FArekkusu Avatar
  • monadius Avatar
  • hobovsky Avatar
  • stellartux Avatar
  • hrommy Avatar
Ad