diff --git a/README.md b/README.md index 9cf7eaa..255c8f9 100644 --- a/README.md +++ b/README.md @@ -122,3 +122,6 @@ CFcSBwgCCBoHRhkKU1cGAA4AGU5YQR5THBwNFwoGGAxTQQMQVBUSBg4EAAwQRhUQVBUHFAQTGRpT QQM * Completed in: 18 mins, 46 secs. * Reference * [The Braille Alphabet](https://www.pharmabraille.com/pharmaceutical-braille/the-braille-alphabet/) + +### the-cake-is-not-a-lie +* Completed in: 10 mins, 5 secs. diff --git a/extra/the-cake-is-not-a-lie/solution.py b/extra/the-cake-is-not-a-lie/solution.py new file mode 100644 index 0000000..0c4d037 --- /dev/null +++ b/extra/the-cake-is-not-a-lie/solution.py @@ -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)