Skip to content

Instantly share code, notes, and snippets.

@tomcha
tomcha / gist:eb66f25b5521cd1f8009
Created July 4, 2014 10:57
カラオケマシン問題
# coding: utf-8
class KaraokeMachine
attr_accessor :melody
def initialize(melody)
@melody = melody
end
def transpose(amount)
amount %= 12
@tomcha
tomcha / ref.rb
Created July 30, 2014 13:29
Rubyのサンプル
#!/usr/bin/env ruby
# encoding: utf-8
#値渡し
array_a = [0,1,2]
array_b = array_a.dup
array_b[1] = 'a'
p array_a
#参照渡し
@tomcha
tomcha / ref.pl
Created July 30, 2014 13:30
Perlのサンプル
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
#値渡し
my @array_a = (0, 1, 2);
my @array_b = @array_a;
@tomcha
tomcha / filenames.pl
Created August 6, 2014 10:24
linger入学式のコード
#!/usr/bin/env perl
#use 5.012;
use warnings;
use strict;
#foreach (glob ('*')) {
# my $dest = readlink $_;
# print "$_ -> $dest\n" if defined $dest;
#}
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
binmode STDIN,":encoding(UTF8)";
binmode STDOUT,":utf8";
binmode STDERR,":utf8";
@tomcha
tomcha / calc.pl
Created November 7, 2014 11:49
Perl入学式 標準入力の練習問題解答例
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
print "1つ目の数字を入力して下さい >>";
my $i = <STDIN>;
chomp $i;
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
sub pickle{
my $filepath = shift;
my $vegetable = shift;
chomp($filepath);
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use lib "./lib";
use nukaduke;
@tomcha
tomcha / prime.rb
Created December 20, 2014 07:22
prime number ruby
#!/usr/bin/env ruby
# encoding: utf-8
def check_prime(num,array)
i = 0
sq_number = Math.sqrt(num).ceil.to_i
array.size.times do
if num % array[i] == 0
return false
else
@tomcha
tomcha / Prime.java
Created December 20, 2014 07:24
prime number java
import java.util.ArrayList;
public class Prime{
public static void main(String[] args){
long start = System.currentTimeMillis();
// System.out.println(2);
// System.out.println(3);
int num = 5;
ArrayList<Integer> array = new ArrayList<Integer>();
array.add(2);