Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let letters =
- [
- '0', ['0']
- '1', ['1']
- '2', ['A';'B';'C']
- '3', ['D';'E';'F']
- '4', ['G';'H';'I']
- '5', ['J';'K';'L']
- '6', ['M';'N';'O']
- '7', ['P';'Q';'R';'S']
- '8', ['T';'U';'V']
- '9', ['W';'X';'Y';'Z']
- ]
- |> dict
- let rec permuteRec = function
- | "" -> [""]
- | s ->
- let hd, tl = s.[0], s.Substring(1)
- [for s in permuteRec(tl) do
- for c in letters.[hd] -> c.ToString() + s]
- let permute (digits:string) =
- let words = ref [""]
- for digit in digits do
- words :=
- [for word in words.Value do
- for c in letters.[digit] ->
- c.ToString() + word]
- words.Value
- permute "3663"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement