Skip to content

Commit 7513997

Browse files
committed
feature phone key pad
1 parent 94e3923 commit 7513997

2 files changed

Lines changed: 2 additions & 50 deletions

File tree

key_press/key_press.py

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,3 @@
1-
# LANGUAGE: PYTHON
2-
# FEATURE PHONE KEY PRESSES
3-
4-
5-
# This is a feature phone keypad:
6-
7-
# ------- ------- -------
8-
# | | | ABC | | DEF |
9-
# | 1 | | 2 | | 3 |
10-
# ------- ------- -------
11-
# ------- ------- -------
12-
# | GHI | | JKL | | MNO |
13-
# | 4 | | 5 | | 6 |
14-
# ------- ------- -------
15-
# ------- ------- -------
16-
# |PQRS | | TUV | | WXYZ|
17-
# | 7 | | 8 | | 9 |
18-
# ------- ------- -------
19-
# ------- ------- -------
20-
# | | | | | |
21-
# | * | | 0 | | # |
22-
# ------- ------- -------
23-
24-
25-
# Before predictive text entry systems like T9, you had to press a button
26-
# repeatedly to cycle through the possible values until you reached
27-
# the one you wanted.
28-
29-
# For example, to type "V8" you would press the 8 key three times and then
30-
# again four times (pressing the 8 key cycles through T->U->V->8),
31-
# giving us a total of seven key presses.
32-
33-
# Note: the 0 key handles spaces and outputs 0 when tapped twice.
34-
35-
# Write a function that can calculate the amount of button presses required for any phrase.
36-
# Except for spaces, punctuation can be ignored.
37-
# Your function should accept both uppercase and lowercase letters and treat them the same.
38-
39-
# Examples:
40-
# presses('V8') # 7
41-
# presses('LOL') # 9
42-
# presses('How R u 2day') # 23
43-
44-
# Bonus: Try to avoid hard-coding the number of button presses for each letter!
45-
# Resource: http://www.learnpython.org/en/Dictionaries
46-
# Use python Dictionaries in this exercise
47-
48-
49-
501
def presses(str):
512
# Your Code Here!
523

readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Happy coding!
8686
### Question 5
8787

8888
This is a feature phone keypad:
89+
```
8990
9091
------- ------- -------
9192
| | | ABC | | DEF |
@@ -104,7 +105,7 @@ This is a feature phone keypad:
104105
| * | | 0 | | # |
105106
------- ------- -------
106107
107-
108+
```
108109
Before predictive text entry systems like T9, you had to press a button
109110
repeatedly to cycle through the possible values until you reached
110111
the one you wanted.

0 commit comments

Comments
 (0)