Instantly share code, notes, and snippets.

🌴
On vacation

Junichi Sato sato11

🌴
On vacation
Created February 2, 2022 00:15
Probablistic primality test based on SICP 1.2.6
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
 (define (expmod base exp m) (cond ((= exp 0) 1) ((even? exp) (remainder (square (expmod base (/ exp 2) m)) m)) (else (remainder (* base (expmod base (- exp 1) m)) m)))) (define (fermat-test n)
Created November 14, 2021 07:07
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
 # Solves arithmetic puzzle. # Input four integers and the expected answer # and the program searches a possible expression. # # e.g. # in: 1,3,9,0 and 10 # out: 1+(3*0)+9 # in: 3,4,7,8 and 10 # out: (3-7/4)*8
Created October 31, 2020 05:42
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
 # test cases that i've used for the lesson below: # https://app.codility.com/programmers/lessons/5-prefix_sums/count_div/ require 'minitest/autorun' class CountDivTest < Minitest::Test def test_solution a, b, k = [6, 11, 2] assert_equal 3, solution(a, b, k)
Created July 9, 2020 12:27
notate rational number including cyclical one. e.g. to_rational(1, 7) == "0.(142857)"
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
 std::string to_rational(int numerator, int denominator) { std::string result; int n = numerator / denominator; result += std::to_string(n); if (numerator % denominator == 0) return result; result += ".";
Created March 4, 2020 14:25
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
 AWSTemplateFormatVersion: 2010-09-09 Description: | A stack to manage an S3 bucket for redirecting to the apex domain, a Route 53 DNS record for using a custom domain, and a CloudFront Distribution for high availability. Parameters: AcmCertificateArn: Type: String Description: The ARN of ACM certificate.
Created March 4, 2020 14:25
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
 AWSTemplateFormatVersion: 2010-09-09 Description: | A stack to manage an S3 bucket for hosting a static website, a Route 53 DNS record for using a custom domain, and a CloudFront Distribution for high availability. Parameters: AcmCertificateArn: Type: String Description: The ARN of ACM certificate.
Last active November 15, 2018 08:21
init script to daemonize digdag server.
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
 #!/bin/bash # digdag daemon # chkconfig: 345 20 80 # description: digdag daemon # processname: digdag # Credit: https://werxltd.com/wp/2012/01/05/simple-init-d-script-template/ source /home/user_name/.bashrc source /home/user_name/.bash_profile