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
| w x r=d:w(100*(x-20*r*d-d*d))(10*r+d)where d=head(filter(\d -> 20*r*d+d*d>=x)[0..])-1 | |
| nthSqrt2 n d=foldl1(++).map show.map((!!)$w 2 0)$[(1+n)..(d+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.Char | |
| import Data.List | |
| stringsRearrangement_ inputArray = zap | |
| where chars = map (map $ ord) inputArray | |
| zap = foldl1 (&&) $ map (==1) . map (sum). map (map (\x -> if (x == 0) then 0 else 1) ) . zipWith (\x y-> zipWith (-) x y) chars $ tail chars | |
| stringsRearrangement xs = foldl1 (||) $ map stringsRearrangement_ $ permutations 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
| import Data.List | |
| import Data.Char | |
| data Operator = Plus | Minus | Times | Div | LParen | RParen | Equals | Dot | XOR | Semi | LBracket | RBracket | GreaterThan | LessThan | LBrace | RBrace | Comma | Mod | QMark | Colon | And | Or | At | BitNeg | Hash | RDiv | LNot | |
| deriving (Show, Eq) | |
| data Token = TokOp Operator | |
| | TokIdent String | |
| | TokString String | |
| | TokNum String |
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 fractions as f | |
| def clockRadian(time): | |
| h, m = tuple(map(int, time.split(':'))) | |
| t = abs((h % 12) * 60 - m * 12 + m) | |
| t = 720 - t if t > 360 else t | |
| if t == 0: | |
| return "0" | |
| a = f.Fraction(t, 360) | |
| b = a.numerator | |
| c = a.denominator |
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
| prevPalindrome x = head$dropWhile e [x-1,x-2..] | |
| s=show | |
| e x = s x /= (reverse$s 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
| import Data.Char | |
| import Data.List | |
| stringsRearrangement_ inputArray = zap | |
| where chars = map (map $ ord) inputArray | |
| zap = foldl1 (&&) $ map (==1) . map (sum). map (map (\x -> if (x == 0) then 0 else 1) ) . zipWith (\x y-> zipWith (-) x y) chars $ tail chars | |
| stringsRearrangement xs = foldl1 (||) $ map stringsRearrangement_ $ permutations 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
| #define x substr | |
| auto singkatan(auto w, auto q) { | |
| int a=w.length(),b=q.length(),m=a<b?a:b; | |
| while(m--)if(w.x(a-m-1,m+1)==q.x(0,m+1))q=q.x(m+1,b-m); | |
| return w+q; | |
| } |
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 | |
| thatsOdd = odd . sum . map (ord) |
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
| auto steganographer(vector<vector<long long>> r, int e) { | |
| bool f[r.size() * r[0].size()],*t; | |
| int z = 0; | |
| for (i:r) | |
| for (j:i) | |
| for(l:{3,2,1,0}) | |
| if (e&(1<<l)) f[z++] = j >> 8*l & 1; | |
| string s; | |
| for (t = f; t < f + z; t += 7) | |
| s += accumulate(t, t + 7, 0, [](int x, int y) { return (x << 1) + 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
| int surviveIt(int n){ | |
| // Get the index of the most significant bit. | |
| asm ("bsrl %1,%0" : "=r" (n) : "r" (n)); | |
| return 1<<n; | |
| } | |
| // movl $1, %eax | |
| // bsrl %edi, %ecx | |
| // sall %cl, %eax | |
| // ret |