update
This commit is contained in:
parent
2e63e7e82c
commit
77de00fd23
@ -2,7 +2,7 @@
|
|||||||
<module type="PYTHON_MODULE" version="4">
|
<module type="PYTHON_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$" />
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -3,5 +3,5 @@
|
|||||||
<component name="Black">
|
<component name="Black">
|
||||||
<option name="sdkName" value="Python 3.8" />
|
<option name="sdkName" value="Python 3.8" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
@ -20,10 +20,20 @@ class FSA:
|
|||||||
else:
|
else:
|
||||||
self.transitions[state_from] = dict()
|
self.transitions[state_from] = dict()
|
||||||
self.transitions[state_from][symbol] = {state_to}
|
self.transitions[state_from][symbol] = {state_to}
|
||||||
|
def get_final_state(self, string):
|
||||||
|
|
||||||
|
current_state = self.initial_state
|
||||||
|
for symbol in string:
|
||||||
|
current_state = self.transitions[current_state][symbol]
|
||||||
|
return current_state
|
||||||
def add_final_state(self, state):
|
def add_final_state(self, state):
|
||||||
self.final_states.add(state)
|
self.final_states.add(state)
|
||||||
|
def accepts(self, string):
|
||||||
|
|
||||||
|
if self.get_final_state(string) in self.final_states:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
fsa = FSA()
|
fsa = FSA()
|
||||||
|
|
||||||
|
@ -37,14 +37,14 @@ nfa = NFA()
|
|||||||
table = open(sys.argv[1])
|
table = open(sys.argv[1])
|
||||||
for line in table:
|
for line in table:
|
||||||
line = line.rstrip('\n')
|
line = line.rstrip('\n')
|
||||||
if len(line.split('\t')) == 3:
|
if len(line.split(' ')) == 3:
|
||||||
a, b, c = line.split('\t')
|
a, b, c = line.split(' ')
|
||||||
c = c.replace("'","")
|
c = c.replace("'","")
|
||||||
c = list(c)
|
c = list(c)
|
||||||
for x in c:
|
for x in c:
|
||||||
nfa.add_transition(a, b, x)
|
nfa.add_transition(a, b, x)
|
||||||
nfa.alphabet.add(x)
|
nfa.alphabet.add(x)
|
||||||
elif len(line.split('\t')) == 1:
|
elif len(line.split(' ')) == 1:
|
||||||
nfa.add_final_state(line)
|
nfa.add_final_state(line)
|
||||||
else:
|
else:
|
||||||
assert False
|
assert False
|
||||||
|
@ -15,16 +15,15 @@ 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,
|
||||||
use one regular expression.
|
use one regular expression.
|
||||||
|
|
||||||
Dla każdego napisu należy wydobyć zadany napis jest numerem telefonu.
|
Dla każdego napisu należy wskazać czy zadany napis jest numerem telefonu.
|
||||||
Zakładamy, że numer telefonu składa się z dwóch cyfr opcjonalnie
|
Zakładamy, że numer telefonu składa się z dwóch cyfr opcjonalnie
|
||||||
poprzedzonych zerem, po których następuje spacja i 7 cyfr w formacie
|
poprzedzonych zerem, po których następuje spacja i 7 cyfr w formacie
|
||||||
N-NNN-NNN. Jeśli napis nie spełnia podanych warunków, należy wypisać
|
N-NNN-NNN. Jeśli napis spełnia podane warunki, należy wypisać
|
||||||
"<NONE>".
|
"yes", w przeciwnym wypadku "no".
|
||||||
|
|
||||||
For each string, extract a phone number. We assume, that the phone
|
For each string, indicate whether it is a phone number. We assume, that the phone
|
||||||
number consists of two digits (optionally prefixed by zero), followed
|
number consists of two digits (optionally prefixed by zero), followed
|
||||||
by space and 7 digits in N-NNN-NNN format. If the string does
|
by space and 7 digits in N-NNN-NNN format. If the string fulfills the condition, print "yes", otherwise "no".
|
||||||
not fulfill the condition, print "<NONE>".
|
|
||||||
|
|
||||||
UWAGA! Zadanie przeznaczone dla studentów, których numer indeksu
|
UWAGA! Zadanie przeznaczone dla studentów, których numer indeksu
|
||||||
dzieli się przez 27 z resztą 20.
|
dzieli się przez 27 z resztą 20.
|
||||||
@ -33,4 +32,4 @@ Attention. The task is for students whose students id remainder of the division
|
|||||||
|
|
||||||
POINTS: 1
|
POINTS: 1
|
||||||
DEADLINE: 2023-12-10 23:59:59
|
DEADLINE: 2023-12-10 23:59:59
|
||||||
REMAINDER: 20/27
|
REMAINDER: 20/27
|
@ -4,6 +4,6 @@ import re
|
|||||||
for line in sys.stdin:
|
for line in sys.stdin:
|
||||||
numbers = re.match(r'^(0?[0-9]{2}) (\d{1}-\d{3}-\d{3})$', line.replace("\n", ""), flags=re.IGNORECASE)
|
numbers = re.match(r'^(0?[0-9]{2}) (\d{1}-\d{3}-\d{3})$', line.replace("\n", ""), flags=re.IGNORECASE)
|
||||||
if numbers:
|
if numbers:
|
||||||
print(numbers)
|
print('yes')
|
||||||
else:
|
else:
|
||||||
print("<NONE>")
|
print("no")
|
@ -2,7 +2,7 @@ import sys
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
for line in sys.stdin:
|
for line in sys.stdin:
|
||||||
str = re.match(r'(NIE|NO).*[EO]{6,}.*!!!.*', line.replace("\n", ""), flags=re.IGNORECASE)
|
str = re.match(r'^N(IE|O).*[EO]{5,}.*!!!.*', line.replace("\n", ""), flags=re.IGNORECASE)
|
||||||
if str:
|
if str:
|
||||||
print('yes')
|
print('yes')
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user