Question: Write code (In Ruby or Python or JavaScript) to find a 9 letter string of characters that contains only letters from acdegilmnoprstuw such that the

Write code (In Ruby or Python or JavaScript) to find a 9 letter string of characters that contains only letters from

acdegilmnoprstuw

such that the hash(the_string) is

930846109532517

if hash is defined by the following pseudo-code:

Int64 hash (String s) { Int64 h = 7 String letters = "acdegilmnoprstuw" for(Int32 i = 0; i < s.length; i++) { h = (h * 37 + letters.indexOf(s[i])) } return h }

For example, if we were trying to find the 7 letter string where hash(the_string) was 680131659347, the answer would be "leepadg".

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!