0

Uppercase letters $(A - Z)$ and numbers $(0 - 9)$ are used to generate all possible combinations of strings of length $10$ characters such as $NAH562GTDS$. Assuming that all the possible combinations are generated and sorted in a text file such that the very first string is $0000000000$ and the last one $ZZZZZZZZZZ$, how can we determine the line number in which a string appears?

idriskameni
  • 1,420

1 Answers1

1

Hint. Think to the given string as number written in base $10+26$.

P.S. In this base what is the numerical value of the digits $Y$, $E$ and $S$? Then what is the position of the string $0000000YES$? Show your effort and edit your question with your attempt.

Robert Z
  • 145,942
  • Apologies good sir, but could you please elaborate further with an example? – Stephen Muga Jan 18 '19 at 08:50
  • In this base what is the numerical value of the digits $Y$, $E$ and $S$? Then what is the position of the string $0000000YES$? Show your effort and edit your question with your attempt. – Robert Z Jan 18 '19 at 09:02
  • I have no effort whatsoever. My mind is an enigma that just comes up with these ideas from nowhere. When that happens, I am completely at lost on what to do. This is one of those instances. – Stephen Muga Jan 18 '19 at 09:13
  • This page could be useful: https://simple.wikipedia.org/wiki/Hexadecimal_numeral_system – Robert Z Jan 18 '19 at 09:15
  • Why hexadecimal? That doesn't look like what I'm looking for – Stephen Muga Jan 18 '19 at 09:24
  • Not exactly, but it is the same idea, in your case we have 36 digits instead of 16. – Robert Z Jan 18 '19 at 09:30
  • Okay so the values of Y, E,and S are 34, 14 and 28 respectively. Using an online converter to convert 341428 from base 36 to decimal gives me 188168912. This can't be right, right? – Stephen Muga Jan 18 '19 at 09:54
  • The values for the digits are correct. The number for YES is $3436^2+1436+28=44596$. – Robert Z Jan 18 '19 at 12:40
  • Thank you. I get it now. Indeed, after generating SOME of the combinations, 0000000YES appears at line number 44, 597. I just have to perform a "+1" to your solution. – Stephen Muga Jan 18 '19 at 14:21
  • Yes, you have to shift by $1$ since the number $0$ is at the $1$st position. – Robert Z Jan 18 '19 at 15:29