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 msvcrt | |
import sys | |
def secret_input(prompt,char=""): | |
'''get terminal input without showing the input''' | |
fb = lambda n: int.from_bytes(n,byteorder="big")# lambda to convert bytes into int | |
#show prompt, then flush buffer to redraw | |
print(prompt,end="") | |
sys.stdout.flush() |
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
//originally it was written on | |
template <class... S> | |
std::string concat(const S&... strs) { | |
std::string_view views[]{strs...}; | |
int totalsize = std::accumulate(std::begin(views), std::end(views), 0, [](int count, std::string_view v){return count + v.size();}); | |
std::string result(totalsize, '\0'); | |
int cur_pos = 0; | |
for(const auto& v : views){ | |
std::copy(v.begin(), v.end(), result.begin() + cur_pos); |
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
module Coder(encode,decode) where | |
import Data.Word | |
import Data.Char(ord,chr) | |
import Data.Bits(xor) | |
import qualified Data.ByteString.Char8 as C | |
import qualified Data.ByteString as B | |
tp n ls = takeWhile(not.null) $ map(take n.flip drop ls) [0,n..] | |
conv_key key = [fromIntegral $ ord x | x <- key] |
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(digitToInt) | |
main::IO() | |
main = print $ sum $ map digitToInt $ show $ product[1..100] |
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
sum1::[Int] -> Int | |
sum1 seq = sum [x*x | x <- seq] | |
sum2::[Int] -> Int | |
sum2 seq = | |
let s = sum [x | x <- seq] | |
in s*s | |
main::IO() | |
main = print $ sum2 [1..100] - sum1 [1..100] |
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
{- | |
#1 task from https://projecteuler.net/archives | |
Find the sum of all the multiples of 3 or 5 below 1000. | |
-} | |
mult::Int -> Bool | |
mult x = x `mod` 5 == 0 || x `mod` 3 == 0 | |
filter_seq::[Int] -> [Int] | |
filter_seq seq = [x | x <- seq, mult 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
kolc::Integer -> Integer | |
kolc n | even n = toInteger n `div` 2 | |
kolc n | not $ even n = (n*3)+1 | |
gks'::[Integer] -> [Integer] | |
gks' xs = xs ++ [kolc $ last xs] | |
gks::[Integer] -> [Integer] | |
gks xs | (last xs) == 1 = 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 os | |
_all = os.listdir(os.getcwd()) | |
files = list(filter(lambda n: os.path.isfile(n),_all)) | |
def is_cpp(file): | |
ext = [".cpp",".hpp",".h",".c"] | |
for e in ext: | |
if file.endswith(e): | |
return True |
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
#ifndef MATRIX_H | |
#define MATRIX_H | |
#include<variant> | |
using namespace std; | |
template<class T> | |
class Matrix | |
{ | |
private: | |
T** matrix; |
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 sys | |
from functools import reduce | |
def read(file): | |
with open(file,"rb") as f: | |
return f.read() | |
all_data = list(map(read,sys.argv[1:])) | |
concated = reduce(lambda a,b:a+b,all_data) | |
concated = concated |
NewerOlder