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
#!/usr/bin/ruby -Ku | |
def fileDel(f_name) | |
puts f_name | |
File::delete(f_name) | |
end | |
Dir::glob("*.{swf,mp4,flv}").each do |file| | |
diff = (Time.now - File::mtime(file)).div(24 * 60 * 60) | |
if diff > 90 |
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
#!/usr/bin/ruby -Ku | |
m = 200 | |
n = 200 | |
k = 200 | |
puts "#{m}, #{n}, #{k}" | |
(n + 1).times do | |
m.times do | |
print "#{(rand * 21).to_i}, " | |
end |
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
いろいろなアルゴリズムを適用できるようになりそうなので、まずは問題で与えられているデータを | |
交差点 -> 頂点、道路 -> 辺 | |
とした無向グラフと考えることにした。 | |
データがグラフならば、最短路を求めるのにはダイクストラ法などのアルゴリズムを利用することができる。 | |
今回の予選課題は、ダイクストラ法を元にした方法で解くことにした。 | |
まずはプライオリティキューを実装した。 | |
このキューは、 |
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 inputMax 999) | |
(define (isMultiOf5 n) (if (= (modulo n 5) 0) #t #f)) | |
(define (isMultiOf3 n) (if (= (modulo n 3) 0) #t #f)) | |
(define (isMulti n) (if (isMultiOf3 n) #t (isMultiOf5 n))) | |
(define (solve n) (if (= n 0) 0 (+ (if (isMulti n) n 0) (solve (- n 1))))) | |
(display (solve inputMax)) |
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
#!/usr/bin/ruby -Ku | |
require 'rexml/document' | |
require 'open-uri' | |
def getXMLDocument(user_id) | |
uri = "http://judge.u-aizu.ac.jp/onlinejudge/webservice/user?id=#{user_id}" | |
xml_source = open(uri).read | |
sleep(1) | |
return REXML::Document.new(xml_source) |
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
#include "DxLib.h" | |
#include <ctime> | |
static const int FRAME_RATE = 10; | |
static const int DOWN_RATE = 5; | |
static const int BROCK_LENGTH = 24; | |
static const int BOARD_WIDTH = 10; | |
static const int BOARD_HEIGHT = 20; | |
int BROCK_COLOR[8]; |
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
#!/usr/bin/env ruby | |
files = Dir.glob("*.abc") # 拡張子で指定する | |
files.each do |f| | |
if f =~ /regex/ # 正規表現でガリガリ | |
puts "#{f} -> hogehoge - #{$1}.abc" # キャプチャーしたのも、てけとーに | |
#File.rename(f, "hogehoge - #{$1}.abc") | |
end | |
end |
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
#!/usr/bin/env ruby | |
ARGV.each do |arg| | |
puts "*** diff #{arg} ‾/#{arg} ***" | |
puts `diff #{arg} ‾/#{arg}` | |
end |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
class String | |
def to_pascal_case | |
self.split("-").map {|s| s.capitalize }.join | |
end | |
end |