0

I have the numbers 0-8 so I can represent a state as
012345678
012345687
....
876543201
876543210
This gives me 40320 ways to represent a state so I have a HashMap of size 40320 and I need a good way to make sure each state only corresponds to 1 key 1-40320

I'm not really sure how to even come close to making sure there are no possible collisions. Any help would be greatly appreciated

3
Contributors
2
Replies
17
Views
4 Years
Discussion Span
Last Post by bguild
0

first of all determine the value of the first state you want to represent. in this case
the first state becomes index 0 and next index 1 and so on. now write a function that
takes a value and compute it index or better still find a constant such that when
you divid or subtract the content from the valued u will get it index

1

I suspect you may be making a mistake about 40320. It looks like you have to account for every permutation of 9 digits, which means 362880 permutations, not 40320, and of course it is hopeless to try to number every state distinctly with 40320 numbers if there are 362880 states. 40320 states are what you would have if your digits were 0-7.

Edited by bguild

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.