Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So far, this has nothing to do with minimazation of automata, right? You are trying to create an automaton from some (given) file format.</p> <p>Since this is a homework, I'll just give you some hints:</p> <p><code>readlines</code> returns a list. You can address specific lines by index, i.e., <code>lines[0]</code> for the first line, <code>lines[1]</code>, for the second, etc. Each of these lines will be a string. Taking, for instance, the line containing the set of states (<code>lines[0]</code>, which holds <code>'dyny,fllf,gdci,gwtj,knos,kole,mjnw,msdl,mtfz,nbat,njgb,nzwx,rzpn,vcsc,zgfx'</code>), you can use</p> <p><code>lines[0].split(',')</code></p> <p>to split it by comma, which gives you a list of strings, each of which represents a state. Those lines which represent individual transitions follow a slightly more complicated format: </p> <p><code>&lt;state&gt;','&lt;input symbol&gt;'-&gt;'&lt;next state&gt;</code></p> <p>You want to parse those lines so that you get the three components depicted above. <code>string.split</code> is again your friend here. You should also decide on a suitable datastructure for the transition function (delta).</p> <p>Note: <code>readlines</code> reads the entire file at once. In practice, automata are often quite big in which case it would be better to read the file incrementally. File objects (<code>f</code> in your code) implement the iterator protocol and allow you to iterate over the file's lines. In particular, I would suggest to use</p> <pre><code>line1 = f.next() # Next line (first line, if first call of next) line2 = f.next() # Next line ... </code></pre> <p>for the first four lines (to get the set of states, etc) and to iterate over the rest (the transitions):</p> <pre><code>for line in f: ... </code></pre> <p>See <a href="http://docs.python.org/tutorial/inputoutput.html" rel="nofollow">http://docs.python.org/tutorial/inputoutput.html</a> for details.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload