Simple types and strings (2)

You have to program several functions. In each case, few lines of code
are enough. Warning: do not use the split string method.

1.  Write a function @um_count(s)@ that given an string s returns the
    number of times character u is followed by character m in string s.

2.  Write an integer function @word_count(s)@ that returns the number of
    words in string s. We assume all characters of s are letters and
    spaces.

3.  Write a function @kth_word(s, k)@ that given a string s and an
    integer k ≥ 1 returns the $k{\it th}$ word in string s. If s has
    less than k words it returns the empty string. We assume all
    characters of s are letters and spaces.

4.  Write a function @suc_word(s)@ that given a string s and returns the
    first word in string s that has some uppercase letter. If all the
    letters in s are lowercase it returns the empty string. We assume
    all characters of s are letters and spaces.

5.  Write a function @drawA(n)@ that given an odd integer n ≥ 3 prints a
    letter A of size n formed with symbol .

Scoring

Every function counts 20 points.

Sample session

Problem information

Author: Jorge Castro

Generation: 2026-01-25T10:15:04.073Z

© Jutge.org, 2006–2026.
https://jutge.org
