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
%% | |
program : | |
top_compstmt | |
; | |
top_compstmt : top_stmts opt_terms | |
; | |
top_stmts : none | |
| top_stmt |
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
%% | |
program : { | |
SET_LEX_STATE(EXPR_BEG); | |
local_push(p, ifndef_ripper(1)+0); | |
} | |
top_compstmt | |
{ | |
/*%%%*/ | |
if ($2 && !compile_for_eval) { | |
NODE *node = $2; |
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
# 以下の BNF で表される数式が書かれたファイルを受け取り、数式をパースし、抽象構文木をJSON形式でファイルに出力します。 | |
# | |
# expression ::= term | term "+" expression | term "-" expression | |
# term ::= factor | factor "*" term | factor "/" term | |
# factor ::= number | "(" expression ")" | |
# number ::= ("0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9")+ | |
# | |
# Usage: | |
# $ ruby main.rb src.txt dst.json |
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
FIELD = [ | |
['G', 'D', 'B', 'A', '', '', ''], | |
['N', 'K', 'H', 'E', 'C', '', ''], | |
['U', 'R', 'O', 'L', 'I', 'F', ''], | |
['2', 'Y', 'V', 'S', 'P', 'M', 'J'], | |
['', '6', '3', 'Z', 'W', 'T', 'Q'], | |
['', '', '9', '7', '4', '1', 'X'], | |
['', '', '', '@', '0', '8', '5'] | |
] |
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
FIELD = [ | |
['A', 'B', 'C', 'D', 'E', 'F'], | |
['G', 'H', 'I', 'J', 'K', 'L'], | |
['M', 'N', 'O', 'P', 'Q', 'R'], | |
['S', 'T', 'U', 'V', 'W', 'X'], | |
['Y', 'Z', '1', '2', '3', '4'], | |
['5', '6', '7', '8', '9', '0'] | |
] | |
DIRECTIONS = [ |
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
module Parser | |
class Parser | |
def parse(input) | |
expression(input) | |
end | |
private | |
def expression(input) | |
node = factor(input) |
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
defmodule Doukaku do | |
def test(input, expected), do: _judge(expected, _solve(input)) | |
defp _judge(expected, actual) when expected == actual, do: IO.puts("AC") | |
defp _judge(expected, actual), do: IO.puts("WA(expected: #{expected}, actual: #{actual})") | |
defp _solve(input), do: _binarise(input) |> _decode |> _calc |> _encode | |
defp _binarise(input) do | |
[limit, encoded_input] = String.splitter(input, ":") |> Enum.to_list |
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
package main | |
import ( | |
"fmt" | |
"os" | |
"os/exec" | |
"github.com/codegangsta/cli" | |
) |
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
def shuffle(num_of_deck, shuffle_procedure) | |
deck = (0...num_of_deck).to_a | |
shuffle_procedure.each do |step| | |
deck = cut(deck, step[0], step[1]) | |
end | |
deck[0] | |
end | |
# デッキをカットする | |
# draw_begin から draw_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
import java.util.Set; | |
import java.util.HashSet; | |
import java.util.TreeSet; | |
public class Main { | |
public String solve(String input) { | |
String[] inputs = input.split(":"); | |
char c = inputs[1].charAt(0); | |
Set<Character> set = new HashSet<>(); | |
for (char s: inputs[0].toCharArray()) { |
NewerOlder