Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,23 @@
|
|||
from itertools import groupby
|
||||
|
||||
def collapser(txt):
|
||||
return ''.join(item for item, grp in groupby(txt))
|
||||
|
||||
if __name__ == '__main__':
|
||||
strings = [
|
||||
"",
|
||||
'"If I were two-faced, would I be wearing this one?" --- Abraham Lincoln ',
|
||||
"..1111111111111111111111111111111111111111111111111111111111111117777888",
|
||||
"I never give 'em hell, I just tell the truth, and they think it's hell. ",
|
||||
" --- Harry S Truman ",
|
||||
"The better the 4-wheel drive, the further you'll be from help when ya get stuck!",
|
||||
"headmistressship",
|
||||
"aardvark",
|
||||
"😍😀🙌💃😍😍😍🙌",
|
||||
]
|
||||
for txt in strings:
|
||||
this = "Original"
|
||||
print(f"\n{this:14} Size: {len(txt)} «««{txt}»»»" )
|
||||
this = "Collapsed"
|
||||
sqz = collapser(txt)
|
||||
print(f"{this:>14} Size: {len(sqz)} «««{sqz}»»»" )
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
'''Determining if a string is collapsible'''
|
||||
|
||||
from operator import eq
|
||||
|
||||
|
||||
# isCollapsible :: String -> Bool
|
||||
def isCollapsible(s):
|
||||
'''True if s contains any consecutively
|
||||
repeated characters.
|
||||
'''
|
||||
return False if 2 > len(s) else (
|
||||
any(map(eq, s, s[1:]))
|
||||
)
|
||||
|
||||
|
||||
# ------------------------- TEST --------------------------
|
||||
# main :: IO ()
|
||||
def main():
|
||||
'''Determining whether each string is collapsible'''
|
||||
xs = [
|
||||
"",
|
||||
'"If I were two-faced, would I be wearing this one?" --- Abraham Lincoln ',
|
||||
"..1111111111111111111111111111111111111111111111111111111111111117777888",
|
||||
"I never give 'em hell, I just tell the truth, and they think it's hell. ",
|
||||
" --- Harry S Truman ",
|
||||
"The better the 4-wheel drive, the further you'll be from help when ya get stuck!",
|
||||
"headmistressship",
|
||||
"aardvark",
|
||||
"😍😀🙌💃😍😍😍🙌",
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
]
|
||||
print([
|
||||
isCollapsible(x) for x in xs
|
||||
])
|
||||
|
||||
|
||||
# MAIN ---
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue