Help developing a hash function to detect duplicate entries?

Let me explain my program so far. This is a cubic rubik. I am given a scrambled cube (this is the initial state). This becomes the root of the graph node. I use iterative deepening depth first searchto “enumerate” this scrambled cube into a recognizable state, which I can then use pattern recognition to solve.

As you can imagine, this is a very large graph, so I would like to offer some hashing function to detect duplicate nodes in this graph (thereby speeding up the crawl).

Basically, I am not familiar with hashing functions, but here's what I think ... Each node is, in fact, a different state of the rubik cube. Therefore, if I came to the state of a cube (node), which was already visible, I want to skip it. So I need a hash function that takes me from the state variable to the checksum, where the state variable is a 54-character string. Only valid characters y, r, g, o, b, w(which match colors).

Any help in developing this hash function is appreciated.

+3
source share
5 answers

- . , , . , , , F B, FB, BF, . 3F, F. , .

, . , , , , . 12 , 8 . , 100 (12,5 ). . 2 . , . 12 .

70 rubik, 96 - 70, . . , , , . 12 , , , , . , . MD5 .

, , . http://cube20.org/ .

+2

-. ( , , ), -. MD4, . 54- MD4 (MD4 55 ).

2,4 12 , , C (, , MD4Transform() , RFC 1320), .

+2

1) 9*6 = 54 rubik. 1 , 432 , . 3 162 (21 ). , rubik.

OTOH, , , ( ) .

2) : MD5, , , - , , - rubik; -).

EDIT: -, MD4/MD5, , , (, OpenSSL, GNU TLS ). void md5(unsigned char *buf, size_t len, unsigned char *digest), digest 16- , buf - , ( rubik). C:

#include <openssl/md5.h>
void main()
{
    unsigned char digest[16];
    unsigned char buf[BUFLEN];
    initializeBuffer(buf);
    MD5(buf,BUFLEN,digest);    // This is the openssl function
    printDigest(digest);
}

/ -lssl.

+2

, - Rubik 4.3*10^19. Log 2 (4.3 * 10 ^ 19) , , 66. , , 66 .

, , , , . - 12 4- , 8 3- 6 3- . 90 .

, , , .

+1

8 :

  • 8 , 3 , , 24 .
  • , 7-8, , , 8- ( 21 ).
  • , 8 8! = 40320, 40320 16 .

120 ° , ( 0, 1 2 ).

  • 2 .
  • ( 3) 0; , 7- , ( ), 8- ( 14 ).
  • ( 3) , 12 ().

, 28 , 33 , 7- .

12 :

  • 4 ( 48 ), 44 , 11- 12 ( 44 ).
  • 12! = 479001600 29 .

, :

  • 1 .
  • , , ( , , 11- 12 ), 11 .

, 40 , 55 , 11--12 .

6

- - (, - ), .

  • : 68
  • : 88
+1
source

Source: https://habr.com/ru/post/1778161/


All Articles