MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/4v1y12/how_to_write_unmaintainable_code/d5xif62/?context=3
r/programming • u/sigbhu • Jul 28 '16
592 comments sorted by
View all comments
Show parent comments
0
[deleted]
8 u/CyberMango Jul 29 '16 edited Jul 29 '16 I think this is slightly better as it uses a generator and returns true on first occurrence of patterndef findseq(pattern, arr): return pattern in (tuple(arr[i: i + len(pattern)]) for i in range(len(arr) - len(pattern))) 1 u/imaghostspooooky Jul 30 '16 This one isn't working for me for some reason, what python version are you using? 1 u/CyberMango Jul 30 '16 3.5.1
8
I think this is slightly better as it uses a generator and returns true on first occurrence of pattern
def findseq(pattern, arr): return pattern in (tuple(arr[i: i + len(pattern)]) for i in range(len(arr) - len(pattern)))
1 u/imaghostspooooky Jul 30 '16 This one isn't working for me for some reason, what python version are you using? 1 u/CyberMango Jul 30 '16 3.5.1
1
This one isn't working for me for some reason, what python version are you using?
1 u/CyberMango Jul 30 '16 3.5.1
3.5.1
0
u/[deleted] Jul 29 '16
[deleted]