Skip to content
ExamSpine

Lesson 5.3 · Write it

Same word

A functionPython or Java14 tests, 11 of them hidden

On a phone? Put the lines in order instead

Write a function that returns whether two words are the same when upper and lower case are ignored.

  1. Each word contains only English letters, and has at least one letter.
  2. Two words are the same when they have the same letters in the same order. The case of each letter does not matter.
  3. Return True or False (true or false in Java).

Only the value your function returns is checked.

def same_word(first: str, second: str) -> bool

Examples

Your function is tested on 14 cases: the 3 examples below, and 11 hidden ones that check the rules above.

  • same_word("Quit", "qUIT") should return True: the same letters, with capitals in different places (rule 2)
  • same_word("plays", "play") should return False: different words, the second is the start of the first (rule 2)
  • same_word("go", "goes") should return False: different words, the first is the start of the second (rule 2)

public static boolean sameWord(String first, String second)

Checking whether Java answers can run here.

Examples

Your function is tested on 14 cases: the 3 examples below, and 11 hidden ones that check the rules above.

  • sameWord("Quit", "qUIT") should return true: the same letters, with capitals in different places (rule 2)
  • sameWord("plays", "play") should return false: different words, the second is the start of the first (rule 2)
  • sameWord("go", "goes") should return false: different words, the first is the start of the second (rule 2)
solution.pySolution.java