Multi-tap Keypad Text Entry

Multi-tap Keypad Text Entry


This is a fun code to show how many taps were required to send messages via numeric keypads.

*Featured Code Submitted and Created By VENOM666


# Multi-tap Keypad Text Entry (from Codewars)
# by: VENOM666

"""
    Prior to having fancy iPhones, teenagers would wear out their thumbs sending SMS messages on candybar-shaped feature phones with 3x4 numeric keypads.
    Prior to the development of T9 (predictive text entry) systems, the method to type words was called "multi-tap" and involved pressing a button repeatedly to cycle through the possible values.

    For example, to type a letter "R" you would press the 7 key three times (as the screen display for the current character cycles through P->Q->R->S->7). A character is "locked in" once the user presses a different key or pauses for a short period of time (thus, no extra button presses are required beyond what is needed for each letter individually). The zero key handles spaces, with one press of the key producing a space and two presses producing a zero.
    
    In order to send the message "WHERE DO U WANT 2 MEET L8R" a teen would have to actually do 47 button presses.
"""

Python


keyStrokes = {1 : ['!', '1'], 2 : ['!', 'A', 'B', 'C', '2'], 3 : ['!', 'D', 'E', 'F', '3'], 4 : ['!', 'G', 'H', 'I', '4'], 5 : ['!', 'J', 'K', 'L', '5'], 6 : ['!', 'M', 'N', 'O', '6'], 7 : ['!', 'P', 'Q', 'R', 'S', '7'], 8 : ['!', 'T', 'U', 'V', '8'], 9 : ['!', 'W', 'X', 'Y', 'Z', '9'], 0 : ['!', " ", "0"]}

def keystrokeCount(phrase):
    keyPresses = 0
    
    for ch in phrase:
        for key, value in keyStrokes.items():
            if ch in value:
                keyPresses += keyStrokes[key].index(ch)

    print(phrase + ": " + str(keyPresses) + " keystrokes")

keystrokeCount("WHERE DO U WANT 2 MEET L8R")



Share with Friends


Twitter Facebook Google LinkedIn Email Pinterest Reddit StumbleUpon Tumblr

More Free Code Examples:


Python Code to Reverse a String


Hello World in 10 Programming Languages


8 Codes to Find Versions





Try these Fun Games by Bobbie:


Travel Blast Game New York


Play and Learn Russian


Battlestarship Game



Take a look at these Groovy Codes:


Fun IQ Test


Html Svg Starburst


Javascript Particles Fishes



Read the Latest Breaking Programming and Tech News, Great Articles and Tips:



Codenewz Programming and Tech News





Comments

  1. I have been searching to find a comfort or effective procedure to complete this process and I think this is the most suitable way to do it effectively.

    Data Science Course

    ReplyDelete
  2. Great tips and very easy to understand. This will definitely be very useful for me when I get a chance to start my blog.

    Data Science Training

    ReplyDelete
  3. Wonderful blog found to be very impressive to come across such an awesome blog. I should really appreciate the blogger for the efforts they have put in to develop such an amazing content for all the curious readers who are very keen of being updated across every corner. Ultimately, this is an awesome experience for the readers. Anyways, thanks a lot and keep sharing the content in future too.

    Artificial Intelligence Course in bhilai

    ReplyDelete
  4. Tremendous blog quite easy to grasp the subject since the content is very simple to understand. Obviously, this helps the participants to engage themselves in to the subject without much difficulty. Hope you further educate the readers in the same manner and keep sharing the content as always you do.

    Data Science Training in Bhilai

    ReplyDelete
  5. Stupendous blog huge applause to the blogger and hoping you to come up with such an extraordinary content in future. Surely, this post will inspire many aspirants who are very keen in gaining the knowledge. Expecting many more contents with lot more curiosity further.

    Digital Marketing training in Bhilai

    ReplyDelete
  6. Do you have video on tiktok how you make it? On this site https://soclikes.com/buy-tiktok-likes you can buy tiktok likes for it

    ReplyDelete
  7. Terrific post thoroughly enjoyed reading the blog and more over found to be the tremendous one. In fact, educating the participants with it's amazing content. Hope you share the similar content consecutively.

    Data Science certification in Bhilai

    ReplyDelete
  8. Impressive blog to be honest definitely this post will inspire many more upcoming aspirants. Eventually, this makes the participants to experience and innovate themselves through knowledge wise by visiting this kind of a blog. Once again excellent job keep inspiring with your cool stuff.

    Digital Marketing training in Bhilai

    ReplyDelete
  9. Truly mindblowing blog went amazed with the subject they have developed the content. These kind of posts really helpful to gain the knowledge of unknown things which surely triggers to motivate and learn the new innovative contents. Hope you deliver the similar successive contents forthcoming as well.

    Digital Marketing Course

    ReplyDelete
  10. Really wonderful blog completely enjoyed reading and learning to gain the vast knowledge. Eventually, this blog helps in developing certain skills which in turn helpful in implementing those skills. Thanking the blogger for delivering such a beautiful content and keep posting the contents in upcoming days.

    Data Science training in Raipur

    ReplyDelete
  11. Truly incredible blog found to be very impressive due to which the learners who ever go through it will try to explore themselves with the content to develop the skills to an extreme level. Eventually, thanking the blogger to come up with such an phenomenal content. Hope you arrive with the similar content in future as well.

    Digital Marketing Course in Raipur

    ReplyDelete
  12. Highly appreciable regarding the uniqueness of the content. This perhaps makes the readers feels excited to get stick to the subject. Certainly, the learners would thank the blogger to come up with the innovative content which keeps the readers to be up to date to stand by the competition. Once again nice blog keep it up and keep sharing the content as always.

    Data Science training

    ReplyDelete
  13. Wonderful blog found to be very impressive to come across such an awesome blog. I should really appreciate the blogger for the efforts they have put in to develop such an amazing content for all the curious readers who are very keen of being updated across every corner. Ultimately, this is an awesome experience for the readers. Anyways, thanks a lot and keep sharing the content in future too.

    Digital Marketing training

    ReplyDelete
  14. Amazing Article ! I would like to say thank you for the efforts you had made for writing this awesome article. This article inspired me to read more your blogs. keep it up.

    Affiliate Marketing Training In Telugu
    Affiliate Marketing Means In Telugu
    Digital Marketing Training In Telugu
    Blogging In Telugu
    Podcast Meaning In telugu
    SEO Meaning In Telugu
    1000 Social BookMarking Sites List

    ReplyDelete
  15. Wonderful blog..!! Reference links are similar to the topic that I’m looking for.
    AngularJS Training in Chennai
    RPA Training in Chennai

    ReplyDelete
  16. Extraordinary blog filled with an amazing content which no one has touched this subject before. Thanking the blogger for all the terrific efforts put in to develop such an awesome content. Expecting to deliver similar content further too and keep sharing as always.

    Data Science Training

    ReplyDelete
  17. Stupendous blog huge applause to the blogger and hoping you to come up with such an extraordinary content in future. Surely, this post will inspire many aspirants who are very keen in gaining the knowledge. Expecting many more contents with lot more curiosity further.

    Data Science Certification in Bhilai

    ReplyDelete
  18. Stupendous blog huge applause to the blogger and hoping you to come up with such an extraordinary content in future. Surely, this post will inspire many aspirants who are very keen in gaining the knowledge. Expecting many more contents with lot more curiosity further.

    Data Science Certification in Bhilai

    ReplyDelete
  19. Extraordinary blog filled with an amazing content which no one has touched this subject before. Thanking the blogger for all the terrific efforts put in to develop such an awesome content. Expecting to deliver similar content further too and keep sharing as always.

    Data Science Training

    ReplyDelete
  20. Very Informative and unique content. This the best blog post I've read . Thanks for sharing

    Trading for beginners

    ReplyDelete

Post a Comment

Popular posts from this blog

HTML5 Crossword 1