View prime.scm
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) |
View arithmetic_puzzle_solver.rb
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 |
View count_div_test.rb
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) |
View to_rational.cpp
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 += "."; |
View redirect-template.yml
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. |
View website-template.yml
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. |
View digdag.sh
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 |