Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AK-wang/0006/key_word.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def wc(filename):


def most_comm():
for txt in list_txt():
all_txt = list_txt()
for txt in all_txt:
print wc(txt)

if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion AK-wang/0011/filtered_words.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def filtered_words(f_file):


def filtered_or_not(input_word, f_file):
return (input_word in filtered_words(f_file))
filtered_words_list = filtered_words(f_file)
return (input_word in filtered_words_list)


def print_user_input(input_word, f_file):
Expand Down
3 changes: 2 additions & 1 deletion AK-wang/0012/f_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def f_replace(f_word, input_str):


def main(f_file, input_str):
for f_word in f_words(f_file):
f_words_list = f_words(f_file)
for f_word in f_words_list:
if filtered_or_not(f_word, input_str):
input_str = f_replace(f_word, input_str)
return input_str
Expand Down
26 changes: 26 additions & 0 deletions AK-wang/A0000/sushu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/env python
#寻找n以内的素数,看执行时间,例子100000内的素数

def prime(n):
all = range(n+1)
flag = [1]*(n+2)
flag[1] = 0 # 1 is not prime
flag[n+1] = 1
p=2
while(p<=n):
print p
i = 2*p
for i in range(n+1)[::p]:
flag[i] = 0
while True:
p += 1
if(flag[p]==1):
break
# test
prime(100000)

# 9592 numbers
# time
#real 0m58.866s
#user 0m58.286s
#sys 0m0.124s