The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: kappa on February 06, 2011, 11:58:07 PM

Title: delete repeated letters
Post by: kappa on February 06, 2011, 11:58:07 PM
Hi, I'm new to this forum and to the assembly, so hello everyone. My problem is this: I want to delete, repeated letters from the given string (eg, hello), and then add this string to the existing array. I think I need to copy character by character to another variable and check (iterating through a string) that the letters are not repeated. The second issue is to copy string letter by letter and add this to the array. Unfortunately, my current knowledge of the assembler does not allow me to code this. I will be grateful for any tips and code examples.
Title: Re: delete repeated letters
Post by: Slugsnack on February 07, 2011, 12:15:27 AM
You don't want to search through any structure for existing letters. It will take a long time and complexity becomes very bad for long passages. Set up a bitmaps of bytes representing all possible characters. Each dword would have 32 possible characters then. Initialize them all to 0 and iterate through your original string. For each character do a bitmap mask check to see if that 'flag' is set. If no, add to new array and set flag. If yes, move to next char. At the end print out your array.