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 the same
::::*   indicate if or which character is different from the previous character
::*   display each string and its length   (as the strings are being examined)
::*   a zero─length (empty) string shall be considered as all the same character(s)
::*   process the strings from left─to─right
::*   if       all the same character,   display a message saying such
::*   if not all the same character,   then:
::::*   display a message saying such
::::*   display what character is different
::::* &nbsp; only the 1<sup>st</sup> different character need be displayed
::::* &nbsp; display where the different character is in the string
::::* &nbsp; the above messages can be part of a single message
::::* &nbsp; display the hexadecimal value of the different character
Use (at least) these seven test values &nbsp; (strings):
:::* &nbsp; a string of length &nbsp; 0 &nbsp; (an empty string)
:::* &nbsp; a string of length &nbsp; 3 &nbsp; which contains three blanks
:::* &nbsp; a string of length &nbsp; 1 &nbsp; which contains: &nbsp; '''2'''
:::* &nbsp; a string of length &nbsp; 3 &nbsp; which contains: &nbsp; '''333'''
:::* &nbsp; a string of length &nbsp; 3 &nbsp; which contains: &nbsp; '''.55'''
:::* &nbsp; a string of length &nbsp; 6 &nbsp; which contains: &nbsp; '''tttTTT'''
:::* &nbsp; a string of length &nbsp; 9 &nbsp; with a blank in the middle: &nbsp; '''4444 &nbsp; 444k'''
Show all output here on this page.
{{Template:Strings}}
<br><br>