finish extra/the-cake-is-not-a-lie #30
@ -122,3 +122,6 @@ CFcSBwgCCBoHRhkKU1cGAA4AGU5YQR5THBwNFwoGGAxTQQMQVBUSBg4EAAwQRhUQVBUHFAQTGRpT QQM
|
|||||||
* Completed in: 18 mins, 46 secs.
|
* Completed in: 18 mins, 46 secs.
|
||||||
* Reference
|
* Reference
|
||||||
* [The Braille Alphabet](https://www.pharmabraille.com/pharmaceutical-braille/the-braille-alphabet/)
|
* [The Braille Alphabet](https://www.pharmabraille.com/pharmaceutical-braille/the-braille-alphabet/)
|
||||||
|
|
||||||
|
### the-cake-is-not-a-lie
|
||||||
|
* Completed in: 10 mins, 5 secs.
|
||||||
|
|||||||
23
extra/the-cake-is-not-a-lie/solution.py
Normal file
23
extra/the-cake-is-not-a-lie/solution.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
def solution(s):
|
||||||
|
for i in range(len(s)):
|
||||||
|
count = i + 1
|
||||||
|
if len(s) % count != 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
is_equal = True
|
||||||
|
piece = s[:count]
|
||||||
|
for j in range(len(s) / count):
|
||||||
|
if piece != s[j*count:(j+1)*count]:
|
||||||
|
is_equal = False
|
||||||
|
break
|
||||||
|
if is_equal:
|
||||||
|
return len(s)/count
|
||||||
|
|
||||||
|
tests = [
|
||||||
|
("abcabcabcabc", 4),
|
||||||
|
("abccbaabccba", 2),
|
||||||
|
]
|
||||||
|
|
||||||
|
for i, o in tests:
|
||||||
|
result = solution(i)
|
||||||
|
print (i, result == o, result, o)
|
||||||
Loading…
x
Reference in New Issue
Block a user