# MSX Puzzle of the day - Solve this!

Page 1/4
| 2 | 3 | 4

I've seen, that there are quite a few MSX gurus around here, so I decited to launch a small competition, where you need to use brains as well as programming skils.

Who ever solves the following word puzzle first, will get huge amount of fame and respect. You just need to be first, who sents a reply here with the correct answer.

Here are the rules:

- The word, that I search is written all in lower case
- It is english word
- The ASCII checksum of the word is 524

and here comes the nasty one:

- If you type in BASIC:

... you can login to your MSX using this word as password!

Happy hunting!

I deduce the word has 5 characters.

Is it... "brain"?

really professional cheating, manuel
(live on #msxdev ^_^)

<wouter_> it's not cheating at all, just beiing smart

This is how I did it:

- ASCII a=97, ASCII z=122. Divide 524 by 97 and 122 and you know the amount of characters is between about 4.29 and 5.4 characters, i.e. 5
- use a Perl script to generate all combinations of characters that sum up to 524:
for (my \$i=0; \$i<26; \$i++)
{
for (my \$j=0; \$j<26; \$j++)
{
for (my \$k=0; \$k<26; \$k++)
{
for (my \$l=0; \$l<26; \$l++)
{
for (my \$m=0; \$m<26; \$m++)
{
if ((\$i+\$j+\$k+\$l+\$m+(5*97)) == 524 )
{
print chr(\$i+97).chr(\$j+97).chr(\$k+97).chr(\$l+97).chr(\$m+97)."\n";
}
}
}
}
}
}
and output the results to crack.txt:
perl crack.pl > crack.txt
- compare the 111510 candidates with a list of english words:
cat american-english crack.txt | sort | uniq -d
The list comes from a Linux dictionary program and the result is only 64 words
- Try all 64 words.

Thanks for the very nice puzzle, NYYRIKKI! Please explain us the hashing algo now

Thanks by the way to Patriek for giving the 5-letters idea and Wouter for helping me remember the filtering trick with sort and uniq and providing me with the word list, which is somehow not installed on my own Linux box.

Is it... "brain"?

Yes, we have a winner That was fast, only 1.5h !

Thanks for the very nice puzzle, NYYRIKKI! Please explain us the hashing algo now

Well, I let someone else to explain, but below is the hash program, that I used. I think, that you tested the possibilitys by hand, but you could have searched the algorithm from your MSX.

Few tips to do that: Password is MSX2 feature, so look from SUB-ROM. You can see text "Password:" when you enter one. That is good string to search. When you find the code, disassemble it. If you have SUPER-X this is not hard.

Anyway... here is the ready to compile program for BASIC:

```	DEFB #FE
DEFW BEGIN
DEFW END
DEFW START

ORG #C000

USR0:	EQU #F39A
USR:	EQU #F7F8
VALTYP:	EQU #F663

BEGIN:
START:
LD HL,CODE
LD (USR0),HL
RET

CODE:
LD	A,(VALTYP)
CP	2
LD	HL,(USR)
LD	A,(HL)
INC	HL
JR	Z,XBASIC	; USR(VARPTR(X\$)) in XBASIC
LD	E,(HL)	; USR(X\$) in BASIC
INC	HL
LD	D,(HL)
EX	DE,HL
XBASIC:
CALL	HASH
LD	A,2
LD	(VALTYP),A
LD	(USR),DE
RET

HASH:
LD	DE,0000H
LD	C,A
OR	A
RET	Z
SCF
X2E08H:	PUSH	AF
X2E09H:	LD	B,08H
X2E0BH:	POP	AF
PUSH	AF
JR	NC,X2E11H
RLC	(HL)
X2E11H:	RL	E
RL	D
JR	NC,X2E1FH
LD	A,D
XOR	80H
LD	D,A
LD	A,E
XOR	05H
LD	E,A
X2E1FH:	DJNZ	X2E0BH
INC	HL
DEC	C
JR	NZ,X2E09H
POP	AF
RET	NC
OR	A
LD	C,02H
JR	X2E08H

END:
```

There are plenty of these kind of pairs, here are few of them:

PIPE, SIZE
PUSH, SWEET
TAX, WAR
same, page
WHIP, peace
person, where

I used word list, that contains only 850 basic english words in uppercase and lowercase, but you propably can find plenty of more funny pairs.

Maybe next competition could be, who finds most fun MSX password pair.

Dammit... I'm now spamming an online English dictionary with connections

I did it in a similar way as Manuel, but then instead of compare them with words in an existing list, I tried to figure wether a specific word exists using this URL. Well, 2bad Manuel got the word in the first place... after 83 minutes my script found this list:
aares
abhor
aldol
allen
amati
anted
areas
asian
bairn
baldy

and well, brain wasn't just there after 83 minutes :|

Actually, I could have done it much faster... Writing the script took only about 5 minutes, running everything took less than 10 seconds. If you like I can send you the full list of words (64), but I haven't checked for all words if they would be accepted. I stopped when I found 'brain'. It's possible that more would 'fit', but maybe someone who understands the above ML program can check whether there's more of those 64 that would do the trick. (Or check by hand

Manuel, I can help you to check rest of the words. Here is program, that goes trough your list:

```10 defint a-z
20 bload"passwd.bin",r ´ Program from previous post
30 a=usr("produce")
40 open "list64.txt" for input as #1
50 if eof(1) then end
60 lineinput #1,a\$
70 if a=usr(a\$) then print a\$
80 goto 50
```
Page 1/4
| 2 | 3 | 4