Problem of the Day
A new programming or logic puzzle every Mon-Fri

Combo Word

What a glorious Monday it is!

Today's goal is to create a function that takes in a word (no spaces or dashes) and determines if that word is created from two or more smaller words. For instance the word "newspaper" is a combination of "news" and "paper". All smaller words must contain at least 2 letters, thus all words passed to this function must be 4 characters or more. Here is an English dictionary to get you started. Feel free to use any language dictionary you want though.



  • Anonymous - 9¬†years, 1¬†month ago

    inputword = raw_input("Enter a word> ")
    p = len(inputword)
    wordlist = []
    file = open('WordsEn.txt', 'r')
    for line in file:
        if len(line) <= p+2:
    pointer = 2
    combo = []
    while pointer <= (p - 2):
        a = inputword[0:pointer]
        b = inputword[pointer:p]
        if a in wordlist:
            if b in wordlist:
        pointer = pointer + 1
    print combo

    Output: $ python Enter a word> crossword [['cros', 'sword'], ['cross', 'word']]

    reply permalink

Content curated by @MaxBurstein