What kind of algorithm would I need to compute a name that equals a number?
<p>For instance A =1, B = 2 ... Z = 26
The name is auto generated and must equal lets say 200 with the sum of the letters.
e.g.</p>

<pre><code> A = 1
 AB = 3 etc
</code></pre>

<p>What steps would be taken in creating a function to create an array of auto generated strings that has a value of 200?</p>

<p>How would this be done in Python?</p>

<p>You want to generate a string under some constraints.
And this is kind of optimisation problem. However we don't need to hire any machine learning here.</p>

<p>One possible solution might look like this (sorry, no python, just pseudo code)</p>

<ol>
<li><code>name = ""</code> #initialize name variable</li>
<li><code>place = selectPlaceWhereToInsertNextCharacter(name)</code></li>
<li><code>char = selectNextRandomCharacter()</code></li>
<li>update <code>name</code> putting <code>char</code> in <code>place</code></li>
<li>If value of ```name`` is &lt; 200, goto 2</li>
</ol>

<p>Comments:</p>

<ul>
<li>Function <code>selectNextRandomCharacter</code> must select next character which value is less than remaining space in built so far name.
Let's say your current name is <code>"zzz"</code>so the value of it is <code>174</code>. Next letter you select can not be greater than <code>200 - 174</code>. Othewise you will overflow.
To do this - just select next integer within appropriate range and map it to char.</li>
<li><code>selectPlaceWhereToInsertNextCharacter(name)</code> it just selects where you will put next character. For example if name is <code>"pawel"</code> there are 6 plces where you could mix in new letter. This is because I assumed that name must be quite random.</li>
<li>value of name can be checked using such python <code>sum(map(lambda x: ord(x)-64, name))</code></li>
</ul>

python