Skip to content

Instantly share code, notes, and snippets.

@AspenForester
Created June 17, 2020 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AspenForester/40405f8dbd047569d2a2c18d74ef1f60 to your computer and use it in GitHub Desktop.
Save AspenForester/40405f8dbd047569d2a2c18d74ef1f60 to your computer and use it in GitHub Desktop.
My approach to the basic problem of the June 16, 2020 Iron Scripter Challenge. Very basic, not a function.
$Text = "EnVeLoPe"
$result = switch ($Text.ToCharArray()) {
{$_ -in ('a','b','c')} { "2"; continue }
{$_ -in ('d','e','f')} { "3"; continue }
{$_ -in ('g','h','i')} { "4"; continue }
{$_ -in ('j','k','l')} { "5"; continue }
{$_ -in ('m','n','o')} { "6"; continue }
{$_ -in ('p','q','r','s')} { "7"; continue }
{$_ -in ('t','u','v')} { "8"; continue }
{$_ -in ('w','x','y','z')} { "9"; continue }
Default {}
}
$result -join ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment