I think looping through the key is cleaner than looping through the alphabet: Dim key as string = "keyword" Dim alphabet As new StringBuilder("abcdefghijklmnopqrstuvwxyz") for each c As Char in key alphabet. Replace(c.ToString(), Nothing) next return key & alphabet.ToString() or slightly more efficient change the replace line as follows to avoid scanning all 26 letters of the alphabet on each iteration: alphabet. Replace(c.ToString(), Nothing, 0, 1).
1 This solution gets more effective as the key get longer: key. Len x ((26+key. Len)/2) times.(The alphabet get shorter as it get's removed).
The other solutions: 26 x key. Len times. – Gerhard Powell Nov 16 at 19:08 thank you for the reply – K_McCormic Nov 16 at 19:11 @GerhardPowell I agree this one searches less, but isn't this one key.
Len X alphabet. Len / 2 (aka key. Len X 26 / 2 aka key.
Len X 13) not counting a shrinking alphabet. It only gets better (faster) on each pass. Can you elaborate on the +key.
Len you mentioned? – tcarvin Nov 16 at 19:39 1 Sorry. Mistake in my formula.Key.
Len x ((26 + (26-key. Len))/2). So the avg of the alphabet and alphabet with all the keys removed.
– Gerhard Powell Nov 16 at 20:25 1 @GerhardPowell Go it, very nice. If you use my 2nd Replace command then that number is divided in half yet again because the alphabet scan jumps out after finding a match. So on average an alphabet scan will need only to visit 1/2 the characters.So after much reducing that is key.
Len x (52 - key. Len) / 4. Like you said, it should get more efficient the longer the key.
– tcarvin Nov 16 at 20:39.
Public Function Rearrange(keyword As String) As String Dim cipher As New StringBuilder(26) cipher. Append(keyword) For c As Char = "a"C To "z"C If Not keyword. Contains(c) Then cipher.
Append(c) End If Next Return cipher.ToString() End Function.
Thank you for the reply it really helped – K_McCormic Nov 16 at 19:11.
Here is the solution in vb: Public Function words(key As String) As String Dim ret As String ret = key key = key.ToLower() For c As Char = "a"c To "z"c If Not key. Contains(c) Then ret = ret + c. ToString End If Next Return ret End Function If you want to check for unique char for the key, then you can just run a for loop through the characters of the key and remove the current char if already exist.
Remember to move the for loop one char back if you delete the char.
Thanks :) I will try remove the character if they are duplicated – K_McCormic Nov 16 at 19:14.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.