Skip to content

Commit 216bfca

Browse files
committed
feat(codeforces): simple solutions
1 parent aff9533 commit 216bfca

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

services/codeforces/problemset/4A-watermelon/README.md

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
n = int(input())
2+
if n > 2 and n % 2 == 0:
3+
print("YES")
4+
else:
5+
print("NO")
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# A. Way Too Long Words
2+
3+
time limit per test
4+
1 second
5+
memory limit per test
6+
256 megabytes
7+
8+
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.
9+
10+
Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.
11+
12+
This abbreviation is made like this: we write down the first and the last letter of a word and between them we write the number of letters between the first and the last letters. That number is in decimal system and doesn't contain any leading zeroes.
13+
14+
Thus, "localization" will be spelt as "l10n", and "internationalization» will be spelt as "i18n".
15+
16+
You are suggested to automatize the process of changing the words with abbreviations. At that all too long words should be replaced by the abbreviation and the words that are not too long should not undergo any changes.
17+
Input
18+
19+
The first line contains an integer n (1 ≤ n ≤ 100). Each of the following n lines contains one word. All the words consist of lowercase Latin letters and possess the lengths of from 1 to 100 characters.
20+
Output
21+
22+
Print n lines. The i-th line should contain the result of replacing of the i-th word from the input data.
23+
24+
[Problem link](https://codeforces.com/problemset/problem/71/A?locale=en)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
n = int(input())
2+
words = [input() for _ in range(n)]
3+
4+
for word in words:
5+
word_len = len(word)
6+
if word_len > 10:
7+
print(f"{word[0]}{word_len-2}{word[-1]}")
8+
else:
9+
print(word)

0 commit comments

Comments
 (0)