Skip to main content
Code Review

Return to Question

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

I've created this function that looks for sequences in a list. If [1,2,3] exists, it will print True. I've tested the code and it works fine.

def looking_patt(pattern,cursor,found):
 big_s = []
 for i in range(1,101):
 if i % 10 == 0:
 big_s.extend([1,2,3])
 else:
 big_s.append(i)
 # check control
 print(big_s)
 for i in big_s:
 if i == pattern[cursor]:
 cursor += 1
 if cursor == len(pattern):
 found.append(pattern)
 print(found)
 cursor = 0
 else:
 cursor = 0 
 
 print(len(found) > 0) 

Part of the script (the for i in big_s:) has been taken from an answer in this SO question this SO question.

How can it be improved?

I've created this function that looks for sequences in a list. If [1,2,3] exists, it will print True. I've tested the code and it works fine.

def looking_patt(pattern,cursor,found):
 big_s = []
 for i in range(1,101):
 if i % 10 == 0:
 big_s.extend([1,2,3])
 else:
 big_s.append(i)
 # check control
 print(big_s)
 for i in big_s:
 if i == pattern[cursor]:
 cursor += 1
 if cursor == len(pattern):
 found.append(pattern)
 print(found)
 cursor = 0
 else:
 cursor = 0 
 
 print(len(found) > 0) 

Part of the script (the for i in big_s:) has been taken from an answer in this SO question.

How can it be improved?

I've created this function that looks for sequences in a list. If [1,2,3] exists, it will print True. I've tested the code and it works fine.

def looking_patt(pattern,cursor,found):
 big_s = []
 for i in range(1,101):
 if i % 10 == 0:
 big_s.extend([1,2,3])
 else:
 big_s.append(i)
 # check control
 print(big_s)
 for i in big_s:
 if i == pattern[cursor]:
 cursor += 1
 if cursor == len(pattern):
 found.append(pattern)
 print(found)
 cursor = 0
 else:
 cursor = 0 
 
 print(len(found) > 0) 

Part of the script (the for i in big_s:) has been taken from an answer in this SO question.

How can it be improved?

deleted 15 characters in body; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

code that looks Looking for a pattern in a list

I've created this function.

It that looks for sequences, in a list. If [1,2,3] existexists, it will print True

. I've tested the code and it works fine.

def looking_patt(pattern,cursor,found):
 big_s = []
 for i in range(1,101):
 if i % 10 == 0:
 big_s.extend([1,2,3])
 else:
 big_s.append(i)
 # check control
 print(big_s)
 for i in big_s:
 if i == pattern[cursor]:
 cursor += 1
 if cursor == len(pattern):
 found.append(pattern)
 print(found)
 cursor = 0
 else:
 cursor = 0 
 
 print(len(found) > 0) 

Part of the script the(the for i in big_s:) has been taken from the secondan answer in this SO'sSO question.

How can it be improved?

code that looks for a pattern

I've created this function.

It looks for sequences, in a list. If [1,2,3] exist, it will print True

I've tested the code and it works fine

def looking_patt(pattern,cursor,found):
 big_s = []
 for i in range(1,101):
 if i % 10 == 0:
 big_s.extend([1,2,3])
 else:
 big_s.append(i)
 # check control
 print(big_s)
 for i in big_s:
 if i == pattern[cursor]:
 cursor += 1
 if cursor == len(pattern):
 found.append(pattern)
 print(found)
 cursor = 0
 else:
 cursor = 0 
 
 print(len(found) > 0) 

Part of the script the for i in big_s: has been taken from the second answer in this SO's question.

How can it be improved?

Looking for a pattern in a list

I've created this function that looks for sequences in a list. If [1,2,3] exists, it will print True. I've tested the code and it works fine.

def looking_patt(pattern,cursor,found):
 big_s = []
 for i in range(1,101):
 if i % 10 == 0:
 big_s.extend([1,2,3])
 else:
 big_s.append(i)
 # check control
 print(big_s)
 for i in big_s:
 if i == pattern[cursor]:
 cursor += 1
 if cursor == len(pattern):
 found.append(pattern)
 print(found)
 cursor = 0
 else:
 cursor = 0 
 
 print(len(found) > 0) 

Part of the script (the for i in big_s:) has been taken from an answer in this SO question.

How can it be improved?

deleted 17 characters in body
Source Link
BCdotWEB
  • 11.4k
  • 2
  • 28
  • 45

I've created this function.

It looks for sequences, in a list. If [1,2,3] exist, it will print True

I've tested the code and it works fine

def looking_patt(pattern,cursor,found):
 big_s = []
 for i in range(1,101):
 if i % 10 == 0:
 big_s.extend([1,2,3])
 else:
 big_s.append(i)
 # check control
 print(big_s)
 for i in big_s:
 if i == pattern[cursor]:
 cursor += 1
 if cursor == len(pattern):
 found.append(pattern)
 print(found)
 cursor = 0
 else:
 cursor = 0 
 
 print(len(found) > 0) 

Part of the script the for i in big_s: has been taken from the second answer in this SO's question.

How can it be improved?

Thanks

I've created this function.

It looks for sequences, in a list. If [1,2,3] exist, it will print True

I've tested the code and it works fine

def looking_patt(pattern,cursor,found):
 big_s = []
 for i in range(1,101):
 if i % 10 == 0:
 big_s.extend([1,2,3])
 else:
 big_s.append(i)
 # check control
 print(big_s)
 for i in big_s:
 if i == pattern[cursor]:
 cursor += 1
 if cursor == len(pattern):
 found.append(pattern)
 print(found)
 cursor = 0
 else:
 cursor = 0 
 
 print(len(found) > 0) 

Part of the script the for i in big_s: has been taken from the second answer in this SO's question.

How can it be improved?

Thanks

I've created this function.

It looks for sequences, in a list. If [1,2,3] exist, it will print True

I've tested the code and it works fine

def looking_patt(pattern,cursor,found):
 big_s = []
 for i in range(1,101):
 if i % 10 == 0:
 big_s.extend([1,2,3])
 else:
 big_s.append(i)
 # check control
 print(big_s)
 for i in big_s:
 if i == pattern[cursor]:
 cursor += 1
 if cursor == len(pattern):
 found.append(pattern)
 print(found)
 cursor = 0
 else:
 cursor = 0 
 
 print(len(found) > 0) 

Part of the script the for i in big_s: has been taken from the second answer in this SO's question.

How can it be improved?

Source Link
Andy K
  • 622
  • 3
  • 9
  • 19
Loading
lang-py

AltStyle によって変換されたページ (->オリジナル) /