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
type Nodo = ((Int,Integer),(Int,Integer)) | |
nivelGiros :: [(Int,Integer)] -> [(Int,Integer)] | |
nivelGiros xs = concatMap g xs where | |
g :: (Int,Integer) -> [(Int,Integer)] | |
g (n,x) = [(n,izq),(n+1,der)] where | |
izq = if even x then par else rimpar | |
der = if even x then rpar else impar | |
par = quot x 2 | |
impar = quot (3*x + 1) 2 |
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
type Nodo = (Int, (Integer,Integer)) | |
nivelArbolLista xs = concatMap g xs where | |
g (n, y) = [izq,der] where | |
izq = (n, fizq y) | |
der = (n+1, fder y) | |
fizq x = if even x | |
then quot x 2 | |
else quot (x + 3^n) 2 | |
fder x = if odd x |
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
type BiNodo = (Int,[(Integer,(Int,Integer))]) | |
nivelArbolBiLista :: BiNodo -> BiNodo | |
nivelArbolBiLista (k,xs) = (k+1,concatMap g xs) where | |
d = 2^k | |
g (x,(n,y)) = [izq,der] where | |
izq = (ii,(n,di)) | |
der = (id,(n+1,dd)) | |
(ii,id) = if even y then (x,x+d) else (x+d,x) | |
di = if even y |
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
----------------- por estilo --------------------- | |
import Prelude hiding ((/)) | |
infixl 7 / | |
(/) = quot | |
par = even | |
impar = odd | |
-------------------------------------------------- |
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 os import system as run | |
def pars(x): return (x*"(" + "1" + x*")") | |
def programa(x): return "int main () { return " + pars(x) + "; }\n" | |
# rango seleccionado al tanteo, manipulando para encontrar el primero que falla | |
for i in range(2**16 + 2**15 + 2**13 + 2**10,2**17): | |
print "---------- " + str(i) + " ----------" | |
fh = open ("parens.c", "w") |
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
----------------- por estilo --------------------- | |
import Prelude hiding ((/)) | |
infixl 7 / | |
(/) = quot | |
par = even | |
impar = odd | |
----------------- REFLEJOS --------------- |
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
last pid: 3083; load averages: 0.15, 0.17, 0.09 up 0+02:17:10 07:58:24 | |
20 processes: 1 running, 19 sleeping | |
CPU: 0.8% user, 0.0% nice, 1.6% system, 1.6% interrupt, 96.1% idle | |
Mem: 73M Active, 59M Inact, 40M Wired, 1424K Cache, 34M Buf, 60M Free | |
Swap: 512M Total, 580K Used, 511M Free | |
PID USERNAME THR PRI NICE SIZE RES STATE TIME WCPU COMMAND | |
2918 jaime 1 61 5 6588K 3872K select 0:00 0.00% ratpoison | |
3072 jaime 4 53 5 10616K 5216K ucond 0:00 0.00% cmus | |
2972 jaime 6 49 5 74068K 60104K ucond 0:20 0.00% /home/jaime/opera-dir/lib/opera/opera |
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
takeUntil :: (a -> Bool) -> [a] -> [a] | |
takeUntil _ [] = [] | |
takeUntil p (x:xs) | |
| (not.p) x = x : takeUntil p xs | |
| otherwise = [x] | |
paso :: (Integer, Integer, Integer, Integer) -> (Integer, Integer, Integer, Integer) | |
paso (numimpares,secuencia,x,reg) = (numimpares',secuencia',x',reg') where | |
x' = quot x 2 | |
corregido = if odd x then reg + 3^numimpares else reg |
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
-- Como recurrencias, operando sobre listas infinitas paralelas | |
-- con función x1 + x3 | |
t1 = True : False : False : True : zipWith (/=) (drop 1 t1) (drop 3 t1) | |
-- x1 + x2 + x3 | |
t2 = True : False : False : True : zipWith3 g (drop 1 t2) (drop 2 t2) (drop 3 t2) where | |
g a b c = (a /= b) /= c | |
leer n xs = take n $ map (\k -> if k then '1' else 0') xs |
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
zipWithN f = foldl1 (zipWith f) | |
generar :: String -> [Int] -> [Bool] | |
generar inicial indices = ts where | |
ts = xs ++ zipWithN (/=) (g indices) | |
xs = map (== '1') inicial | |
g = map ((flip drop) ts) | |
leer n xs = take n $ map (\k -> if k then '1' else '0') xs |