Skip to content

Latest commit

 

History

History
 
 

135-word-chain

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Word chain

Challenge Description:

In this challenge, we suggest playing "Word chain" - a well-known game in which players come up with words that begin with the letter that the previous word ended with. Your task is to determine the maximum length of a chain that can be created from a list of words.

Input sample:

Your program should accept a path to a filename as its first argument. Each line of the file contains a list of words separated by comma.

For example:

soup,sugar,peas,rice
ljhqi,nrtxgiu,jdtphez,wosqm
cjz,tojiv,sgxf,awonm,fcv

Output sample:

Print out the length of the longest chain or print out "None" if there is no chain.

For example:

4
None
2

Constraints:

  • The length of a list of words is in a range from 4 to 35.
  • A word in a list is represented by a random lowercase ASCII string with the length from 3 to 7 letters.
  • The words in a list do not repeat.