Find an algorithm to write a given word with this broken keyboard

That's my approach

This implicitly means that finding the button to map the keyboard character follows

As it says, the problem can be of arbitrary complexity because we have no prior information on this transfer function.

  • random or have a random component
  • stateful, so the result could depend on the history

However, let's start by focusing on a simple subset of transfer functions with the following characteristics:

We can model this as follows, in terms of Haskell

f :: Char -> Char

However, there is an additional problem with this function: it is possible that any character we need is not represented, that is, there is no input for this function, which allows us to get the desired character output.

This makes the problem essentially equivalent to a linear search, so it is SURE) with NOT number of possible characters for the transfer function, so buttons on this keyboard

The additional restriction that requires entering a word and not unique characters, to observe the result, does not affect the complexity: it is sufficient to identify a set of non-overlapping words covering the entire input domain for get a complete knowledge.

At the end of this procedure, we can solve the problem or decide not to solve it because some characters are not representable.