Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. String Factorial??

String Factorial??

Scheduled Pinned Locked Moved C / C++ / MFC
databasealgorithmscryptographyquestion
3 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Paul Farry
    wrote on last edited by
    #1

    I'm trying to come up with an algorithm which will generate a readable hash index for use in a project. The string I can play with is "ABCDE". The aim is to generate the smallest number of characters to represent each unique display of those characters. Like this "A" "B" "C" "D" "E" "AA" ... "AE" "BA" .. "BE" .. "EE" "AAA" ... "EEE" etc. I just can't seem to get it.. Any clues or the name of this particular programming challenge appreciated.

    D W 2 Replies Last reply
    0
    • P Paul Farry

      I'm trying to come up with an algorithm which will generate a readable hash index for use in a project. The string I can play with is "ABCDE". The aim is to generate the smallest number of characters to represent each unique display of those characters. Like this "A" "B" "C" "D" "E" "AA" ... "AE" "BA" .. "BE" .. "EE" "AAA" ... "EEE" etc. I just can't seem to get it.. Any clues or the name of this particular programming challenge appreciated.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Kinda cheesy but here's one way:

      CStringArray arr;
      CString str;

      for (char l1 = 'A'; l1 <= 'E'; l1++)
      {
      str = l1;
      arr.Add(str);
      }

      for (l1 = 'A'; l1 <= 'E'; l1++)
      {
      for (char l2 = 'A'; l2 <= 'E'; l2++)
      {
      str = l1 + l2;
      arr.Add(str);
      }
      }

      for (l1 = 'A'; l1 <= 'E'; l1++)
      {
      for (char l2 = 'A'; l2 <= 'E'; l2++)
      {
      for (char l3 = 'A'; l3 <= 'E'; l3++)
      {
      str = l1 + l2 + l3;
      arr.Add(str);
      }
      }
      }

      for (l1 = 'A'; l1 <= 'E'; l1++)
      {
      for (char l2 = 'A'; l2 <= 'E'; l2++)
      {
      for (char l3 = 'A'; l3 <= 'E'; l3++)
      {
      for (char l4 = 'A'; l4 <= 'E'; l4++)
      {
      str = l1 + l2 + l3 + l4;
      arr.Add(str);
      }
      }
      }
      }

      for (l1 = 'A'; l1 <= 'E'; l1++)
      {
      for (char l2 = 'A'; l2 <= 'E'; l2++)
      {
      for (char l3 = 'A'; l3 <= 'E'; l3++)
      {
      for (char l4 = 'A'; l4 <= 'E'; l4++)
      {
      for (char l5 = 'A'; l5 <= 'E'; l5++)
      {
      str = l1 + l2 + l3 + l4 + l5;
      arr.Add(str);
      }
      }
      }
      }
      }

      I believe that yields 3,905 (51 + 52 + 53 + 54 + 55) combinations.

      1 Reply Last reply
      0
      • P Paul Farry

        I'm trying to come up with an algorithm which will generate a readable hash index for use in a project. The string I can play with is "ABCDE". The aim is to generate the smallest number of characters to represent each unique display of those characters. Like this "A" "B" "C" "D" "E" "AA" ... "AE" "BA" .. "BE" .. "EE" "AAA" ... "EEE" etc. I just can't seem to get it.. Any clues or the name of this particular programming challenge appreciated.

        W Offline
        W Offline
        wb
        wrote on last edited by
        #3

        may you describe it a bit more? but... if you create a "normal" hashkey which is suitable for the hashspace, and then transform it to ASCII? LOWELL = 76 79 87 69 76 76 -> S = 7679 + 8769 + 7676 = 24124 your hashspace is 19937 (should be prime) 24124 % 19937 = 4187 and now put it to ASCII 41 and 87 :confused:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups