This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from card import Card, FACE | |
from enum import Enum | |
from itertools import permutations | |
from enum import Enum | |
class Hand(Enum): | |
ROYAL_FLUSH = 1 | |
STRAIGHT_FLUSH = 2 | |
FOUR_OF_A_KIND = 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (a *Analyser) Run(ctx context.Context) { | |
ticker := time.NewTicker(10 * time.Minute) | |
defer ticker.Stop() | |
for { | |
select { | |
case <-ctx.Done(): | |
return | |
case <-ticker.C: | |
source, err := a.dbConn.GetUnratedSource(ctx) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Function | |
= Var | |
| Sum Function Function | |
| Product Function Function | |
| Const Int | |
| Ln Function | |
| Pow Function Function | |
| Exp Function | |
| Sin Function | |
| Cos Function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Expr | |
= One | |
| Zero | |
| Var | |
| And Expr Expr | |
| Or Expr Expr | |
| Not Expr | |
deriving (Show) | |
eval :: Expr -> Expr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_sub(arr): | |
x = arr[0] | |
for n in arr[1:-1]: | |
x ^= n | |
y = arr[-1] # we want x ^ y == 0 | |
diff = y - (x ^ 0) | |
if diff < 0: # if negative difference, try a different last element | |
return find_sub([arr[-1], *arr[:-1]]) | |
return diff, y |