All problems
Character Trigram Count
Problem
Character trigrams are all length-3 substrings, including across word boundaries when spaces are preserved.
Given text and n = 3, return the number of trigrams (text length minus two, not below zero).
Hint
A string of length L has L - 2 trigrams when L >= 3.
Test cases
case 1
in: ["abcd"]
expected: 2
case 2
in: ["ab"]
expected: 0
case 3
in: ["hello"]
expected: 3
Starter codePython
def character_trigram_count(text):
# Your code here
pass3 test cases · run your code against them in the editor