about | help | code help+videos | done | prefs |
Write a function difference(word1, word2) that returns the first index at which the strings word1 and word2 differ. If the words have different lengths, and the shorter word is a prefix of the longer word, the function should return the length of the shorter word. If the two words are the same, the function should return −1. Do this without directly testing whether word1 and word2 are equal. difference('words', 'wordiness') → 4 difference('notice: capiTalization matters', 'notice: capital') → 12 difference('c0c0nuts7', 'cOcOnuts8') → 1 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy