Skip to content

Commit b2316b4

Browse files
committed
tentando solucionar o problema xor and sum
1 parent ee86d27 commit b2316b4

File tree

13 files changed

+579
-29
lines changed

13 files changed

+579
-29
lines changed

python/Xor/.idea/workspace.xml

Lines changed: 110 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/Xor/solutions/XorAndSum.py

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,51 @@ def naive_test(a, b):
2323
return acc
2424

2525

26-
def solver():
26+
def run():
2727
bin_a = input()
2828
bin_b = input()
29-
a, b = toDec(bin_a), toDec(bin_b)
30-
return naive_test(a, b)
29+
max_length = max(len(bin_a), len(bin_b))
30+
reverse_a = [0] * max_length
31+
for i in range(0, len(bin_a)):
32+
reverse_a[i] = bin_a[len(bin_a)-1-i]
33+
reverse_b = [0] * max_length
34+
for i in range(0, len(bin_b)):
35+
reverse_b[i] = bin_b[len(bin_b)-1-i]
36+
37+
return reverse_a, reverse_b
38+
39+
def solver():
40+
reverse_a, reverse_b = run()
41+
limit = 314519
42+
mod = 1000000007
43+
count_bits_b = 0
44+
power = 1
45+
acc = 0
46+
i = 0
47+
while i < max_length:
48+
count_bits_b += int(reverse_b[i])
49+
m = count_bits_b if reverse_a[i] == '0' else limit - count_bits_b + 1
50+
acc = (acc + power * m) % mod
51+
power = (power << 1) % mod
52+
i += 1
53+
54+
while i <= limit:
55+
acc = (acc + power * count_bits_b) % mod
56+
power = (power << 1) % mod
57+
i += 1
58+
59+
for i in range(0, max_length):
60+
acc = (acc + power * count_bits_b) % mod
61+
power = (power << 1) % mod
62+
count_bits_b -= int(reverse_b[i])
63+
i += 1
64+
65+
return acc
66+
67+
68+
def solver_2():
69+
reverse_a, reverse_b = run()
70+
return
3171

3272

3373
print(solver())

python/minimax/.idea/minimax.iml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/minimax/.idea/misc.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/minimax/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/minimax/.idea/workspace.xml

Lines changed: 171 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/minimax/raw/minimax

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
https://www.hackerearth.com/blog/artificial-intelligence/minimax-algorithm-alpha-beta-pruning/
2+
https://www.geeksforgeeks.org/minimax-algorithm-in-game-theory-set-4-alpha-beta-pruning/
3+
4+
5+
Pesquisar
6+
algorithm tic tac toe Alpha Beta Pruning
7+
https://www3.ntu.edu.sg/home/ehchua/programming/java/javagame_tictactoe_ai.html
8+
https://medium.com/@pelensky/ruby-tic-tac-toe-negamax-with-alpha-beta-pruning-c1126172fb5a
9+
https://en.wikipedia.org/wiki/Alpha%E2%80%93beta_pruning
10+
http://catarak.github.io/blog/2015/01/07/solving-tic-tac-toe/
11+
https://www.hackerearth.com/blog/artificial-intelligence/minimax-algorithm-alpha-beta-pruning/
12+
13+
14+
Zero sum
15+
https://en.wikipedia.org/wiki/Zero-sum_game
16+
17+
18+
http://will.thimbleby.net/algorithms/doku.php?id=minimax_search_with_alpha-beta_pruning
19+
https://www.ntu.edu.sg/home/ehchua/programming/java/JavaGame_TicTacToe_AI.html
20+
21+
22+
https://tonypoer.io/2016/10/28/implementing-minimax-and-alpha-beta-pruning-using-python/
23+
https://github.com/siddeshpillai/minimax/blob/master/ttt.py

python/stockmax/.idea/misc.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/stockmax/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/stockmax/.idea/stockmax.iml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)