RosettaCodeData/Task/Determine-if-a-string-has-a.../00-TASK.txt

36 lines
1.7 KiB
Plaintext

;Task:
Given a character string   (which may be empty, or have a length of zero characters):
::*   create a function/procedure/routine to:
::::*   determine if all the characters in the string are unique
::::*   indicate if or which character is duplicated and where
::*   display each string and its length   (as the strings are being examined)
::*   a zero─length (empty) string shall be considered as unique
::*   process the strings from left─to─right
::*   if       unique,   display a message saying such
::*   if not unique,   then:
::::*   display a message saying such
::::*   display what character is duplicated
::::* &nbsp; only the 1<sup>st</sup> non─unique character need be displayed
::::* &nbsp; display where "both" duplicated characters are in the string
::::* &nbsp; the above messages can be part of a single message
::::* &nbsp; display the hexadecimal value of the duplicated character
Use (at least) these five test values &nbsp; (strings):
:::* &nbsp; a string of length &nbsp; &nbsp; 0 &nbsp; (an empty string)
:::* &nbsp; a string of length &nbsp; &nbsp; 1 &nbsp; which is a single period &nbsp; (<big>'''.'''</big>)
:::* &nbsp; a string of length &nbsp; &nbsp; 6 &nbsp; which contains: &nbsp; '''abcABC'''
:::* &nbsp; a string of length &nbsp; &nbsp; 7 &nbsp; which contains a blank in the middle: &nbsp; '''XYZ&nbsp; ZYX'''
:::* &nbsp; a string of length &nbsp; 36 &nbsp; which &nbsp; ''doesn't'' &nbsp; contain the letter "oh":
:::::::: '''1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ'''
Show all output here on this page.
{{Template:Strings}}
<br><br>