0
\$\begingroup\$

Your challenge is to create a simple Check-Digit algorithm.

Inputs:

  1. Dictionary - set of unique characters, for example "ABCDEF")
  2. Length - integer
  3. Input digit - this is what we are calculating the CheckDigit for -it will also be an integer.

Examples:

  • Dictionary:"A", Length:2, Input->Output: (input)1->(output)AA, 2->AA, 3->AA, ...
  • Dictionary:"AB", Length:1, Input->Output: 1->B, 2->B, 3->A, ...
  • Dictionary:"ABCDEF", Length:3, Input->Output: 1->FAD, 2->EEB, 3->CDC, ...

In other words for a consecutive inputs i.e 1,2,3,4... the outputs should be something like "AB", "CA", "BD", "DD"... the trick is NOT to have obvious pattern in the output for pattern-based input.

Rules:

  • Consecutive input shouldn't generate trivially consecutive output, for example:

    1->AA, 2->AB, 3->AC, 4->AD, 5->AE, ...

  • Cryptographic functions are not allowed.

I can see some confusion. What I'm after is a function - let's call is a checkdigit(string dict, int length, int input) which give me the following output:

  • checkdigit("ABC",2,1) //outputs:"BC" - length is 2, values in output from Dictionary passed
  • checkdigit("ABC", 2, 2) //outputs:"AA"
  • checkdigit("ABC", 2, 3) //outputs:"BA"
  • checkdigit("ABC", 2, 4) //outputs:"CC"
  • checkdigit("ABC", 2, 5) //outputs:"AA"
  • checkdigit("ABC", 2, 6) //outputs:"AA"

(Collisions should be possible) The trick is NOT to have a pattern in the output for pattern-based input

\$\endgroup\$

closed as unclear what you're asking by Luis felipe De jesus Munoz, Kevin Cruijssen, AdmBorkBork, Mr. Xcoder, Quintec Jan 11 at 14:37

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    \$\begingroup\$ What exactly does that “3. Input digit - this will be also an integer”? \$\endgroup\$ – manatwork Jan 11 at 14:11
  • \$\begingroup\$ This is an input which we will calculate a check digit for \$\endgroup\$ – Katie Jan 11 at 14:23
  • \$\begingroup\$ Hi and welcome to PPCG! I've voted to close this question as unclear, because I don't understand how the input relates to the output. Can you walk through a specific example? \$\endgroup\$ – AdmBorkBork Jan 11 at 14:26
  • \$\begingroup\$ Given a dictionay:"ABCD", Length:2, for consecutive inputs i.e 1,2,3,4... the outputs should be something like "AB", "CA", "BD", "DD"... the trick is not to have a pattern in the output for pattern-based input \$\endgroup\$ – Katie Jan 11 at 14:29
  • \$\begingroup\$ I'm not sure I follow, although I think I partially understand.. Do you mean that all possible permutations of size length will be put in a list based on the dictionary-characters. So for example: dictionary "ABCD", length: 2 will give the map ["CA","AB","CD","DA","AC","CC","BA","DC","CB","AA","BC","BD","DB","AD","DD","BB"]. But where is the third input used? Do we use it to index into this list, so if the third input is 4, we return the "DA" of the list I mentioned? And how do we define 'trivially consecutive' / 'obvious pattern'? Could I reverse the list? Rotate it once? \$\endgroup\$ – Kevin Cruijssen Jan 11 at 14:33