61
Programs / Word ladder - Rosetta Code
« on: September 03, 2021, 08:46:12 pm »
ref: http://rosettacode.org/wiki/Word_ladder
Oh this was a little more tricky!
Same unixdict.txt for words attached and screen shot of output.
All original in Basic!
Oh this was a little more tricky!
Code: QB64: [Select]
- _Title "Word ladder - Rosetta Code" 'b+ start 2021-09-03 ref: http://rosettacode.org/wiki/Word_ladder
- Type connectType
- LoadWords 'build the strings for each word length the split them for that length
- Sub LoadWords
- ok = -1
- Close #1
- connect$ = w1$
- newConnect:
- 'progress
- 'Print "Connect word is "; connect$; UBound(wl$); listPlace;
- TheList(1).connect = connect$
- TheList(1).word = wl$(i)
- Else ' add to list only if word isn't a connect
- found = 0
- cAppend TheList(), connect$, wl$(i)
- listPlace = listPlace + 1
- ladder$ = "Could NOT connect " + w1$ + " to " + w2$
- connect$ = TheList(listPlace).word
- GoTo newConnect
- 'should be able to backtrack our path?
- ladder$ = "Could connect " + w1$ + " to " + w2$
- target$ = w2$: trail$ = w2$
- again:
- arrpos = arrpos + 1
- curpos = dpos + LD
Same unixdict.txt for words attached and screen shot of output.
All original in Basic!