Just in time processing on a character stream: Difference between revisions

Content added Content deleted
(fix English in problem description)
Line 1: Line 1:
{{draft task}}
{{draft task}}
Given a stream of characters, presumably (simulated) from a keyboard, that contain the separators "formfeed", "linefeed", "tab" and "space" characters. Print out the i<sup>th</sup> character of the i<sup>th</sup> tab-field of the i<sup>th</sup> line of the i<sup>th</sup> page to reveal a secret password.
Given a stream of characters containing the separator characters "formfeed", "linefeed", "tab" and "space", print out the i<sup>th</sup> character of the i<sup>th</sup> tab-field of the i<sup>th</sup> line of the i<sup>th</sup> page to reveal a secret password.


Stop processing immediately upon encountering a "!" found uniquely in this <i>i,i,i,i</i> position (least the system self destruct). The "!" may be found/permitted else where however, in which case it should be ignored.
Stop processing immediately upon encountering a "!" found uniquely in this <i>i,i,i,i</i> position (lest the system self-destruct). The "!" may be found elsewhere however, in which case it should be ignored.


Ideally this can be generalise as follows:
Ideally this can be generalised as follows:
* The separators (formfeed, linefeed, tab, space) provided from a user supplied array and can include additional/alternative separators, e.g. (formfeed, linefeed, ".", "," ," ",...).
* The separator characters are defined by a user-supplied array that can include additional or alternative separators, e.g. (formfeed, linefeed, ".", "," ," ",...).
* These selection criterial is generalised i<sup>th</sup>,i<sup>th</sup>,i<sup>th</sup>,i<sup>th</sup> to a boolean function of <i>f(page,line,field,word,...) <b>or</b> f(i<sup>th</sup>,j<sup>th</sup>,k<sup>th</sup>,l<sup>th</sup>,m<sup>th</sup>,etc...)</i>
* The selection criterion is generalised i<sup>th</sup>,i<sup>th</sup>,i<sup>th</sup>,i<sup>th</sup> to a boolean function of <i>f(page,line,field,word,...) <b>or</b> f(i<sup>th</sup>,j<sup>th</sup>,k<sup>th</sup>,l<sup>th</sup>,m<sup>th</sup>,etc...)</i>


Provide a reasonably interesting message to be decoded, e.g. Silence-Dogood. Your choice.
Provide a reasonably interesting message to be decoded, e.g. "Silence-Dogood". Your choice.


This task was inspired by the movie "[[wp:National_Treasure_%28film%29|National Treasure]]" with refers to a "[[wp:Book cipher|book cipher]]".
This task was inspired by the movie "[[wp:National_Treasure_%28film%29|National Treasure]]", which refers to a "[[wp:Book cipher|book cipher]]".


=={{header|C}}==
=={{header|C}}==