Skip to content

Instantly share code, notes, and snippets.

View shouth's full-sized avatar
💭
🤩

Shota Minami shouth

💭
🤩
View GitHub Profile
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()
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) =>
#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);
#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;
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, '='))
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)
#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 {};

これは何

ソフトウェア工学の課題でHello, world!難読化の課題が出たので面白がってやってたら何個かできたので紹介するよ! 授業では課題の提出物から何個かピックアップされて紹介されてたけど,作者はこの課題の締切には間に合わせたけど提出が遅かったからピックアップの対象の中に入ってさえいなかったよ!ちょっと悲しいね!

各プログラムの解説を途中まで書いてたけどめんどくさくなってきたから各プログラムの紹介で読解のためのヒント出す程度に留めることにするよ!

ただ読解するにも通常とはやや異なる書き方をしている部分があるから先にそこの説明だけしておくよ!

C言語では

#include<chrono>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<string>
#include<utility>
#include<gmpxx.h>
#include<omp.h>
#include<unistd.h>
@shouth
shouth / sudoku_solver.c
Last active July 16, 2020 23:23
Sudoku solver with Dancing Links and Knuth's Algorithm X.
/**
* @file sudoku_solver.h
* @brief Dancing Linksで数独をExact Cover ProblemとしてKnuth's Algorithm Xで解くプログラムです.
* @note 課題の提出からしばらく経ってポインタの理解が深まってから書き直したバージョンです.
* @author Shota Minami
*/
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>