Skip to content

Instantly share code, notes, and snippets.

@tomcha
tomcha / sref.pl
Created August 11, 2020 13:02
scalar reference
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
my $a = 1;
my $b = $a;
$b *= 10;
#!/usr/bin/env ruby
(y, x) = gets.chomp.split(/ /).map(&:to_i)
now = [1, 1]
addy = 1
addx = 1
puts "#{now[0]}, #{now[1]}"
while
now[0] += addy
now[1] += addx
#!/usr/bin/env ruby
(y, x) = gets.chomp.split(/ /).map(&:to_i)
now = [1, 1]
addy = 1
addx = 1
puts "#{now[0]}, #{now[1]}"
while
now[0] += addy
now[1] += addx
@tomcha
tomcha / lifegame.go
Created May 21, 2020 01:34
lifegame
package main
import (
"fmt"
"math/rand"
"time"
)
const (
clear = "\033[2J"
@tomcha
tomcha / fatcomma.pl
Last active October 20, 2019 22:25
fatcomma.pl
#!/usr/bin/env perl
use strict;
use warnings;
my ($a, $b, $c) = (1, 2, 3);
my ($aa, $bb, $cc) = (1 => 2 => 3);
print "$b\n";
print "$cc\n";
@tomcha
tomcha / ref_allow.pl
Created July 14, 2019 11:51
ref_allow.pl
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use DDP { deparse => 1 };
my $allow = {1 => ['a', 'b', 'c'], 2 => ['d', 'e', 'f']};
@tomcha
tomcha / fizzbuzz.go
Created April 24, 2019 14:06
fizz buzz + goroutine
package main
import (
"fmt"
"sync"
)
func main() {
var wg sync.WaitGroup
wg.Add(1)
@tomcha
tomcha / guess-ad-year.pl
Created April 14, 2019 09:07
Perl入学式 第1回 ピザ会 課題 2019/04/13 回答
#!/usr/bin/env perl
# guess-ad-year.pl - 和暦を引数に与えると西暦年を応えてくれる
# ad は A.D. (Anno Domini = 西暦年) の略
#
# 例:
# guess-ad-year.pl 平成30年
# 2018年
# guess-ad-year.pl 昭和54年
# 1979年
@tomcha
tomcha / dijkstra.pl
Created April 13, 2019 01:36
ダイクストラ法
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use DDP { deparse => 1 };
my $graph = [];
for my $line (<DATA>){
@tomcha
tomcha / Trapezoidal.pl
Created April 13, 2019 01:34
台形法
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
use DDP { deparse => 1 };
print "a b(区間)を入力してください(スペース区切り) >";
chomp(my $input = <STDIN>);