Skip to content

Instantly share code, notes, and snippets.

@tomcha
tomcha / gist:eb66f25b5521cd1f8009
Created Jul 4, 2014
カラオケマシン問題
View gist:eb66f25b5521cd1f8009
# coding: utf-8
class KaraokeMachine
attr_accessor :melody
def initialize(melody)
@melody = melody
end
def transpose(amount)
amount %= 12
@tomcha
tomcha / ref.pl
Created Jul 30, 2014
Perlのサンプル
View ref.pl
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
#値渡し
my @array_a = (0, 1, 2);
my @array_b = @array_a;
@tomcha
tomcha / ref.rb
Created Jul 30, 2014
Rubyのサンプル
View ref.rb
#!/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 / filenames.pl
Created Aug 6, 2014
linger入学式のコード
View filenames.pl
#!/usr/bin/env perl
#use 5.012;
use warnings;
use strict;
#foreach (glob ('*')) {
# my $dest = readlink $_;
# print "$_ -> $dest\n" if defined $dest;
#}
View kinugasa.pl
#!/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 Nov 7, 2014
Perl入学式 標準入力の練習問題解答例
View calc.pl
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
print "1つ目の数字を入力して下さい >>";
my $i = <STDIN>;
chomp $i;
View nukaduke.pm
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
sub pickle{
my $filepath = shift;
my $vegetable = shift;
chomp($filepath);
View test.pl
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
use lib "./lib";
use nukaduke;
@tomcha
tomcha / prime.rb
Created Dec 20, 2014
prime number ruby
View prime.rb
#!/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 Dec 20, 2014
prime number java
View Prime.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);