How to resolve the algorithm Determine if a string has all unique characters step by step in the 11l programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Determine if a string has all unique characters step by step in the 11l programming language
Table of Contents
Problem Statement
Given a character string (which may be empty, or have a length of zero characters):
Use (at least) these five test values (strings):
Show all output here on this page.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Determine if a string has all unique characters step by step in the 11l programming language
Source code in the 11l programming language
F processString(input)
[Char = Int] charMap
V dup = Char("\0")
V index = 0
V pos1 = -1
V pos2 = -1
L(key) input
index++
I key C charMap
dup = key
pos1 = charMap[key]
pos2 = index
L.break
charMap[key] = index
V unique = I dup == Char("\0") {‘yes’} E ‘no’
V diff = I dup == Char("\0") {‘’} E ‘'’dup‘'’
V hexs = I dup == Char("\0") {‘’} E hex(dup.code)
V position = I dup == Char("\0") {‘’} E pos1‘ ’pos2
print(‘#<40 #<6 #<10 #<8 #<3 #<5’.format(input, input.len, unique, diff, hexs, position))
print(‘#<40 #2 #10 #8 #. #.’.format(‘String’, ‘Length’, ‘All Unique’, ‘1st Diff’, ‘Hex’, ‘Positions’))
print(‘#<40 #2 #10 #8 #. #.’.format(‘------------------------’, ‘------’, ‘----------’, ‘--------’, ‘---’, ‘---------’))
L(s) [‘’, ‘.’, ‘abcABC’, ‘XYZ ZYX’, ‘1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ’]
processString(s)
You may also check:How to resolve the algorithm Pascal's triangle step by step in the X86 Assembly programming language
You may also check:How to resolve the algorithm Atomic updates step by step in the D programming language
You may also check:How to resolve the algorithm Grayscale image step by step in the Euler Math Toolbox programming language
You may also check:How to resolve the algorithm Largest int from concatenated ints step by step in the S-lang programming language
You may also check:How to resolve the algorithm Van der Corput sequence step by step in the Forth programming language