Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6acf4b265a | ||
![]() |
28db16fa1d | ||
![]() |
250d742548 | ||
![]() |
4648b0262c | ||
![]() |
78fc989a52 | ||
![]() |
b9e7856760 | ||
![]() |
dfc8e0de39 | ||
![]() |
b519e4ce13 | ||
![]() |
ef7a470ae5 | ||
![]() |
8b27cc30c1 | ||
![]() |
8bb69f7cf5 | ||
![]() |
adab123343 | ||
![]() |
5c4e00956d | ||
![]() |
417d2efa32 | ||
025bbead96 | |||
5417f67adf | |||
5dbcfb00b3 | |||
8aff6e794b | |||
402fe81d33 | |||
![]() |
5f61213d21 | ||
![]() |
e3b4150554 | ||
![]() |
a5ec559880 | ||
58e8d6c4ad | |||
cd74f9ca4c | |||
1204013bed | |||
a4bf772414 |
106
TaskA01/shakespeare.out
Normal file
106
TaskA01/shakespeare.out
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
CLAUDIUS, King of Denmark, Hamlet’s uncle.
|
||||||
|
The GHOST of the late king, Hamlet’s father.
|
||||||
|
GERTRUDE, the Queen, Hamlet’s mother, now wife of Claudius.
|
||||||
|
HORATIO, Friend to Hamlet.
|
||||||
|
Dar’d to the combat; in which our valiant Hamlet,
|
||||||
|
His fell to Hamlet. Now, sir, young Fortinbras,
|
||||||
|
Unto young Hamlet; for upon my life,
|
||||||
|
Enter Claudius King of Denmark, Gertrude the Queen, Hamlet, Polonius,
|
||||||
|
Though yet of Hamlet our dear brother’s death
|
||||||
|
But now, my cousin Hamlet, and my son—
|
||||||
|
Good Hamlet, cast thy nighted colour off,
|
||||||
|
’Tis sweet and commendable in your nature, Hamlet,
|
||||||
|
Let not thy mother lose her prayers, Hamlet.
|
||||||
|
This gentle and unforc’d accord of Hamlet
|
||||||
|
[_Exeunt all but Hamlet._]
|
||||||
|
For Hamlet, and the trifling of his favour,
|
||||||
|
So please you, something touching the Lord Hamlet.
|
||||||
|
Than a command to parley. For Lord Hamlet,
|
||||||
|
As to give words or talk with the Lord Hamlet.
|
||||||
|
Enter Hamlet, Horatio and Marcellus.
|
||||||
|
That I will speak to thee. I’ll call thee Hamlet,
|
||||||
|
[_Ghost beckons Hamlet._]
|
||||||
|
[_Exeunt Ghost and Hamlet._]
|
||||||
|
Enter Ghost and Hamlet.
|
||||||
|
Wouldst thou not stir in this. Now, Hamlet, hear.
|
||||||
|
O Hamlet, what a falling off was there,
|
||||||
|
Adieu, adieu, adieu. Hamlet, remember me.
|
||||||
|
[_Within._] Lord Hamlet.
|
||||||
|
And what so poor a man as Hamlet is
|
||||||
|
Lord Hamlet, with his doublet all unbrac’d,
|
||||||
|
Of Hamlet’s transformation; so I call it,
|
||||||
|
And bring these gentlemen where Hamlet is.
|
||||||
|
The very cause of Hamlet’s lunacy.
|
||||||
|
Came this from Hamlet to her?
|
||||||
|
‘Lord Hamlet is a prince, out of thy star.
|
||||||
|
Enter Hamlet, reading.
|
||||||
|
How does my good Lord Hamlet?
|
||||||
|
You go to seek the Lord Hamlet; there he is.
|
||||||
|
For we have closely sent for Hamlet hither,
|
||||||
|
Of Hamlet’s wildness: so shall I hope your virtues
|
||||||
|
Enter Hamlet.
|
||||||
|
You need not tell us what Lord Hamlet said,
|
||||||
|
Enter Hamlet and certain Players.
|
||||||
|
How fares our cousin Hamlet?
|
||||||
|
I have nothing with this answer, Hamlet; these words are not mine.
|
||||||
|
Come hither, my dear Hamlet, sit by me.
|
||||||
|
[_Exeunt all but Hamlet and Horatio._]
|
||||||
|
[_Exeunt all but Hamlet._]
|
||||||
|
Enter Hamlet.
|
||||||
|
Enter Hamlet.
|
||||||
|
Hamlet, thou hast thy father much offended.
|
||||||
|
Why, how now, Hamlet?
|
||||||
|
O Hamlet, speak no more.
|
||||||
|
No more, sweet Hamlet.
|
||||||
|
Speak to her, Hamlet.
|
||||||
|
O Hamlet, thou hast cleft my heart in twain.
|
||||||
|
[_Exit Hamlet dragging out Polonius._]
|
||||||
|
What, Gertrude? How does Hamlet?
|
||||||
|
Hamlet in madness hath Polonius slain,
|
||||||
|
Enter Hamlet.
|
||||||
|
[_Within._] Hamlet! Lord Hamlet!
|
||||||
|
What noise? Who calls on Hamlet? O, here they come.
|
||||||
|
Enter Hamlet and Guildenstern.
|
||||||
|
Now, Hamlet, where’s Polonius?
|
||||||
|
Hamlet, this deed, for thine especial safety,—
|
||||||
|
Ay, Hamlet.
|
||||||
|
Thy loving father, Hamlet.
|
||||||
|
The present death of Hamlet. Do it, England;
|
||||||
|
Enter Hamlet, Rosencrantz, Guildenstern &c.
|
||||||
|
[_Exeunt all but Hamlet._]
|
||||||
|
I should be greeted, if not from Lord Hamlet.
|
||||||
|
Letters, my lord, from Hamlet.
|
||||||
|
From Hamlet! Who brought them?
|
||||||
|
’Tis Hamlet’s character. ’Naked!’
|
||||||
|
And that in Hamlet’s hearing, for a quality
|
||||||
|
Did Hamlet so envenom with his envy
|
||||||
|
Hamlet comes back: what would you undertake
|
||||||
|
Hamlet return’d shall know you are come home:
|
||||||
|
Enter Hamlet and Horatio, at a distance.
|
||||||
|
Hamlet o’ercame Fortinbras.
|
||||||
|
that young Hamlet was born,—he that is mad, and sent into England.
|
||||||
|
I hop’d thou shouldst have been my Hamlet’s wife;
|
||||||
|
Hamlet the Dane.
|
||||||
|
Hamlet! Hamlet!
|
||||||
|
Enter Hamlet and Horatio.
|
||||||
|
[_Hamlet moves him to put on his hat._]
|
||||||
|
Come, Hamlet, come, and take this hand from me.
|
||||||
|
[_The King puts Laertes’s hand into Hamlet’s._]
|
||||||
|
Was’t Hamlet wrong’d Laertes? Never Hamlet.
|
||||||
|
If Hamlet from himself be ta’en away,
|
||||||
|
Then Hamlet does it not, Hamlet denies it.
|
||||||
|
Hamlet is of the faction that is wrong’d;
|
||||||
|
His madness is poor Hamlet’s enemy.
|
||||||
|
Give them the foils, young Osric. Cousin Hamlet,
|
||||||
|
If Hamlet give the first or second hit,
|
||||||
|
The King shall drink to Hamlet’s better breath,
|
||||||
|
‘Now the King drinks to Hamlet.’ Come, begin.
|
||||||
|
Stay, give me drink. Hamlet, this pearl is thine;
|
||||||
|
Here, Hamlet, take my napkin, rub thy brows.
|
||||||
|
The Queen carouses to thy fortune, Hamlet.
|
||||||
|
[_Laertes wounds Hamlet; then, in scuffling, they change rapiers, and
|
||||||
|
Hamlet wounds Laertes._]
|
||||||
|
No, no, the drink, the drink! O my dear Hamlet!
|
||||||
|
It is here, Hamlet. Hamlet, thou art slain.
|
||||||
|
Exchange forgiveness with me, noble Hamlet.
|
||||||
|
Bear Hamlet like a soldier to the stage,
|
17
TaskA01/shakespeare.py
Normal file
17
TaskA01/shakespeare.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
def solve(lines):
|
||||||
|
return [l for l in lines if "Hamlet" in l]
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
lines = []
|
||||||
|
|
||||||
|
fp = sys.argv[1]
|
||||||
|
assert(fp == "shakespeare.in") # just a sanity check
|
||||||
|
|
||||||
|
print(fp)
|
||||||
|
with open(fp, encoding="utf-8") as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
sol = solve(lines)
|
||||||
|
with open("./shakespeare.out", 'w', encoding="utf-8") as f:
|
||||||
|
f.writelines(sol)
|
13
TaskA02/polish_wiki_excerpt.out
Normal file
13
TaskA02/polish_wiki_excerpt.out
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Pies ten pochodzi z południowych Chin, z terenów prowincji Guangdong. Został rozpropagowany i hodowany w celach wystawowych przez hodowców w USA. Nazwa psa, pochodząca z chińskiego "shā pí" (沙皮), oznacza dosłownie "piaszczysta skóra".
|
||||||
|
Chart polski – polska rasa psa myśliwskiego, znana prawdopodobnie od czasów Galla Anonima, zaliczana do grupy chartów. Dawniej użytkowana była przede wszystkim do polowań, obecnie jako pies reprezentacyjny.
|
||||||
|
Smukły pies o wąskim pysku. Chart polski jest wyraźnie mocniejszy i nie tak finezyjny w kształtach jak inne charty. Jest najwyższą z polskich ras.
|
||||||
|
Chart polski to pies silny, wytrzymały, o dobrze zbalansowanym ciele i proporcjach (wpisany jest w prostokąt oparty na dłuższym boku) pozwalających nie tylko na szybki galop, ale i na pokonywanie dużych odległości wyciągniętym kłusem. Jest psem o okrywie włosowej dobrze chroniącej go przed zimnem, wilgocią i wiatrem.
|
||||||
|
Pies wymagający sporej dawki codziennego ruchu, stąd jest idealnym towarzyszem dla ludzi uprawiających jeździectwo lub jogging.
|
||||||
|
W filmie występuje pies rasy landseer.
|
||||||
|
Bohaterami anime jest grupa łowców nagród, podróżująca statkiem kosmicznym o nazwie "Bebop": Spike Spiegel, Faye Valentine, Jet Black, haker Ed oraz genetycznie zmodyfikowany pies Ein.
|
||||||
|
Tytułowym głównym bohaterem serii jest Lucky Luke - kowboj, najszybszy rewolwerowiec na Dzikim Zachodzie i najgorszy koszmar braci Dalton. Zawsze, gdy planują oni skok na bank lub inne przestępstwo, dzielny stróż prawa staje im na drodze. W jego przygodach towarzyszą mu inteligentny koń Jolly Jumper i pies Bzik (we francuskojęzycznym oryginale: "Rantanplan").
|
||||||
|
Serial w krzywym zwierciadle przedstawia życie typowej amerykańskiej rodziny. Jej głową i jedynym żywicielem jest wiecznie sfrustrowany sprzedawca butów, Al Bundy. Kocha swojego starego dodge'a, wolny czas spędza siedząc na kanapie, oglądając telewizję i pijąc piwo lub na posiedzeniach w toalecie. Jego małżonką jest Peggy, która całymi dniami przesiaduje przed telewizorem, oglądając "The Oprah Winfrey Show", i The Phil Donahue Show zajadając się popcornem i czekoladkami, paląc przy tym papierosa za papierosem. O jej podejściu do typowo domowych zajęć świadczą zadawane przez nią pytania, np. o odkurzacz – "Jak się nazywa to coś, co ciągniesz po dywanie, a ono buczy?" Tytułowymi dziećmi są nastoletni Bud oraz Kelly, którzy nie przepadają za sobą i nie przepuszczą żadnej okazji, aby sobie dokuczyć czy donieść na siebie. Kelly i Bud dojrzewają w trakcie trwania serialu, przez co trochę się zmieniają: Bud z wrednego kilkunastolatka przeistacza się w nastoletniego macho, którego nie chce żadna dziewczyna, a Kelly z każdą serią staje się coraz mniej inteligentna. Wiecznie niedocenianym członkiem rodziny jest pies Buck, który jednak żyje swoim życiem i sam troszczy się o siebie. W trakcie wszystkich dziesięciu lat trwania serialu Bundym towarzyszy dwójka sąsiadów: Marcy, najpierw ze swoim pierwszym mężem, Steve'em Rhoadesem, a następnie z Jeffersonem d'Arcym. Marcy lubi przebywać z Peggy, jest za to na bakier z Alem, natomiast Al utrzymuje dobre stosunki z mężami Marcy, szczególnie Jeffersonem – Steve raczej nie darzył Bundych tak bezwzględną sympatią.
|
||||||
|
Buck (prawdziwe imię Michael; trener Steven Ritt) to pies rodziny Bundych, Briard. Głosu użycza mu Kevin Curran, a w odcinkach specjalnych Cheech Marin. Zdechł w wieku dwunastu lat (w 1996 roku Michael przeszedł na emeryturę, zdechł dziewięć miesięcy po tym, jak Bucka uśmiercono w serialu).
|
||||||
|
Lucky to drugi pies rodziny Bundych, spaniel, reinkarnacja Bucka.
|
||||||
|
20 stycznia 1974 r. o godz. 10.40 w Dolinie Mięguszowieckiej wydarzyła się największa jak do owej pory katastrofa lawinowa w Tatrach. Żlebem spod Przełęczy nad Skokiem w Grani Baszt zeszła potężna lawina, która przewaliła się przez Mięguszowiecki Potok i wdarła 140 m na przeciwległy stok, wspinając się na niego z rozpędu aż 44 m w górę. Na stoku tym, na śnieżnym pólku trenowali z instruktorem uczestnicy kursu narciarskiego ze słowackiego Technikum Budowlanego. Lawina przysypała 24 z nich. Dzięki błyskawicznej akcji ratunkowej (było to tylko 400 m od schroniska nad Popradzkim Stawem) udało się odgrzebać spod śniegu 11 płycej przywalonych. W ciągu następnych godzin i kilku dni liczne zespoły ratunkowe (z pomocą przyszło również wojsko) odgrzebały ciała 10 uczestników kursu; wśród nich nauczyciela z 12-letnim synem. Pies wskazał miejsce, gdzie po 5 godzinach od zejścia lawiny wydobyto żywego 18-latka przywalonego metrową warstwą śniegu. Ciała dwóch uczniów udało się znaleźć dopiero wiosną po stopieniu się śniegu.
|
||||||
|
Początkowo Morris wykorzystał w swoich komiksach historycznych braci Daltonów Grat, Bill i Emmett, których przedstawił jako bardzo groźnych i inteligentnych przestępców. Niestety po pierwszym spotkaniu z Lucky Luke, zostali aresztowani i skazani w więzieniu na śmierć. Morris żałował potem swojej decyzji i wraz z Gościnnym wprowadził na ich miejsce, czwórkę kuzynów (także) Daltonów – Joe, Williama, Jacka i Averelle, którzy byli przeciwieństwem swoich kuzynów. Wiecznie pechowi, gamoniowaci i niezbyt inteligentni. Wkrótce stali się oni najpopularniejszymi postaciami w serii, zaraz po samym Lucky Luke i z czasem dołączył do nich pies Rantanplan. Doczekali się także solowego filmu dystrybuowanego w Polsce pt. "Lucky Luke" (oryg. "Les Dalton").
|
15
TaskA02/solution.py
Normal file
15
TaskA02/solution.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
# return if the sentence contains word pies
|
||||||
|
def solve(lines):
|
||||||
|
return [l for l in lines if "pies" in l.lower().split(" ")]
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
lines = []
|
||||||
|
|
||||||
|
fp = sys.argv[1]
|
||||||
|
with open(fp, encoding="utf-8") as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
sol = solve(lines)
|
||||||
|
with open("./polish_wiki_excerpt.out", 'w', encoding="utf-8") as f:
|
||||||
|
f.writelines(sol)
|
951
TaskA03/polish_wiki_excerpt.out
Normal file
951
TaskA03/polish_wiki_excerpt.out
Normal file
File diff suppressed because one or more lines are too long
35
TaskA03/solution.py
Normal file
35
TaskA03/solution.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
# '19xx' literally would be accepted as well but we won't tell anyone
|
||||||
|
def solve(lines):
|
||||||
|
def detect_date(s):
|
||||||
|
date_f = "19XX r."
|
||||||
|
date_l = len(date_f)
|
||||||
|
|
||||||
|
j = 0
|
||||||
|
for i in range(len(s)):
|
||||||
|
c = s[i]
|
||||||
|
|
||||||
|
if j == date_l:
|
||||||
|
return True
|
||||||
|
elif c == date_f[j] \
|
||||||
|
or (j in (2, 3) and c.isdigit()):
|
||||||
|
j += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
j = 0
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
return filter(detect_date, lines)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
lines = []
|
||||||
|
|
||||||
|
fp = sys.argv[1]
|
||||||
|
with open(fp, encoding="utf-8") as f: # following symlinks might not work on Windows
|
||||||
|
lines = f.readlines()
|
||||||
|
sol = solve(lines)
|
||||||
|
with open("./polish_wiki_excerpt.out", 'w', encoding="utf-8") as f:
|
||||||
|
f.writelines(sol)
|
19939
TaskA04/polish_wiki_excerpt.out
Normal file
19939
TaskA04/polish_wiki_excerpt.out
Normal file
File diff suppressed because it is too large
Load Diff
30
TaskA04/solution.py
Normal file
30
TaskA04/solution.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
# detect numbers. separate numbers by spaces
|
||||||
|
def solve(lines):
|
||||||
|
res = []
|
||||||
|
|
||||||
|
j = 0
|
||||||
|
for l in lines:
|
||||||
|
numbers = []
|
||||||
|
for i in range(len(l)):
|
||||||
|
c = l[i]
|
||||||
|
|
||||||
|
if j > 0 and not c.isdigit():
|
||||||
|
numbers.append(l[i-j:i])
|
||||||
|
j = j+1 if (c.isdigit() and c.isascii()) else 0
|
||||||
|
|
||||||
|
if numbers:
|
||||||
|
res.append(' '.join(numbers))
|
||||||
|
return '\n'.join(res)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
lines = []
|
||||||
|
|
||||||
|
fp = sys.argv[1]
|
||||||
|
with open(fp, encoding="utf-8") as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
sol = solve(lines)
|
||||||
|
with open("./polish_wiki_excerpt.out", 'w', encoding="utf-8") as f:
|
||||||
|
f.writelines(sol)
|
||||||
|
f.write('\n') # it expects for file to end with newline :)
|
106
TaskB01/shakespeare.out
Normal file
106
TaskB01/shakespeare.out
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
CLAUDIUS, King of Denmark, Hamlet’s uncle.
|
||||||
|
The GHOST of the late king, Hamlet’s father.
|
||||||
|
GERTRUDE, the Queen, Hamlet’s mother, now wife of Claudius.
|
||||||
|
HORATIO, Friend to Hamlet.
|
||||||
|
Dar’d to the combat; in which our valiant Hamlet,
|
||||||
|
His fell to Hamlet. Now, sir, young Fortinbras,
|
||||||
|
Unto young Hamlet; for upon my life,
|
||||||
|
Enter Claudius King of Denmark, Gertrude the Queen, Hamlet, Polonius,
|
||||||
|
Though yet of Hamlet our dear brother’s death
|
||||||
|
But now, my cousin Hamlet, and my son—
|
||||||
|
Good Hamlet, cast thy nighted colour off,
|
||||||
|
’Tis sweet and commendable in your nature, Hamlet,
|
||||||
|
Let not thy mother lose her prayers, Hamlet.
|
||||||
|
This gentle and unforc’d accord of Hamlet
|
||||||
|
[_Exeunt all but Hamlet._]
|
||||||
|
For Hamlet, and the trifling of his favour,
|
||||||
|
So please you, something touching the Lord Hamlet.
|
||||||
|
Than a command to parley. For Lord Hamlet,
|
||||||
|
As to give words or talk with the Lord Hamlet.
|
||||||
|
Enter Hamlet, Horatio and Marcellus.
|
||||||
|
That I will speak to thee. I’ll call thee Hamlet,
|
||||||
|
[_Ghost beckons Hamlet._]
|
||||||
|
[_Exeunt Ghost and Hamlet._]
|
||||||
|
Enter Ghost and Hamlet.
|
||||||
|
Wouldst thou not stir in this. Now, Hamlet, hear.
|
||||||
|
O Hamlet, what a falling off was there,
|
||||||
|
Adieu, adieu, adieu. Hamlet, remember me.
|
||||||
|
[_Within._] Lord Hamlet.
|
||||||
|
And what so poor a man as Hamlet is
|
||||||
|
Lord Hamlet, with his doublet all unbrac’d,
|
||||||
|
Of Hamlet’s transformation; so I call it,
|
||||||
|
And bring these gentlemen where Hamlet is.
|
||||||
|
The very cause of Hamlet’s lunacy.
|
||||||
|
Came this from Hamlet to her?
|
||||||
|
‘Lord Hamlet is a prince, out of thy star.
|
||||||
|
Enter Hamlet, reading.
|
||||||
|
How does my good Lord Hamlet?
|
||||||
|
You go to seek the Lord Hamlet; there he is.
|
||||||
|
For we have closely sent for Hamlet hither,
|
||||||
|
Of Hamlet’s wildness: so shall I hope your virtues
|
||||||
|
Enter Hamlet.
|
||||||
|
You need not tell us what Lord Hamlet said,
|
||||||
|
Enter Hamlet and certain Players.
|
||||||
|
How fares our cousin Hamlet?
|
||||||
|
I have nothing with this answer, Hamlet; these words are not mine.
|
||||||
|
Come hither, my dear Hamlet, sit by me.
|
||||||
|
[_Exeunt all but Hamlet and Horatio._]
|
||||||
|
[_Exeunt all but Hamlet._]
|
||||||
|
Enter Hamlet.
|
||||||
|
Enter Hamlet.
|
||||||
|
Hamlet, thou hast thy father much offended.
|
||||||
|
Why, how now, Hamlet?
|
||||||
|
O Hamlet, speak no more.
|
||||||
|
No more, sweet Hamlet.
|
||||||
|
Speak to her, Hamlet.
|
||||||
|
O Hamlet, thou hast cleft my heart in twain.
|
||||||
|
[_Exit Hamlet dragging out Polonius._]
|
||||||
|
What, Gertrude? How does Hamlet?
|
||||||
|
Hamlet in madness hath Polonius slain,
|
||||||
|
Enter Hamlet.
|
||||||
|
[_Within._] Hamlet! Lord Hamlet!
|
||||||
|
What noise? Who calls on Hamlet? O, here they come.
|
||||||
|
Enter Hamlet and Guildenstern.
|
||||||
|
Now, Hamlet, where’s Polonius?
|
||||||
|
Hamlet, this deed, for thine especial safety,—
|
||||||
|
Ay, Hamlet.
|
||||||
|
Thy loving father, Hamlet.
|
||||||
|
The present death of Hamlet. Do it, England;
|
||||||
|
Enter Hamlet, Rosencrantz, Guildenstern &c.
|
||||||
|
[_Exeunt all but Hamlet._]
|
||||||
|
I should be greeted, if not from Lord Hamlet.
|
||||||
|
Letters, my lord, from Hamlet.
|
||||||
|
From Hamlet! Who brought them?
|
||||||
|
’Tis Hamlet’s character. ’Naked!’
|
||||||
|
And that in Hamlet’s hearing, for a quality
|
||||||
|
Did Hamlet so envenom with his envy
|
||||||
|
Hamlet comes back: what would you undertake
|
||||||
|
Hamlet return’d shall know you are come home:
|
||||||
|
Enter Hamlet and Horatio, at a distance.
|
||||||
|
Hamlet o’ercame Fortinbras.
|
||||||
|
that young Hamlet was born,—he that is mad, and sent into England.
|
||||||
|
I hop’d thou shouldst have been my Hamlet’s wife;
|
||||||
|
Hamlet the Dane.
|
||||||
|
Hamlet! Hamlet!
|
||||||
|
Enter Hamlet and Horatio.
|
||||||
|
[_Hamlet moves him to put on his hat._]
|
||||||
|
Come, Hamlet, come, and take this hand from me.
|
||||||
|
[_The King puts Laertes’s hand into Hamlet’s._]
|
||||||
|
Was’t Hamlet wrong’d Laertes? Never Hamlet.
|
||||||
|
If Hamlet from himself be ta’en away,
|
||||||
|
Then Hamlet does it not, Hamlet denies it.
|
||||||
|
Hamlet is of the faction that is wrong’d;
|
||||||
|
His madness is poor Hamlet’s enemy.
|
||||||
|
Give them the foils, young Osric. Cousin Hamlet,
|
||||||
|
If Hamlet give the first or second hit,
|
||||||
|
The King shall drink to Hamlet’s better breath,
|
||||||
|
‘Now the King drinks to Hamlet.’ Come, begin.
|
||||||
|
Stay, give me drink. Hamlet, this pearl is thine;
|
||||||
|
Here, Hamlet, take my napkin, rub thy brows.
|
||||||
|
The Queen carouses to thy fortune, Hamlet.
|
||||||
|
[_Laertes wounds Hamlet; then, in scuffling, they change rapiers, and
|
||||||
|
Hamlet wounds Laertes._]
|
||||||
|
No, no, the drink, the drink! O my dear Hamlet!
|
||||||
|
It is here, Hamlet. Hamlet, thou art slain.
|
||||||
|
Exchange forgiveness with me, noble Hamlet.
|
||||||
|
Bear Hamlet like a soldier to the stage,
|
18
TaskB01/solution.py
Normal file
18
TaskB01/solution.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
|
def solve(lines):
|
||||||
|
return [l for l in lines if re.search("Hamlet", l)]
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
lines = []
|
||||||
|
|
||||||
|
fp = sys.argv[1]
|
||||||
|
assert(fp == "shakespeare.in") # just a sanity check
|
||||||
|
|
||||||
|
print(fp)
|
||||||
|
with open(fp, encoding="utf-8") as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
sol = solve(lines)
|
||||||
|
with open("./shakespeare.out", 'w', encoding="utf-8") as f:
|
||||||
|
f.writelines(sol)
|
13
TaskB02/polish_wiki_excerpt.out
Normal file
13
TaskB02/polish_wiki_excerpt.out
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Pies ten pochodzi z południowych Chin, z terenów prowincji Guangdong. Został rozpropagowany i hodowany w celach wystawowych przez hodowców w USA. Nazwa psa, pochodząca z chińskiego "shā pí" (沙皮), oznacza dosłownie "piaszczysta skóra".
|
||||||
|
Chart polski – polska rasa psa myśliwskiego, znana prawdopodobnie od czasów Galla Anonima, zaliczana do grupy chartów. Dawniej użytkowana była przede wszystkim do polowań, obecnie jako pies reprezentacyjny.
|
||||||
|
Smukły pies o wąskim pysku. Chart polski jest wyraźnie mocniejszy i nie tak finezyjny w kształtach jak inne charty. Jest najwyższą z polskich ras.
|
||||||
|
Chart polski to pies silny, wytrzymały, o dobrze zbalansowanym ciele i proporcjach (wpisany jest w prostokąt oparty na dłuższym boku) pozwalających nie tylko na szybki galop, ale i na pokonywanie dużych odległości wyciągniętym kłusem. Jest psem o okrywie włosowej dobrze chroniącej go przed zimnem, wilgocią i wiatrem.
|
||||||
|
Pies wymagający sporej dawki codziennego ruchu, stąd jest idealnym towarzyszem dla ludzi uprawiających jeździectwo lub jogging.
|
||||||
|
W filmie występuje pies rasy landseer.
|
||||||
|
Bohaterami anime jest grupa łowców nagród, podróżująca statkiem kosmicznym o nazwie "Bebop": Spike Spiegel, Faye Valentine, Jet Black, haker Ed oraz genetycznie zmodyfikowany pies Ein.
|
||||||
|
Tytułowym głównym bohaterem serii jest Lucky Luke - kowboj, najszybszy rewolwerowiec na Dzikim Zachodzie i najgorszy koszmar braci Dalton. Zawsze, gdy planują oni skok na bank lub inne przestępstwo, dzielny stróż prawa staje im na drodze. W jego przygodach towarzyszą mu inteligentny koń Jolly Jumper i pies Bzik (we francuskojęzycznym oryginale: "Rantanplan").
|
||||||
|
Serial w krzywym zwierciadle przedstawia życie typowej amerykańskiej rodziny. Jej głową i jedynym żywicielem jest wiecznie sfrustrowany sprzedawca butów, Al Bundy. Kocha swojego starego dodge'a, wolny czas spędza siedząc na kanapie, oglądając telewizję i pijąc piwo lub na posiedzeniach w toalecie. Jego małżonką jest Peggy, która całymi dniami przesiaduje przed telewizorem, oglądając "The Oprah Winfrey Show", i The Phil Donahue Show zajadając się popcornem i czekoladkami, paląc przy tym papierosa za papierosem. O jej podejściu do typowo domowych zajęć świadczą zadawane przez nią pytania, np. o odkurzacz – "Jak się nazywa to coś, co ciągniesz po dywanie, a ono buczy?" Tytułowymi dziećmi są nastoletni Bud oraz Kelly, którzy nie przepadają za sobą i nie przepuszczą żadnej okazji, aby sobie dokuczyć czy donieść na siebie. Kelly i Bud dojrzewają w trakcie trwania serialu, przez co trochę się zmieniają: Bud z wrednego kilkunastolatka przeistacza się w nastoletniego macho, którego nie chce żadna dziewczyna, a Kelly z każdą serią staje się coraz mniej inteligentna. Wiecznie niedocenianym członkiem rodziny jest pies Buck, który jednak żyje swoim życiem i sam troszczy się o siebie. W trakcie wszystkich dziesięciu lat trwania serialu Bundym towarzyszy dwójka sąsiadów: Marcy, najpierw ze swoim pierwszym mężem, Steve'em Rhoadesem, a następnie z Jeffersonem d'Arcym. Marcy lubi przebywać z Peggy, jest za to na bakier z Alem, natomiast Al utrzymuje dobre stosunki z mężami Marcy, szczególnie Jeffersonem – Steve raczej nie darzył Bundych tak bezwzględną sympatią.
|
||||||
|
Buck (prawdziwe imię Michael; trener Steven Ritt) to pies rodziny Bundych, Briard. Głosu użycza mu Kevin Curran, a w odcinkach specjalnych Cheech Marin. Zdechł w wieku dwunastu lat (w 1996 roku Michael przeszedł na emeryturę, zdechł dziewięć miesięcy po tym, jak Bucka uśmiercono w serialu).
|
||||||
|
Lucky to drugi pies rodziny Bundych, spaniel, reinkarnacja Bucka.
|
||||||
|
20 stycznia 1974 r. o godz. 10.40 w Dolinie Mięguszowieckiej wydarzyła się największa jak do owej pory katastrofa lawinowa w Tatrach. Żlebem spod Przełęczy nad Skokiem w Grani Baszt zeszła potężna lawina, która przewaliła się przez Mięguszowiecki Potok i wdarła 140 m na przeciwległy stok, wspinając się na niego z rozpędu aż 44 m w górę. Na stoku tym, na śnieżnym pólku trenowali z instruktorem uczestnicy kursu narciarskiego ze słowackiego Technikum Budowlanego. Lawina przysypała 24 z nich. Dzięki błyskawicznej akcji ratunkowej (było to tylko 400 m od schroniska nad Popradzkim Stawem) udało się odgrzebać spod śniegu 11 płycej przywalonych. W ciągu następnych godzin i kilku dni liczne zespoły ratunkowe (z pomocą przyszło również wojsko) odgrzebały ciała 10 uczestników kursu; wśród nich nauczyciela z 12-letnim synem. Pies wskazał miejsce, gdzie po 5 godzinach od zejścia lawiny wydobyto żywego 18-latka przywalonego metrową warstwą śniegu. Ciała dwóch uczniów udało się znaleźć dopiero wiosną po stopieniu się śniegu.
|
||||||
|
Początkowo Morris wykorzystał w swoich komiksach historycznych braci Daltonów Grat, Bill i Emmett, których przedstawił jako bardzo groźnych i inteligentnych przestępców. Niestety po pierwszym spotkaniu z Lucky Luke, zostali aresztowani i skazani w więzieniu na śmierć. Morris żałował potem swojej decyzji i wraz z Gościnnym wprowadził na ich miejsce, czwórkę kuzynów (także) Daltonów – Joe, Williama, Jacka i Averelle, którzy byli przeciwieństwem swoich kuzynów. Wiecznie pechowi, gamoniowaci i niezbyt inteligentni. Wkrótce stali się oni najpopularniejszymi postaciami w serii, zaraz po samym Lucky Luke i z czasem dołączył do nich pies Rantanplan. Doczekali się także solowego filmu dystrybuowanego w Polsce pt. "Lucky Luke" (oryg. "Les Dalton").
|
18
TaskB02/solution.py
Normal file
18
TaskB02/solution.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
|
def solve(lines):
|
||||||
|
# return [l for l in lines if re.search(r"\bpies\b", l, re.I)]
|
||||||
|
return [l for l in lines if re.search(r"(^|\s)pies($|\s)", l, re.I)]
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
lines = []
|
||||||
|
|
||||||
|
fp = sys.argv[1]
|
||||||
|
|
||||||
|
print(fp)
|
||||||
|
with open(fp, encoding="utf-8") as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
sol = solve(lines)
|
||||||
|
with open("./polish_wiki_excerpt.out", 'w', encoding="utf-8") as f:
|
||||||
|
f.writelines(sol)
|
951
TaskB03/polish_wiki_excerpt.out
Normal file
951
TaskB03/polish_wiki_excerpt.out
Normal file
File diff suppressed because one or more lines are too long
19
TaskB03/solution.py
Normal file
19
TaskB03/solution.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
|
def solve(lines):
|
||||||
|
print(len(lines))
|
||||||
|
return [l for l in lines if re.search(r"19\d\d r\.", l)]
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
lines = []
|
||||||
|
|
||||||
|
fp = sys.argv[1]
|
||||||
|
assert("polish_wiki_excerpt" in fp)
|
||||||
|
|
||||||
|
print(fp)
|
||||||
|
with open(fp, encoding="utf-8") as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
sol = solve(lines)
|
||||||
|
with open("./polish_wiki_excerpt.out", 'w', encoding="utf-8") as f:
|
||||||
|
f.writelines(sol)
|
19939
TaskB04/polish_wiki_excerpt.out
Normal file
19939
TaskB04/polish_wiki_excerpt.out
Normal file
File diff suppressed because it is too large
Load Diff
23
TaskB04/solution.py
Normal file
23
TaskB04/solution.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import sys
|
||||||
|
import re
|
||||||
|
|
||||||
|
def solve(lines):
|
||||||
|
p = re.compile(r"\d+")
|
||||||
|
return [
|
||||||
|
' '.join(re.findall(p, l)) + '\n'
|
||||||
|
for l in lines
|
||||||
|
if re.search(p, l)
|
||||||
|
]
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
lines = []
|
||||||
|
|
||||||
|
fp = sys.argv[1]
|
||||||
|
assert("polish_wiki_excerpt" in fp)
|
||||||
|
|
||||||
|
print(fp)
|
||||||
|
with open(fp, encoding="utf-8") as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
sol = solve(lines)
|
||||||
|
with open("./polish_wiki_excerpt.out", 'w', encoding="utf-8") as f:
|
||||||
|
f.writelines(sol)
|
13
TaskC03/solution.py
Normal file
13
TaskC03/solution.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def is_valid_nip(line: str) -> bool:
|
||||||
|
# matching either:
|
||||||
|
# xxx-xxx-xx-xx OR xxx-xx-xx-xxx
|
||||||
|
p = re.compile(r'^(?:\d{3}-\d{3}-\d{2}-\d{2}|\d{3}-\d{2}-\d{2}-\d{3})$')
|
||||||
|
return bool(p.match(line))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
for line in sys.stdin:
|
||||||
|
stripped_line = line.strip()
|
||||||
|
print("yes" if is_valid_nip(stripped_line) else "no")
|
5
TaskC03/test.out
Normal file
5
TaskC03/test.out
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
yes
|
||||||
|
yes
|
||||||
|
yes
|
||||||
|
no
|
||||||
|
no
|
17
TaskC20/solution.py
Normal file
17
TaskC20/solution.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def extract_phone_number(line: str) -> str:
|
||||||
|
# The Pattern:
|
||||||
|
# - Start word-boundary
|
||||||
|
# - An optional leading zero
|
||||||
|
# - Two digits followed by a space
|
||||||
|
# - Then a digit, followed by '-', then three digits, then '-', then three digits
|
||||||
|
p = re.compile(r'\b([0]?\d{2}\s\d-\d{3}-\d{3})\b')
|
||||||
|
m = p.search(line)
|
||||||
|
return m.group(1) if m else "<NONE>"
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
for line in sys.stdin:
|
||||||
|
stripped_line = line.strip()
|
||||||
|
print(extract_phone_number(stripped_line))
|
6
TaskC20/test.out
Normal file
6
TaskC20/test.out
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
00 0-000-000
|
||||||
|
000 0-000-000
|
||||||
|
<NONE>
|
||||||
|
061 5-555-553
|
||||||
|
61 5-555-553
|
||||||
|
<NONE>
|
@ -22,7 +22,7 @@ bądź NNN-NN-NN. Jeśli napis nie spełnia podanych warunków, należy wypisać
|
|||||||
"<NONE>".
|
"<NONE>".
|
||||||
|
|
||||||
For each string, extract an area code from the phone number.
|
For each string, extract an area code from the phone number.
|
||||||
We assume, that the phone number is two digits, is preceded by zero or plus.
|
We assume, that the area code(?) is two digits, is preceded by zero or plus.
|
||||||
The rest of the phone number is 7 digits written in N-NNN-NNN
|
The rest of the phone number is 7 digits written in N-NNN-NNN
|
||||||
or NNN-NN-NN form.
|
or NNN-NN-NN form.
|
||||||
If the string does not fulfill the condition, you should print "<NONE>".
|
If the string does not fulfill the condition, you should print "<NONE>".
|
||||||
|
14
TaskC37/solution.py
Normal file
14
TaskC37/solution.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def extract_area_code(line: str) -> str:
|
||||||
|
# While this regex seems complicated, it essentially enforces either of two possible formats
|
||||||
|
# Returning the area code captured in group(1)
|
||||||
|
p = re.compile(r'^[+0](\d{2})\s(?:\d-\d{3}-\d{3}|\d{3}-\d{2}-\d{2})$')
|
||||||
|
m = p.match(line)
|
||||||
|
return m.group(1) if m else "<NONE>"
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
for line in sys.stdin:
|
||||||
|
stripped_line = line.strip()
|
||||||
|
print(extract_area_code(stripped_line))
|
9
TaskC37/test.out
Normal file
9
TaskC37/test.out
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<NONE>
|
||||||
|
61
|
||||||
|
61
|
||||||
|
61
|
||||||
|
61
|
||||||
|
82
|
||||||
|
<NONE>
|
||||||
|
<NONE>
|
||||||
|
<NONE>
|
@ -9,7 +9,7 @@ to wyrazić w samym wyrażeniu regularnym). Tam, gdzie to możliwe należy
|
|||||||
użyć pojedynczego wyrażenia regularnego.
|
użyć pojedynczego wyrażenia regularnego.
|
||||||
|
|
||||||
Write a program, which loads consecutive lines from standard input
|
Write a program, which loads consecutive lines from standard input
|
||||||
and analyze every line (with no newline character). You should
|
and analyzes every line (with no newline character). You should
|
||||||
use regular expressions to the greatest extent possible (e.g. you
|
use regular expressions to the greatest extent possible (e.g. you
|
||||||
can not use negation in the programming language if it is
|
can not use negation in the programming language if it is
|
||||||
possible to express the same in regular expression). Wherever possible,
|
possible to express the same in regular expression). Wherever possible,
|
||||||
|
17
TaskC48/solution.py
Normal file
17
TaskC48/solution.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def is_pokemon(line: str) -> bool:
|
||||||
|
# Defining lowercase and uppercase sets, with Polish diacritic letters included.
|
||||||
|
lowercase = "a-ząćęłńóśźż"
|
||||||
|
uppercase = "A-ZĄĆĘŁŃÓŚŹŻ"
|
||||||
|
|
||||||
|
# Note: I tried to use a single regex pattern as requested.
|
||||||
|
# It turned to be kinda complicated! It relies on preventing identical cases appearing in a row, thus switching case.
|
||||||
|
p = re.compile(fr'^([{uppercase}]?(?:[{lowercase}][{uppercase}])+[{lowercase}]?)')
|
||||||
|
return bool(p.match(line))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
for line in sys.stdin:
|
||||||
|
stripped_line = line.strip()
|
||||||
|
print("yes" if is_pokemon(stripped_line) else "no")
|
12
TaskC48/test.out
Normal file
12
TaskC48/test.out
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
no
|
||||||
|
no
|
||||||
|
yes
|
||||||
|
yes
|
||||||
|
yes
|
||||||
|
yes
|
||||||
|
no
|
||||||
|
no
|
||||||
|
no
|
||||||
|
yes
|
||||||
|
yes
|
||||||
|
yes
|
@ -5,12 +5,6 @@ użyć negacji jako operacji w danym języku programowania, jeśli da się
|
|||||||
to wyrazić w samym wyrażeniu regularnym). Tam, gdzie to możliwe należy
|
to wyrazić w samym wyrażeniu regularnym). Tam, gdzie to możliwe należy
|
||||||
użyć pojedynczego wyrażenia regularnego.
|
użyć pojedynczego wyrażenia regularnego.
|
||||||
|
|
||||||
Write a program, which loads consecutive lines from standard input
|
|
||||||
and analyze every line (with no newline character). You should
|
|
||||||
use regular expressions to the greatest extent possible (e.g. you
|
|
||||||
can not use negation in the programming language if it is
|
|
||||||
possible to express the same in regular expression). Wherever possible,
|
|
||||||
use one regular expression.
|
|
||||||
|
|
||||||
Write a program to substitute all 4-digits string to 4-characters string.
|
Write a program to substitute all 4-digits string to 4-characters string.
|
||||||
In the substituted string "0" should change to "a", "1" should change to "b", "2" should change to "c", etc.
|
In the substituted string "0" should change to "a", "1" should change to "b", "2" should change to "c", etc.
|
||||||
|
File diff suppressed because one or more lines are too long
20
TaskD00/solution.py
Normal file
20
TaskD00/solution.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
FOUR_DIGIT_PATTERN = re.compile(r'\d{4}')
|
||||||
|
DIGIT_TRANSLATION = str.maketrans('0123456789', 'abcdefghij')
|
||||||
|
|
||||||
|
def translate_four_digits(line: str) -> str:
|
||||||
|
"""
|
||||||
|
An approach utilizing pythonic static methods,
|
||||||
|
for creating and executing a string translation.
|
||||||
|
"""
|
||||||
|
# taking and replacing 4-digit substrings using the translation table
|
||||||
|
return FOUR_DIGIT_PATTERN.sub(lambda m: m.group().translate(DIGIT_TRANSLATION), line)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
for l in sys.stdin:
|
||||||
|
print(
|
||||||
|
translate_four_digits(l),
|
||||||
|
end='' # some leading spaces were mistakingly removed
|
||||||
|
)
|
50000
TaskD01/polish_wiki_excerpt.out
Normal file
50000
TaskD01/polish_wiki_excerpt.out
Normal file
File diff suppressed because one or more lines are too long
39
TaskD01/solution.py
Normal file
39
TaskD01/solution.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
LOWERCASE = 'a-ząćęłńóśźż'
|
||||||
|
UPPERCASE = 'A-ZĄĆĘŁŃÓŚŹŻ'
|
||||||
|
|
||||||
|
# ensuring the presence of both by two positive lookaheads
|
||||||
|
# the pattern looks for matches in word bounds only
|
||||||
|
WORD_PATTERN = re.compile(
|
||||||
|
rf'\b(?=\w*[{LOWERCASE}])(?=\w*[{UPPERCASE}])\w+\b'
|
||||||
|
)
|
||||||
|
|
||||||
|
def _invert(word: str) -> str:
|
||||||
|
"""
|
||||||
|
Inverts cases utilizing regexes to the max!
|
||||||
|
"""
|
||||||
|
res = []
|
||||||
|
for c in word:
|
||||||
|
if re.match(rf'[{LOWERCASE}]', c):
|
||||||
|
res.append(c.upper())
|
||||||
|
elif re.match(rf'[{UPPERCASE}]', c):
|
||||||
|
res.append(c.lower())
|
||||||
|
else:
|
||||||
|
res.append(c)
|
||||||
|
return ''.join(res)
|
||||||
|
|
||||||
|
def flip_case(line: str) -> str:
|
||||||
|
"""
|
||||||
|
Processes a single line with a regex
|
||||||
|
and inverts their cases.
|
||||||
|
"""
|
||||||
|
return WORD_PATTERN.sub(lambda match: _invert(match.group()), line)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
for l in sys.stdin:
|
||||||
|
print(
|
||||||
|
flip_case(l),
|
||||||
|
end=''
|
||||||
|
)
|
50000
TaskD02/polish_wiki_excerpt.out
Normal file
50000
TaskD02/polish_wiki_excerpt.out
Normal file
File diff suppressed because it is too large
Load Diff
40
TaskD02/solution.py
Normal file
40
TaskD02/solution.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# character classes
|
||||||
|
LOWERCASE = 'a-ząćęłńóśźż'
|
||||||
|
UPPERCASE = 'A-ZĄĆĘŁŃÓŚŹŻ'
|
||||||
|
DIGIT = r'\d'
|
||||||
|
MISC = r'[^a-zA-ZĄĆĘŁŃÓŚŹŻąćęłńóśźż\d]'
|
||||||
|
|
||||||
|
# a pattern featuring 4 capturing groups,
|
||||||
|
# each for a class accordingly.
|
||||||
|
PATTERN = re.compile(
|
||||||
|
rf'([{LOWERCASE}])|([{UPPERCASE}])|({DIGIT})|({MISC})'
|
||||||
|
)
|
||||||
|
|
||||||
|
def count_classes(line: str) -> str:
|
||||||
|
"""
|
||||||
|
Count the number of polish lowercase/uppercase letters,
|
||||||
|
digits and other characters in the given line.
|
||||||
|
"""
|
||||||
|
A = B = C = D = 0
|
||||||
|
|
||||||
|
# match over each character in the line
|
||||||
|
for m in PATTERN.finditer(line):
|
||||||
|
if m.group(1):
|
||||||
|
A += 1
|
||||||
|
elif m.group(2):
|
||||||
|
B += 1
|
||||||
|
elif m.group(3):
|
||||||
|
C += 1
|
||||||
|
else:
|
||||||
|
D += 1
|
||||||
|
|
||||||
|
return f"{A} {B} {C} {D}"
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
for l in sys.stdin:
|
||||||
|
print(
|
||||||
|
count_classes(l.rstrip('\n'))
|
||||||
|
)
|
50000
TaskD03/polish_wiki_excerpt.out
Normal file
50000
TaskD03/polish_wiki_excerpt.out
Normal file
File diff suppressed because it is too large
Load Diff
33
TaskD03/solution.py
Normal file
33
TaskD03/solution.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
#
|
||||||
|
# similar to task D02:
|
||||||
|
#
|
||||||
|
|
||||||
|
LOWERCASE = 'a-ząćęłńóśźż'
|
||||||
|
UPPERCASE = 'A-ZĄĆĘŁŃÓŚŹŻ'
|
||||||
|
|
||||||
|
UNICASE_WORD_PATTERN = re.compile(
|
||||||
|
rf'\b([{LOWERCASE}]\w*)\b|'
|
||||||
|
rf'\b([{UPPERCASE}]\w*)\b'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def count_word_casings(line: str) -> str:
|
||||||
|
A = B = 0
|
||||||
|
|
||||||
|
for m in UNICASE_WORD_PATTERN.finditer(line):
|
||||||
|
if m.group(1):
|
||||||
|
A += 1
|
||||||
|
else:
|
||||||
|
B += 1
|
||||||
|
|
||||||
|
return f"{A} {B}"
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
for l in sys.stdin:
|
||||||
|
print(
|
||||||
|
count_word_casings(l.rstrip('\n'))
|
||||||
|
)
|
File diff suppressed because one or more lines are too long
20
TaskD04/solution.py
Normal file
20
TaskD04/solution.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
NUMBER_PATTERN = re.compile(r'\d+')
|
||||||
|
|
||||||
|
def reprint_without_second_number(line: str) -> str:
|
||||||
|
number_count = 0
|
||||||
|
|
||||||
|
def reprinter(m):
|
||||||
|
nonlocal number_count
|
||||||
|
number_count += 1
|
||||||
|
return '' if number_count == 2 else m.group()
|
||||||
|
|
||||||
|
return NUMBER_PATTERN.sub(reprinter, line)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
for l in sys.stdin:
|
||||||
|
print(
|
||||||
|
reprint_without_second_number(l.rstrip('\n'))
|
||||||
|
)
|
50000
TaskD05/polish_wiki_excerpt.out
Normal file
50000
TaskD05/polish_wiki_excerpt.out
Normal file
File diff suppressed because one or more lines are too long
20
TaskD05/solution.py
Normal file
20
TaskD05/solution.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
WORD_PATTERN = re.compile(r'\w+')
|
||||||
|
|
||||||
|
def reprint_without_third_word(line: str) -> str:
|
||||||
|
word_count = 0
|
||||||
|
|
||||||
|
def reprinter(m):
|
||||||
|
nonlocal word_count
|
||||||
|
word_count += 1
|
||||||
|
return 'x' * len(m.group()) if word_count == 3 else m.group()
|
||||||
|
|
||||||
|
return WORD_PATTERN.sub(reprinter, line)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
for l in sys.stdin:
|
||||||
|
print(
|
||||||
|
reprint_without_third_word(l.rstrip('\n'))
|
||||||
|
)
|
@ -1,23 +0,0 @@
|
|||||||
Use regular expressions to extract lines containing polish surnames.
|
|
||||||
|
|
||||||
Download list of polish male and female surnames from here:
|
|
||||||
|
|
||||||
|
|
||||||
* https://dane.gov.pl/pl/dataset/568,nazwiska-wystepujace-w-rejestrze-pesel/resource/22810/table?page=1&per_page=20&q=&sort=
|
|
||||||
* https://dane.gov.pl/pl/dataset/568,nazwiska-wystepujace-w-rejestrze-pesel/resource/22812/table?page=1&per_page=20&q=&sort=
|
|
||||||
|
|
||||||
|
|
||||||
Extract lines from stdin containing any of the surname.
|
|
||||||
Look only for surnames in lowercase.
|
|
||||||
The surname does not have to be surrounded by space or any other special characters.
|
|
||||||
Don't search for declined forms of surnames.
|
|
||||||
|
|
||||||
Check either NFA (e.g. re python library) and DFA (google re2) and compare run speed.
|
|
||||||
|
|
||||||
Submit solution based on DFA library.
|
|
||||||
|
|
||||||
NOTE: You could extract the polish surnames list, save it to a file, then commit the file to your repository.
|
|
||||||
NOTE: You may set max_mem to a higher value than the default in re2 library.
|
|
||||||
|
|
||||||
POINTS: 3
|
|
||||||
DEADLINE: 2025-02-10 23:59:59
|
|
@ -1 +0,0 @@
|
|||||||
../TaskA02/polish_wiki_excerpt.in
|
|
@ -1,44 +0,0 @@
|
|||||||
Use regular expressions to mark Polish first-person masculine forms.
|
|
||||||
|
|
||||||
You should handle the following types of expressions:
|
|
||||||
|
|
||||||
* first-person masculine past forms of verbs ("zrobiłem", "pisałem", etc.),
|
|
||||||
* first-person singular masculine forms of the verb "być" ("be") combined
|
|
||||||
with singular masculine nominative forms of adjectives ("wysoki", "sprytny", etc.),
|
|
||||||
assuming that the form of the verb "być" is to the left of the adjective, not
|
|
||||||
more than 3 other words,
|
|
||||||
* the verb "będę" combined with the past participle (i.e. 3rd person
|
|
||||||
masculine imperfect form, e.g. "robił", pisał"), assuming
|
|
||||||
that "będę" is to the left of the adjective, not
|
|
||||||
more than 3 other words to the left of the participle OR directly
|
|
||||||
to the right of the participle ("robił będę").
|
|
||||||
|
|
||||||
The first-person masculine forms should be marked with curly brackets.
|
|
||||||
You should mark only the masculine form. Do not mark the form of "być"
|
|
||||||
(unless it clearly a masculine form, i.e. for "byłem").
|
|
||||||
|
|
||||||
The match should be case-insensitive.
|
|
||||||
|
|
||||||
The PoliMorf dictionary of inflected forms should be applied:
|
|
||||||
http://zil.ipipan.waw.pl/PoliMorf?action=AttachFile&do=get&target=PoliMorf-0.6.7.tab.gz
|
|
||||||
|
|
||||||
Suggested steps:
|
|
||||||
|
|
||||||
1. Extract all the needed forms from the PoliMorf dictionary:
|
|
||||||
|
|
||||||
* 1st person masculine past forms of verbs, unfortunately
|
|
||||||
this form is not directly present in the lexicon, you need
|
|
||||||
to add "em" to the 3rd person masculine form ("zrobił" => "zrobiłem")
|
|
||||||
* singular masculine nominative forms of adjectives
|
|
||||||
* masculine past participle (3rd person masculine imperfect forms of verbs)
|
|
||||||
|
|
||||||
You could do this using grep/cut commands — to obtain a simple text files
|
|
||||||
with a word in each line. You can do this once and commit the 3 files to your repository.
|
|
||||||
|
|
||||||
2. In your `run` script/program, read the 3 files and create a large
|
|
||||||
expression with alternatives. Use a regexp library based on DFAs (determintistic
|
|
||||||
finite-automatons).
|
|
||||||
|
|
||||||
POINTS: 5
|
|
||||||
DEADLINE: 2025-02-10 23:59:59
|
|
||||||
REMAINDER: 0/2
|
|
@ -1,25 +0,0 @@
|
|||||||
Tu nic nie ma.
|
|
||||||
Wczoraj {ugotowałem} ziemniaki.
|
|
||||||
{Jechałem}, {jechałem} i {jechałem}, a potem się {zatrzymałem}.
|
|
||||||
{Umyłem} się mydłem.
|
|
||||||
Jestem {wysoki}.
|
|
||||||
Jest wysoki.
|
|
||||||
Mówią, że jestem od zawsze niezwykle {sprytny}.
|
|
||||||
aaaa {byłem} aaa {zielony} ddd
|
|
||||||
aaaa {byłem} aaa bbb {zielony} ddd
|
|
||||||
aaaa {byłem} aaa bbb ccc {zielony} ddd
|
|
||||||
aaaa {byłem} aaa bbb ccc ddd zielony ddd
|
|
||||||
aaaa był aaa bbb zielony ddd
|
|
||||||
aaaa byłam aaa bbb zielony ddd
|
|
||||||
aaaa byłam aaa bbb zielona ddd
|
|
||||||
teraz będę {pisał} książkę
|
|
||||||
będę teraz {pisał} książkę
|
|
||||||
będę teraz dla ciebie {pisał} książkę
|
|
||||||
teraz dla ciebie {pisał} będę księżkę
|
|
||||||
będę i on napisał książkę
|
|
||||||
aaa będę {śpiewał} bbb
|
|
||||||
aaa będę ccc {śpiewał} bbb
|
|
||||||
aaa będę ccc ddd {śpiewał} bbb
|
|
||||||
aaa będę ccc ddd eee {śpiewał} bbb
|
|
||||||
aaa będę ccc ddd eee fff śpiewał bbb
|
|
||||||
{pływałem} i {biegałem}
|
|
@ -1,25 +0,0 @@
|
|||||||
Tu nic nie ma.
|
|
||||||
Wczoraj ugotowałem ziemniaki.
|
|
||||||
Jechałem, jechałem i jechałem, a potem się zatrzymałem.
|
|
||||||
Umyłem się mydłem.
|
|
||||||
Jestem wysoki.
|
|
||||||
Jest wysoki.
|
|
||||||
Mówią, że jestem od zawsze niezwykle sprytny.
|
|
||||||
aaaa byłem aaa zielony ddd
|
|
||||||
aaaa byłem aaa bbb zielony ddd
|
|
||||||
aaaa byłem aaa bbb ccc zielony ddd
|
|
||||||
aaaa byłem aaa bbb ccc ddd zielony ddd
|
|
||||||
aaaa był aaa bbb zielony ddd
|
|
||||||
aaaa byłam aaa bbb zielony ddd
|
|
||||||
aaaa byłam aaa bbb zielona ddd
|
|
||||||
teraz będę pisał książkę
|
|
||||||
będę teraz pisał książkę
|
|
||||||
będę teraz dla ciebie pisał książkę
|
|
||||||
teraz dla ciebie pisał będę księżkę
|
|
||||||
będę i on napisał książkę
|
|
||||||
aaa będę śpiewał bbb
|
|
||||||
aaa będę ccc śpiewał bbb
|
|
||||||
aaa będę ccc ddd śpiewał bbb
|
|
||||||
aaa będę ccc ddd eee śpiewał bbb
|
|
||||||
aaa będę ccc ddd eee fff śpiewał bbb
|
|
||||||
pływałem i biegałem
|
|
@ -1,44 +0,0 @@
|
|||||||
Use regular expressions to mark Polish first-person feminine forms.
|
|
||||||
|
|
||||||
You should handle the following types of expressions:
|
|
||||||
|
|
||||||
* first-person feminine past forms of verbs ("zrobiłam", "pisałam", etc.),
|
|
||||||
* first-person singular feminine forms of the verb "być" ("be") combined
|
|
||||||
with singular feminine nominative forms of adjectives ("wysoka", "sprytna", etc.),
|
|
||||||
assuming that the form of the verb "być" is to the left of the adjective, not
|
|
||||||
more than 3 other words,
|
|
||||||
* the verb "będę" combined with the past participle (i.e. 3rd person
|
|
||||||
feminine imperfect form, e.g. "robiła", pisała"), assuming
|
|
||||||
that "będę" is to the left of the adjective, not
|
|
||||||
more than 3 other words to the left of the participle OR directly
|
|
||||||
to the right of the participle ("robiła będę").
|
|
||||||
|
|
||||||
The first-person feminine forms should be marked with curly brackets.
|
|
||||||
You should mark only the feminine form. Do not mark the form of "być"
|
|
||||||
(unless it clearly a feminine form, i.e. for "byłam").
|
|
||||||
|
|
||||||
The match should be case-insensitive.
|
|
||||||
|
|
||||||
The PoliMorf dictionary of inflected forms should be applied:
|
|
||||||
http://zil.ipipan.waw.pl/PoliMorf?action=AttachFile&do=get&target=PoliMorf-0.6.7.tab.gz
|
|
||||||
|
|
||||||
Suggested steps:
|
|
||||||
|
|
||||||
1. Extract all the needed forms from the PoliMorf dictionary:
|
|
||||||
|
|
||||||
* 1st person feminine past forms of verbs, unfortunately
|
|
||||||
this form is not directly present in the lexicon, you need
|
|
||||||
to add "m" to the 3rd person feminine form ("zrobiła" => "zrobiłam")
|
|
||||||
* singular feminine nominative forms of adjectives
|
|
||||||
* feminine past participle (3rd person feminine imperfect forms of verbs)
|
|
||||||
|
|
||||||
You could do this using grep/cut commands — to obtain a simple text files
|
|
||||||
with a word in each line. You can do this once and commit the 3 files to your repository.
|
|
||||||
|
|
||||||
2. In your `run` script/program, read the 3 files and create a large
|
|
||||||
expression with alternatives. Use a regexp library based on DFAs (determintistic
|
|
||||||
finite-automatons).
|
|
||||||
|
|
||||||
POINTS: 5
|
|
||||||
DEADLINE: 2025-02-10 23:59:59
|
|
||||||
REMAINDER: 1/2
|
|
@ -1,25 +0,0 @@
|
|||||||
Tu nic nie ma.
|
|
||||||
Wczoraj {ugotowałam} ziemniaki.
|
|
||||||
{Jechałam}, {jechałam} i {jechałam}, a potem się {zatrzymałam}.
|
|
||||||
{Umyłam} się mydłem i bam, złam się.
|
|
||||||
Jestem {wysoka}.
|
|
||||||
Jest {wysoka}.
|
|
||||||
Mówią, że jestem od zawsze niezwykle {sprytna}.
|
|
||||||
aaaa {byłam} aaa {zielona} ddd
|
|
||||||
aaaa {byłam} aaa bbb {zielona} ddd
|
|
||||||
aaaa {byłam} aaa bbb ccc {zielona} ddd
|
|
||||||
aaaa {byłam} aaa bbb ccc ddd zielona ddd
|
|
||||||
aaaa była aaa bbb zielona ddd
|
|
||||||
aaaa byłem aaa bbb zielona ddd
|
|
||||||
aaaa byłem aaa bbb zielony ddd
|
|
||||||
teraz będę {pisała} książkę
|
|
||||||
będę teraz {pisała} książkę
|
|
||||||
będę teraz dla ciebie {pisała} książkę
|
|
||||||
teraz dla ciebie {pisała} będę księżkę
|
|
||||||
będę i ona napisała książkę
|
|
||||||
aaa będę {śpiewała} bbb
|
|
||||||
aaa będę ccc {śpiewała} bbb
|
|
||||||
aaa będę ccc ddd {śpiewała} bbb
|
|
||||||
aaa będę ccc ddd eee {śpiewała} bbb
|
|
||||||
aaa będę ccc ddd eee fff śpiewała bbb
|
|
||||||
{pływałam} i {biegałam}
|
|
@ -1,25 +0,0 @@
|
|||||||
Tu nic nie ma.
|
|
||||||
Wczoraj ugotowałam ziemniaki.
|
|
||||||
Jechałam, jechałam i jechałam, a potem się zatrzymałam.
|
|
||||||
Umyłam się mydłem i bam, złam się.
|
|
||||||
Jestem wysoka.
|
|
||||||
Jest wysoka.
|
|
||||||
Mówią, że jestem od zawsze niezwykle sprytna.
|
|
||||||
aaaa byłam aaa zielona ddd
|
|
||||||
aaaa byłam aaa bbb zielona ddd
|
|
||||||
aaaa byłam aaa bbb ccc zielona ddd
|
|
||||||
aaaa byłam aaa bbb ccc ddd zielona ddd
|
|
||||||
aaaa była aaa bbb zielona ddd
|
|
||||||
aaaa byłem aaa bbb zielona ddd
|
|
||||||
aaaa byłem aaa bbb zielony ddd
|
|
||||||
teraz będę pisała książkę
|
|
||||||
będę teraz pisała książkę
|
|
||||||
będę teraz dla ciebie pisała książkę
|
|
||||||
teraz dla ciebie pisała będę księżkę
|
|
||||||
będę i ona napisała książkę
|
|
||||||
aaa będę śpiewała bbb
|
|
||||||
aaa będę ccc śpiewała bbb
|
|
||||||
aaa będę ccc ddd śpiewała bbb
|
|
||||||
aaa będę ccc ddd eee śpiewała bbb
|
|
||||||
aaa będę ccc ddd eee fff śpiewała bbb
|
|
||||||
pływałam i biegałam
|
|
@ -1,23 +0,0 @@
|
|||||||
Use regular expressions to extract lines containing polish surnames. CASE INSENSITIVE
|
|
||||||
|
|
||||||
Download list of polish male and female surnames from here:
|
|
||||||
|
|
||||||
|
|
||||||
* https://dane.gov.pl/pl/dataset/568,nazwiska-wystepujace-w-rejestrze-pesel/resource/22810/table?page=1&per_page=20&q=&sort=
|
|
||||||
* https://dane.gov.pl/pl/dataset/568,nazwiska-wystepujace-w-rejestrze-pesel/resource/22812/table?page=1&per_page=20&q=&sort=
|
|
||||||
|
|
||||||
|
|
||||||
Extract lines from stdin containing any of the surnames.
|
|
||||||
Look only for surnames no matter casing (case insensitive).
|
|
||||||
The surname does not have to be surrounded by space or any other special characters.
|
|
||||||
Don't search for declined forms of surnames.
|
|
||||||
|
|
||||||
Check either NFA (e.g. re python library) and DFA (google re2) and compare them.
|
|
||||||
|
|
||||||
Submit solution based on a better method.
|
|
||||||
|
|
||||||
NOTE: You could extract the polish surnames list, save it to a file, then commit the file to your repository.
|
|
||||||
NOTE: You may set max_mem to a higher value than the default in re2 library.
|
|
||||||
|
|
||||||
POINTS: 2
|
|
||||||
DEADLINE: 2025-02-10 23:59:59
|
|
@ -1 +0,0 @@
|
|||||||
../TaskA02/polish_wiki_excerpt.in
|
|
Loading…
Reference in New Issue
Block a user