This file contains 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 System.Random | |
import Control.Monad (when) | |
makeBitStrings :: Int -> [String] | |
makeBitStrings 0 = [] | |
makeBitStrings 1 = ["0","1"] | |
makeBitStrings w = map ('0':) (makeBitStrings (w-1)) ++ map ('1':) (makeBitStrings (w-1)) | |
makeMaskZeroStrings :: Int -> [String] | |
makeMaskZeroStrings w = ((map oneToMask) . makeBitStrings) w |
This file contains 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
main = print $ filter (\(_,y) -> y > 400) $ take 5000 $ map (\(x,y) -> (x, length y)) l | |
tris :: [Integer] | |
tris = [ n*(n+1) `div` 2 | n <- [1..]] | |
isTriangle :: Int -> Bool | |
isTriangle x = n*(n+1) == m | |
where n = floor $ sqrt (fromIntegral (2*x)) | |
m = fromIntegral 2*x |
This file contains 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
--main :: IO () | |
--main = putStrLn "Hello, what is your name?" >> getLine >>= \n -> putStrLn n | |
import Data.Char | |
import System.Environment | |
import Control.Exception | |
-- (>>) :: IO a -> IO b -> IO b | |
-- (>>=) :: IO a -> (a -> IO b) -> IO b |
This file contains 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
@31.136.135.217/32 105.200.113.38/32 0 : 65535 443 : 443 0x06/0xFF 0x0000/0x0200 | |
@93.234.40.32/32 20.35.91.246/32 0 : 65535 21 : 21 0x11/0xFF 0x0000/0x0000 | |
@93.230.104.122/32 105.200.113.45/32 0 : 65535 5730 : 5730 0x06/0xFF 0x0000/0x0000 | |
@93.230.104.122/32 83.23.62.240/32 0 : 65535 80 : 80 0x11/0xFF 0x0000/0x0000 | |
@106.4.123.45/32 166.106.208.51/32 0 : 65535 80 : 80 0x06/0xFF 0x0000/0x0000 | |
@99.56.209.158/32 164.32.106.12/32 0 : 65535 80 : 80 0x06/0xFF 0x0000/0x0000 | |
@60.238.186.221/32 154.116.147.158/32 0 : 65535 138 : 138 0x11/0xFF 0x0000/0x0000 | |
@20.46.247.22/32 151.26.49.195/32 0 : 65535 443 : 443 0x11/0xFF 0x0000/0x0000 | |
@20.46.247.22/32 60.220.91.198/32 0 : 65535 25 : 25 0x06/0xFF 0x0000/0x0000 | |
@29.41.178.227/32 20.35.91.246/32 0 : 65535 8080 : 8080 0x11/0xFF 0x0000/0x0000 |
This file contains 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.Split | |
-- reverse $ int2bin' 32 63 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1] | |
-- int2bin' c n は n を c 桁の2進表記へ変換する函数.ただし,逆順に表示される.つまり,右の方が位が高い. | |
int2bin' :: Int -> Int -> [Int] | |
int2bin' 0 _ = [] | |
int2bin' c 0 = 0 : int2bin' (c-1) 0 | |
int2bin' c n = n `mod` 2 : int2bin' (c-1) (n `div` 2) |
This file contains 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
// g++ -std=c++11 set.cpp | |
#include <iostream> | |
#include <unordered_set> | |
#include <algorithm> | |
#include <iterator> | |
using namespace std; | |
int main() |
This file contains 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 System.IO | |
import System.Directory | |
import System.Environment | |
import Control.Applicative | |
import Control.Monad | |
import Data.List | |
main :: IO () | |
main = do | |
(filename:[]) <- getArgs |
This file contains 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
#include <stdio.h> | |
#include <gmp.h> | |
// -lgmp | |
int main(void) | |
{ | |
long a = 1, b = 3, c = 6; | |
mpq_t x, y, z; | |
mpq_init(x); |
This file contains 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 | |
isC1P :: [String] -> Bool | |
isC1P xss = (or . map strongC1P . map transpose . permutations . transpose) xss | |
strongC1P :: [String] -> Bool | |
strongC1P xss = (and . map oneConsecutive) xss | |
oneConsecutive :: String -> Bool | |
oneConsecutive xs = 3 > fst (foldr (\x (i,y) -> if x /= y then (i+1,x) else (i,y)) (0,'0') xs) |
This file contains 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.Applicative | |
import Data.Array.IO | |
import Data.Char | |
-- http://d.hatena.ne.jp/eiel/20120217 | |
{- | |
3 4 4 | |
1101 |