3

Is it possible to generate random numbers between say 1000000 and 9999999 that are easy to remember?

I know the term easy to remember is relative but I'd believe that for your typical human being the number 331332 is easier to remember than 537106 (or is it?)

Use case. Am generating unique numbers for people in an application and was thinking I could try and make it easier for the people by assigning them easy numbers. The way I'd play it is that the first people to register get the easy numbers and from there the easiness reduces.

If you've seen the same in any programming language you could post for inspiration to others

There's a similar question here but that was alphanumeric in nature and it was six years ago

Community
  • 1
  • 1
lukik
  • 3,919
  • 6
  • 46
  • 89
  • 2
    Only if they followed some kind of pattern—which would make them non-random by definition. – martineau Dec 09 '16 at 17:07
  • 1
    This is an incredibly broad topic and seems to be two different questions. One is, "What makes a number easy to remember", which is out of scope for SO. It's more than likely a psychology research project. Two is "How do I generate easy to remember numbers", which all depends on that first step. – Morgan Thrapp Dec 09 '16 at 17:08
  • If you assume easy to remember numbers have more repeated digits then you can generate random numbers and count how many digits get repeated and select those with say 4 repeated digits. – Atirag Dec 09 '16 at 17:10
  • Do the identifiers have to be numbers? You could generate random sequences of dictionary words, as seen on sites like gfycat or password generation models like "correct horse battery staple". – user2357112 Dec 09 '16 at 17:15
  • @MorganThrapp My thinking is that this question is similar to `how to compute similarity score between strings` which is quite a common issue and it has a mathematical formula to it which `lay man me` would never have known until I came to SO. – lukik Dec 09 '16 at 17:17
  • 1
    Why not just start with small numbers; these are definitely easier to remember than larger numbers! – Chris_Rands Dec 09 '16 at 17:17
  • @user2357112 unfortunately its numbers only for this particular use case but would welcome pointers to what your referring to – lukik Dec 09 '16 at 17:18
  • user2357112 is referring to https://xkcd.com/936/ which is a popularization of the argument that if we want things that are easy to remember, we should generate things that are easy to remember, rather than going just by mathematical systems that force us to become vulnerable to social engineering attacks. Random numbers themselves are not easy to remember. – Kenny Ostrom Dec 09 '16 at 17:31
  • Define "easy to remember" numbers, write a function to check for it, then generate random numbers in the given range until you find one that meets the criteria. – martineau Dec 09 '16 at 18:08

3 Answers3

3

Here I've found some things which make a number memorable: http://www.slideshare.net/cntryrckr69/what-makes-a-number-memorable

I've implemented it in python based on a few of these things

Here's what the code looks like:

import random

def easynum(num):
    num = str(num)

    if len(set(num)) <= 2: # common characters eg. 1114111
        print("common")
        return True
    if num == num[::-1]: # its the same backwards eg. 1234321
        print("reversible")
        return True
    if all(x <= y for x, y in zip(list(num), list(num)[1:])): # increasing, e.g. 123456789
        print("increasing")
        return True
    if all(x >= y for x, y in zip(list(num), list(num)[1:])): # decreasing
        print("decreasing")
        return True


for count in range(10):
    rand = random.randint(1000000, 9999999)
    while easynum(rand) == None:
        rand = random.randint(1000000, 9999999)
    print(rand)

Here's the output I got:

reversible
5691965
reversible
9585859
increasing
1112557
reversible
9057509
reversible
3831383
decreasing
8322000
increasing
1122356
common
4884484
decreasing
9887320
common
4004040
Tom Fuller
  • 5,291
  • 7
  • 33
  • 42
2

I can think of a few easy to remember patterns:

1234321 (half reversed)
1234567 (in order)
1231231 (repeating)
7654321 (reverse order)
2468024 (even in order)
1357135 (odd in order)
1212121 (alternating)

There are obviously more you can think of. Have a library of different patterns. Randomly select a pattern from the library and then randomly populate that pattern, within the constraints of the pattern. For example, you can only select the starting digit of the 'in order' pattern, the following digits will depend on the starting digit.

rossum
  • 15,344
  • 1
  • 24
  • 38
1

One simple way is to randomly repeat your 0-9 digits different number of times; so making some digits more likely to appear than others.

import random
DIGITS = list(range(10))

def generate_easy_number(length=6):
    multiplier = list(range(10))
    random.shuffle(multiplier)
    repeated_dig = list()
    for i, n in enumerate(DIGITS):
        for _ in range(multiplier[i]):
            repeated_dig.append(n)
    random.shuffle(repeated_dig)
    return ''.join([str(x) for x in repeated_dig[:length]])

print(generate_easy_number())

So have your DIGITS list of 0-10, create another multiplier list which is shuffled, then use its values to indicate how many repetitions (or weight) each digit would have.

Create the final list of duplicated digits, shuffle it and slice it.

Random results:

404092
090417
002657
840818
130610
065644
495060
Alex R.
  • 11
  • 2