Загружаю решение ДЗ по поиску первого повторяющегося символа в строке
This commit is contained in:
parent
ac65502e7e
commit
676bb2fd9f
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (ДЗ тестирование 2)" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
|
@ -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.11" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -1,17 +1,75 @@
|
||||||
|
def verify(message, expected, actual):
|
||||||
|
a = "========================="
|
||||||
|
print(a)
|
||||||
|
print(message)
|
||||||
|
if type(actual) != type(expected) or actual != expected:
|
||||||
|
print("FAILED!")
|
||||||
|
|
||||||
|
print(f"Expected value: {expected}")
|
||||||
|
print(f"Actual value: {actual}")
|
||||||
|
|
||||||
|
print(a)
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
print("SUCCESS!")
|
||||||
|
print(a)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def verify_all(dataset):
|
||||||
|
summa_success = int()
|
||||||
|
summa_failed = int()
|
||||||
|
for result in dataset:
|
||||||
|
if verify(result[0], result[1], result[2]):
|
||||||
|
summa_success += 1
|
||||||
|
else:
|
||||||
|
summa_failed += 1
|
||||||
|
print("Total:", len(dataset), "Successful:", summa_success, "Failed:", summa_failed)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def first_recurring_char(s):
|
def first_recurring_char(s):
|
||||||
array = []
|
array = []
|
||||||
z = str
|
p = 1
|
||||||
|
t = 0
|
||||||
|
k = str
|
||||||
if type(s) is str and s is not None:
|
if type(s) is str and s is not None:
|
||||||
for i in s:
|
for i in s:
|
||||||
|
if i.isalpha():
|
||||||
array.append(i)
|
array.append(i)
|
||||||
k = + 1
|
k = i
|
||||||
for j in array[0:k - 1]:
|
t += 1
|
||||||
if j == i:
|
for j in array[0:t-1]:
|
||||||
p = +1
|
if k == j:
|
||||||
print(p)
|
p += 1
|
||||||
if p > 1:
|
if p > 1:
|
||||||
z = str(j)
|
return k
|
||||||
return z
|
break
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
print(first_recurring_char("вадвава"))
|
|
||||||
|
dataset = [ # Проверочные тесты, что вообще что-то работает
|
||||||
|
("first_recurring_char0", None, first_recurring_char([1])),
|
||||||
|
("first_recurring_char1", ("п"), first_recurring_char("у попа была собака")),
|
||||||
|
("first_recurring_char2", None, first_recurring_char("япчм")),
|
||||||
|
("first_recurring_char3", None, first_recurring_char(-2)),
|
||||||
|
("first_recurring_char4", ("q"), first_recurring_char("qwertyuiopq")),
|
||||||
|
|
||||||
|
# Тесты на пустые значения
|
||||||
|
("first_recurring_char5", None, first_recurring_char('')),
|
||||||
|
("first_recurring_char6", None, first_recurring_char(None)),
|
||||||
|
|
||||||
|
# Тесты на неверный тип
|
||||||
|
("first_recurring_char7", None, first_recurring_char(True)),
|
||||||
|
("first_recurring_char8", None, first_recurring_char({1212})),
|
||||||
|
|
||||||
|
# Тесты на редкие случаи
|
||||||
|
("first_recurring_char9", ("а"), first_recurring_char("у Попа была собака, он ее прибил")),
|
||||||
|
("first_recurring_char10", ("W"), first_recurring_char(("WWW"))),
|
||||||
|
("first_recurring_char11", ("Г"), first_recurring_char('гГваунзГг')),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
verify_all(dataset)
|
Loading…
Reference in New Issue