Skip to content

Commit

Permalink
Merge pull request keon#126 from yunshuipiao/master
Browse files Browse the repository at this point in the history
fix factor_combinations and readme
  • Loading branch information
ankit167 authored Feb 5, 2018
2 parents 82198b8 + 315abd0 commit e2f56eb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Minimal and clean example implementations of data structures and algorithms in P
- [backtrack](backtrack)
- [general_solution.md](backtrack/)
- [anagram](backtrack/anagram.py)
- [array_sum_combinations](backtrack/array_sum_combination.py)
- [array_sum_combinations](backtrack/array_sum_combinations.py)
- [combination_sum](backtrack/combination_sum.py)
- [expression_add_operators](backtrack/expression_add_operators.py)
- [factor_combinations](backtrack/factor_combinations.py)
Expand Down
3 changes: 2 additions & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ python版数据结构和算法实现的简约版小示例
- [backtrack:回溯](backtrack)
- [general_solution.md:一般方法](backtrack/)
- [anagram:同字母异序词](backtrack/anagram.py)
- [array_sum_combinations:数组和](backtrack/array_sum_combination.py)
- [array_sum_combinations:数组和](backtrack/array_sum_combinations.py)
- [combination_sum:和的合并](backtrack/combination_sum.py)
- [expression_add_operators:给表达式添加运算符](backtrack/expression_add_operators.py)
- [factor_combinations:因素组合](backtrack/factor_combinations.py)
Expand Down Expand Up @@ -211,4 +211,5 @@ python版数据结构和算法实现的简约版小示例
- [trie:字典](tree/trie/trie.py)
- [union-find:并查集](union-find)
- [count_islands:岛计数](union-find/count_islands.py)
- [或者可以用不同语言来完成上述算法,期待加入](https://github.com/yunshuipiao/sw-algorithms)

6 changes: 3 additions & 3 deletions backtrack/factor_combinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def getFactors(self, n):
n, i, combi = todo.pop()
while i * i <= n:
if n % i == 0:
combis += combi + [i, n/i],
todo += (n/i, i, combi+[i]),
combis.append(combi + [i, n/i]),
todo.append( [n / i, i, combi+[i] ] ) # python3: n // i
i += 1
return combis

Expand All @@ -53,7 +53,7 @@ def getFactors(self, n):
def factor(n, i, combi, combis):
while i * i <= n:
if n % i == 0:
combis += combi + [i, n/i],
combis.append(combi + [i, n/i]),
factor(n/i, i, combi+[i], combis)
i += 1
return combis
Expand Down

0 comments on commit e2f56eb

Please sign in to comment.