CodeJP 2014のコードゴルフの私の回答
http://jsfiddle.net/maraigue/cqpx5m4p/1/
- 以下のjsファイルのどちらかをダウンロードし、main.jsの名前で保存する
- 実行用HTMLファイルをダウンロードして同じフォルダに置き、これを適当なブラウザで開く
CodeJP 2014のコードゴルフの私の回答
http://jsfiddle.net/maraigue/cqpx5m4p/1/
| # https://github.com/maraigue/cpp-chinese-postman を | |
| # JR全線(jr-all.edges)を対象に解いた結果 | |
| # 路線網の分割には jr-all-division-example.edges を利用 | |
| # | |
| # JR全線:19860.5km(間違いがあるかも) | |
| # 二度乗車する区間(以下の一覧の合計):5729.7km | |
| # 合計:25590.2km | |
| # | |
| # 以下の一覧における距離の単位は「0.1km」 | |
| # ------------------------------------------------------------ |
| def create_field(str) | |
| str = str.gsub(/\A\n+|\n+\z/, "") | |
| str.split("\n").map{ |line| line.split(//) } | |
| end | |
| def find_start_goal(field) | |
| result = {} | |
| field.each_with_index do |line, i| | |
| line.each_with_index do |cell, j| | |
| if cell == "S" || cell == "G" |
| #include <iostream> | |
| class Hoge{ | |
| const int v; | |
| public: | |
| Hoge(int x) : v(x * 5) {} // 問題なく動作 | |
| //Hoge(int x) { v = x * 5; } // 不可 | |
| int value(){ return v; } | |
| }; |
| #!/usr/bin/env ruby | |
| require 'tmpdir' | |
| require 'fileutils' | |
| # このスクリプトができること | |
| # | |
| # 「1ページに、指定されたPDFの複数ページを印刷する」形式のPDFを作る。 | |
| # 隙間なく敷き詰められる。 | |
| # 「横に何列並べるか」と「元のPDFのページの縮小率」が指定できる。 |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
| <link rel="alternate" type="application/rss+xml" title="RSS" href="/rss"/> | |
| <link rel="shortcut icon" href="{Favicon}"> | |
| <link type="text/css" rel="stylesheet" media="screen" href="http://libelabo.jp/stylesheets/screen.css"/> | |
| <title>{Title}</title> | |
| <style type="text/css"> |
| require 'net/http' | |
| require 'cgi' | |
| Net::HTTP.version_1_2 | |
| module TinyURL | |
| module_function | |
| # Makes a URL short via TinyURL.com. | |
| # returned value is the key of TinyURL.com. |
| class Integer | |
| def toshigo? | |
| # return nil if self <= 0 | |
| s = self.to_s | |
| l = s.length | |
| return false if l % 2 != 0 | |
| ((s[0...(l/2)].to_i) - (s[(l/2)..-1].to_i)).abs == 1 | |
| end |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
| <head> | |
| <!-- DEFAULT COLORS --> | |
| <meta name="color:Background" content="#fff"/> | |
| <meta name="color:Title" content="#444"/> | |
| <meta name="color:Description" content="#777"/> | |
| <meta name="color:Post Title" content="#6498cc"/> | |
| <meta name="color:Text" content="#444"/> |
| #!/usr/bin/env ruby1.9 | |
| # -*- coding: utf-8 -*- | |
| def URLencode(str) | |
| str.force_encoding("binary").gsub(/\W+/){ |x| x.unpack("C*").map{ |y| sprintf("%%%02X", y) }.join } | |
| end | |
| puts URLencode("ほげ") |