From 408a709c743ebaa2397bb31dc7cd927cefa4bf6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iida=20Pyykk=C3=B6nen?= <iapyyk@utu.fi> Date: Fri, 17 Jan 2025 16:26:03 +0200 Subject: [PATCH] 15 and 17 --- 15.py | 10 ++++++++++ 17.py | 9 +++++++++ 2 files changed, 19 insertions(+) create mode 100644 15.py create mode 100644 17.py diff --git a/15.py b/15.py new file mode 100644 index 0000000..2389d66 --- /dev/null +++ b/15.py @@ -0,0 +1,10 @@ +# Write a function solve that rotates an n x n matrix 90 degrees clockwise in-place. + +def solve(matrix): + for i in range(int(len(matrix))): + for j in range(i): + matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j] + for list in matrix: + list.reverse() + return matrix + diff --git a/17.py b/17.py new file mode 100644 index 0000000..296da98 --- /dev/null +++ b/17.py @@ -0,0 +1,9 @@ +# Write a function solve that counts the number of vowels (a,e,i,o,u) in a string, ignoring case. + +def solve(string): + counter = 0 + vowels = ["a","e","i","o","u"] + for char in string.lower(): + if char in vowels: + counter += 1 + return counter -- GitLab