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
object SHA256 { | |
val k: Seq[Int] = Seq( | |
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, | |
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, | |
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, | |
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, | |
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, | |
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, | |
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, | |
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2) |
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<type_traits> | |
#include<iostream> | |
struct nat {}; | |
template<typename T> | |
using is_nat = std::enable_if_t<std::is_base_of<nat, T>::value>; | |
template<typename N, typename = is_nat<N>> | |
struct suc : nat {}; |
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<chrono> | |
#include<cmath> | |
#include<iomanip> | |
#include<iostream> | |
#include<fstream> | |
#include<string> | |
#include<utility> | |
#include<gmpxx.h> | |
#include<omp.h> | |
#include<unistd.h> |
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<cmath> | |
#include<iomanip> | |
#include<iostream> | |
#include<gmpxx.h> | |
constexpr unsigned DIGIT = 10'000'001; | |
int main() { | |
mpf_class a = 1_mpf; | |
mpf_class b = 1_mpf / sqrt(2_mpf); |
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<cmath> | |
#include<iomanip> | |
#include<iostream> | |
#include<gmpxx.h> | |
int main() { | |
unsigned digit = 10000; | |
mpf_set_default_prec((digit + 1) * log2(10)); | |
mpf_class pi = 0; | |
unsigned m = digit / 4; |
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
object Base64 { | |
def main(args: Array[String]): Unit = { | |
val str = "input here" | |
val result = str.getBytes | |
.flatMap(b => (0 until 8).map(n => (b >> (7 - n)) & 1)) | |
.grouped(6) | |
.map(b => b.indices.map(n => b(n) << (5 - n)).sum) | |
.map("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"(_)) | |
.grouped(4) | |
.flatMap(_.padTo(4, '=')) |
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 scala.io.StdIn | |
object SudokuSolver { | |
def main(args: Array[String]): Unit = { | |
val board = Vector.fill(9)(StdIn.readLine) | |
.map(_.replace('*', '0').map(_.toString.toInt)) | |
val possibilities = { | |
val transposed = board.transpose | |
val divided = Seq.tabulate(3, 3) { (oy, ox) => |
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
from PIL import Image | |
from datetime import datetime | |
from pathlib import Path | |
import imghdr | |
import os | |
import shutil | |
for path in Path.cwd().iterdir(): | |
if Path.is_dir(path) or imghdr.what(path) != 'jpeg': continue | |
exif = Image.open(path)._getexif() |
NewerOlder