Write a functon split(s) that splits a string s into words separated by one or more spaces, and returns a list of these words. Do not use the built-in method of the same name.
Write a program that reads a matrix of integers and rotates it to the right.
Input:
2 4 6 8 8 6 4 2 1 3 7 9 9 7 3 1
Output:
9 1 8 2 7 3 6 4 3 7 4 6 1 9 2 8
Write a function cycle
that takes a list of length N
representing a permutation of the integers 0, …, N – 1. The
function should return True
if the permutation is a single cycle. For example:
cycle([2, 3, 1, 0]) is True
because the
permutation
0 -> 2
1 ->
3
2 -> 1
3 -> 0
is a cycle (0 ->
2 -> 1 -> 3 -> 0)
cycle([2, 3, 0, 1]) is False
because the
permutaion
0 -> 2
1 -> 3
2 -> 0
3
-> 1
is not a cycle (0 -> 2 -> 0, 1 -> 3 ->
1)
Write a program that reads text until the end of input is reached, and prints out the most common word in the input text.
Write a program that reads a string and print out the five most common characters in the string along with their occurrence counts, e.g.
e 23 t 20 o 18 n 15 i 14
Write the characters in decreasing order of frequency. The string may contain any Unicode characters.
Write a function that
takes a dictionary such as { 'green' : 'zelený', 'red'
: 'červený' }
and
returns a corresponding dictionary in which the keys and values have
been flipped, e.g. { 'zelený' : 'green', 'červený' :
'red'}
.