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
| import Control.Monad | |
| import Control.Monad.State | |
| type ListZipper a = ([a], [a]) | |
| -- move focus forward, put previous root into breadcrumbs | |
| goForward :: ListZipper a -> ListZipper a | |
| goForward (x:xs, bs) = (xs, x:bs) | |
| -- move focus back, restore previous root from breadcrumbs |
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
| import Control.Monad | |
| import Control.Monad.State | |
| import Control.Monad.Trans.Writer | |
| type ListZipper a = ([a], [a]) | |
| -- move focus forward, put previous root into breadcrumbs | |
| goForward :: ListZipper a -> ListZipper a | |
| goForward (x:xs, bs) = (xs, x:bs) |
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
| import Control.Monad | |
| import Control.Monad.Writer | |
| import Control.Monad.Trans.State | |
| type ListZipper a = ([a], [a]) | |
| -- move focus forward, put previous root into breadcrumbs | |
| goForward :: ListZipper a -> ListZipper a | |
| goForward (x:xs, bs) = (xs, x:bs) |
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
| import Data.Char | |
| import Data.List | |
| fibSeq :: [(Integer, Integer)] | |
| fibSeq = map (\(n, (a,_)) -> (n, a)) $ iterate (\(n, (a,b))->(n+1, (b,a+b))) (1,(1,1)) | |
| fstPandigital :: Integer -> Bool | |
| fstPandigital n = charNum == "123456789" where | |
| charNum = sort $ take 9 $ show n |
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
| import Data.List (break) | |
| import Control.Monad | |
| import Control.Monad.Instances | |
| import Control.Monad.Trans | |
| import Control.Monad.Trans.Writer | |
| type Name = String | |
| type Data = String | |
| data FSItem = File Name Data | Folder Name [FSItem] deriving (Show) |
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
| // compile with args: -lstdc++ -std=c++0x | |
| #include <cstdlib> | |
| #include <cstdio> | |
| #include <algorithm> | |
| #include <numeric> | |
| int a[16]; | |
| int main() |
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
| -- complied with: ghc --make problem-14 -rtsopts | |
| -- run with: ./problem-14 +RTS -K20000000 -RTS | |
| -- time elapsed: 32.592s | |
| import qualified Data.Set as S | |
| -- (set, (x,value)) | |
| -- set: a set to keep numbers that has been calculated | |
| -- x: a number |
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
| public class Test { | |
| public static class A {} | |
| public static class B extends A {} | |
| public static class C extends A {} | |
| public interface Hello { | |
| void hello(A a); | |
| } | |
| public static class Tester implements Hello { |
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
| adb shell am start -a android.intent.action.MAIN -n com.android.development/.MediaScannerActivity |
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
| f = file( "raw", "r" ) | |
| raw = f.read() | |
| f.close() | |
| secret = ''.join( map( lambda x:chr( int(x,2)) , map( lambda x: x.replace("____", "1111") , raw.split() ) ) ) + "=" | |
| import base64 | |
| g = file("sec", "wb") | |
| g.write( base64.b64decode( secret ) ) |
OlderNewer