Prześlij pliki do 'TaskA01'
This commit is contained in:
parent
28d2cd7130
commit
233ca57613
5
TaskA01/description.txt
Normal file
5
TaskA01/description.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Write a program to find lines containing the word "Hamlet".
|
||||||
|
Do not use regular expressions, just the simplest capabilities
|
||||||
|
of a programming language.
|
||||||
|
|
||||||
|
POINTS: 1
|
23
TaskA01/run.py
Normal file
23
TaskA01/run.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
def checkFile(file):
|
||||||
|
hamlet = ['h', 'a', 'm', 'l', 'e', 't']
|
||||||
|
i = 0
|
||||||
|
line = 1
|
||||||
|
word = ''
|
||||||
|
|
||||||
|
with open(file, 'r', encoding='utf-8') as sampleCheck:
|
||||||
|
for row in sampleCheck:
|
||||||
|
for char in row:
|
||||||
|
if char.lower() == hamlet[i]:
|
||||||
|
i += 1
|
||||||
|
word += char
|
||||||
|
if i == len(hamlet):
|
||||||
|
print(line)
|
||||||
|
i = 0
|
||||||
|
word = ''
|
||||||
|
else:
|
||||||
|
i = 0
|
||||||
|
word = ''
|
||||||
|
line += 1
|
||||||
|
|
||||||
|
file = 'shakespeare.in'
|
||||||
|
checkFile(file)
|
106
TaskA01/shakespeare.exp
Normal file
106
TaskA01/shakespeare.exp
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,
|
2
TaskA01/simple.exp
Normal file
2
TaskA01/simple.exp
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Here comes Hamlet
|
||||||
|
Hamlet Hamlet again
|
3
TaskA01/simple.in
Normal file
3
TaskA01/simple.in
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Here comes Hamlet
|
||||||
|
ABC
|
||||||
|
Hamlet Hamlet again
|
Loading…
Reference in New Issue
Block a user