Skip to content

Instantly share code, notes, and snippets.

View psqq's full-sized avatar
🙃
Where is my mind?

Sergey Pestov psqq

🙃
Where is my mind?
View GitHub Profile
@psqq
psqq / intput.txt
Last active January 8, 2016 19:44
semigroup iso
[
[[0, 0],
[0, 1]],
[[0, 1],
[1, 1]]
]
@psqq
psqq / README.txt
Last active January 10, 2016 15:30
semigroups_iso
=== Запуск ===
Чтобы запустить программу выполните файл main.exe
Когда программа закончит работу нажмите <Enter> чтобы выйти.
=== Описание ===
Программа для проверки полурешеток на изоморфизм.
=== Вход ===
Входные данные: фалй input.txt содержаший две таблицы для полурешеток.
class Number < Struct.new(:value)
def to_s
value.to_s
end
def inspect
"\"#{self}\""
end
import System.IO
import Control.Monad
import Data.Tree
import Data.List
import System.Environment
-------------------------------------------------------------------------------
encodeTree (Node root []) = "01"
encodeTree (Node root childs) = "0" ++ intercalate "" (sort $ map encodeTree childs) ++ "1"
isIsomorphic t1 t2 = encodeTree t1 == encodeTree t2
import sys
a = []
def go(s, c0, c1, n):
if c0 + c1 == 2*n:
a.append(s)
elif c0 == 0 or c0 == c1:
go(s + "0", c0+1, c1, n)
elif c0 == n:
import sys
a = []
def go(s, c0, c1, n):
if c0 + c1 == 2*n:
a.append(s)
elif c0 == 0 or c0 == c1:
go(s + "0", c0+1, c1, n)
elif c0 == n:
# http://stackoverflow.com/questions/400794/generating-the-partitions-of-a-number
def partitions(n):
if n == 0: yield []
if n <= 0: return
for p in partitions(n-1):
if len(p) == 1 or (len(p) > 1 and p[-1] < p[-2]):
p[-1] += 1
yield p
import Data.List (genericIndex)
a027750 n k = a027750_row n !! (k-1)
a027750_row n = filter ((== 0) . (mod n)) [1..n]
a027750_tabf = map a027750_row [1..]
a000081 = genericIndex a000081_list
a000081_list = 0 : 1 : f 1 [1, 0] where
f x ys = y : f (x + 1) (y : ys) where
y = sum (zipWith (*) (map h [1..x]) ys) `div` x
h = sum . map (\d -> d * a000081 d) . a027750_row
# https://repl.it/BnaK
t_ran_poz = [(0,0),(8,9),(17,40),(13,13),(20,20),(23,26),(29,29),(33,43),(37,38),(42,42),(48,48),(61,61)]
rabots = [(0,1,8),(0,3,13),(0,4,9),(1,2,9),(1,3,4),(1,5,6),(2,7,3),(3,4,7),(3,5,10),(3,6,6),
(4,6,9),(4,8,10),(4,9,6),(5,6,3),(5,7,8),(6,7,4),(6,8,8),(6,9,13),(6,10,5),(7,10,5),
(8,9,4),(9,10,6),(9,11,17),(10,11,13)]
# Сроки начала и окночания работ
t_ran_nach = [t_ran_poz[r[0]][0] for r in rabots]
@psqq
psqq / SConstruct
Created February 29, 2016 13:53
scons
env=Environment(CPPPATH='/usr/include/boost/',
CPPDEFINES=[],
LIBS=[],
SCONS_CXX_STANDARD="c++11"
)
env.Program('Hello', Glob('src/*.cpp'))