Code Monkey home page Code Monkey logo

oldphonekeypad's Introduction

Old Phone Pad

This is a C# implementation of a method that converts a sequence of button presses on an old phone keypad to a string of letters.

The old phone keypad has the following layout:

  1     2     3
&'()  abc   def

  4     5     6
 ghi   jkl   mno

  7     8     9
pqrs  tuv   wxyz

  *     0     #
     space

To use the OldPhonePad method, simply call it with a string of button presses as input. The method will return the corresponding string of letters.

Example usage:

string output = OldPhonePad("227*#");
Console.WriteLine(output); // Output: B

Method signature

public static string OldPhonePad(string input)

Parameters

input: A string representing a sequence of button presses on an old phone keypad.

Return value

A string representing the corresponding sequence of letters.

Button mapping

The mapping of each button to its corresponding letters is as follows:

Button: 1
Letters: &'(

Button: 2
Letters: abc

Button: 3
Letters: def

Button: 4
Letters: ghi

Button: 5
Letters: jkl

Button: 6
Letters: mno

Button: 7
Letters: pqrs

Button: 8
Letters: tuv

Button: 9
Letters: wxyz

Button: *
Letters: (none)

Button: 0
Letters: space

Button: #
Letters: (none)

Additional notes

  • Pressing the same button repeatedly cycles through the letters associated with that button.
  • Pressing a different button or a pause before the end of the input adds the previous letter to the output.
  • The backspace button (*) removes the last letter from the output, unless it was the last character added to the output.
  • The pause button (0) adds a space to the output.
  • The end-of-input button (#) signals the end of the input and adds the last letter to the output.
  • If the input ends with a backspace button (*), the last letter added to the output is deleted and not included in the output.
  • If the input ends with a pause button (0) or a backspace button followed by a pause button (*0), the last letter is not included in the output.

oldphonekeypad's People

Contributors

d1dac0 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.