Problem # 2 : Chains of words
A word-chain is a sequence of words in which every word starts with the last character of the previous word. So CSI INTERNET TV VETO OM is a word-chain
Given an array of words find out whether a word-chain can be made using all the words.
Write a function WORDCHAIN(N A$()) where N is the number of words and A$() the array containing these words. The function returns -1 (true) if a wordchain can be made using all the words and 0 (false) otherwise
Sample Output
N=5
A$() contains "AND"
"FIXING"
"GIGA'
"GONE'
"EGG'
in elements 1
2
3
4
and 5 respectively
WORDCHAIN(N
A$()) returns -1
N=3
A$() contains "ROOM"
"RUN"
"MAN"
in elements 1
2 and 3 respectively
WORDCHAIN(N
A$()) returns 0
![]() |