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
%?- talk(hello, X). で会話できる | |
talk(hello, hello). | |
talk(こんにちは, こんにちは). | |
talk(ばか, あほ). | |
talk(今日はいい天気ですね, そうですね). | |
talk(あなたはだれ?, 人工知能です). |
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
#シーザー暗号 | |
#ruby caesar.rb piyopiyo -2 | |
#ngwmngwm | |
def caesar_cipher(str, shift) | |
str.split(//).each {|c| print (c.ord + shift.to_i).chr} | |
end | |
caesar_cipher(ARGV[0], ARGV[1]) |
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
scala> val angou = "fhaal naq jvaql" | |
angou: String = fhaal naq jvaql | |
scala> angou.map({s => if(s < 'a' || s > 'z') s else if(s <= 'm') (s + 'n' - 'a').toChar else (s - 'n' + 'a').toChar}) | |
res43: String = sunny and windy |
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
# -*- coding: utf-8 -*- | |
import numpy as np | |
import pylab as plt | |
import copy | |
def jacobi_or_seidel(x, a, b, use_jacobi = True): | |
cpx = copy.copy(x) if use_jacobi else x | |
for i in range(x.size): | |
cpx[i] = b[i] | |
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
require "gnuplot" | |
# (gem install gnuplot) | |
# (brew install gnuplot) | |
INPUT_DATA = ARGV[0] || raise("input file name is not given") | |
OUTPUT_DATA = ARGV[1] || "output.txt" | |
OUTPUT_GRAPH = ARGV[2] || "output.eps" | |
n = 0 |
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
require 'uri' | |
buf = "" | |
File::open(ARGV[0]) {|file| | |
file.each {|line| | |
line = buf + line.strip | |
while line.length >= 9 do | |
print URI.decode(line[0..8]) | |
line = line[9..line.length-1] | |
end | |
buf = line |
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
require 'uri' | |
require 'prime' | |
# RSA暗号 | |
# 公開鍵(E, N) | |
E = 47 #適当な正整数 | |
N = 323 #素数p * 素数q | |
D_RANGE = 1000 #秘密鍵の推定最大値(一応ループ回避) | |
def decryption(x, d) |
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
import java.io.BufferedReader; | |
import java.io.FileInputStream; | |
import java.io.InputStreamReader; | |
import java.util.ArrayList; | |
import java.util.LinkedList; | |
import java.util.Queue; | |
/** | |
* Created by sambaiz on 2014/03/06. | |
*/ |
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
max_length = 5 | |
password = 'poor' | |
chars = ('a'..'z').to_a | |
searches = Array.new | |
searches << "" | |
length = 0 | |
while true | |
new_searches = Array.new | |
length += 1 |
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
val hello : String? = "hello" | |
var bye : String? = "bye" | |
//(hello or bye).length is error (need ? or !!) | |
hello!! | |
hello.length //ok | |
bye!! | |
//bye.length is error (need ? or !!) | |
bye?.length // if bye == null, return null |
OlderNewer