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 gbf | |
class GBrainFuckResult { | |
final String output | |
final String buffer | |
GBrainFuckResult(String output, String buffer) { | |
this.output = output | |
this.buffer = buffer | |
} |
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 xutp | |
class KeyValueStore { | |
private final store = [:] | |
void put(def key, def value) { | |
if (key == null) throw new IllegalArgumentException() | |
store[key] = value | |
} |
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 doukaku | |
class BaseballScore { | |
String ballCount(String s) { | |
def out = 0 | |
def strike = 0 | |
def ball = 0 | |
def result = [] |
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 calc | |
import groovy.util.Eval | |
import java.awt.event.ActionEvent | |
class CalcController { | |
def model | |
def view |
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 doukaku | |
class Poker { | |
final def handPattern = ['14':'4K', '23':'FH', '113':'3K', '122':'2P', '1112':'1P', '11111':'-'] | |
String judge(String hand) { | |
def eachNumberCount = [:].withDefault {0} | |
(hand =~ /([2-9AJQK]|10)/).each { | |
++eachNumberCount[it] | |
} |
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 <stdio.h> | |
int main(int argc, char* argv[]) { | |
printf(" \n"); | |
printf(" .;BHHHHBBBBBBBBBBBBBBBBBHHBs........ \n"); | |
printf(" ,:G@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#:: \n"); | |
printf(" h@@@@@@@@@2X9, :GhGAAAB@@@@@@@@@@@@i \n"); | |
printf(" r@@@@@&: S@@@@@@@; \n"); | |
printf(" .B@@@@M, ,@@@@@@. \n"); | |
printf(" 9@@@, :@@@@@ \n"); |
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 Calculator | |
class Calculator { | |
Integer add(int x, int y) { | |
x + y | |
} | |
Integer multiply(int x, int y) { | |
x * y | |
} |
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
@Category(Integer) | |
class IntegerCategory { | |
Integer fizzbuzz() { | |
if (this % 15 == 0) { | |
println "FizzBuzz" | |
} else if (this % 5 == 0) { | |
println "Buzz" | |
} else if (this % 3 == 0) { | |
println "Fizz" | |
} else { |
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 Tetromino { | |
private List patternL = [[1,1,10],[10,1,1],[10,10,1],[1,10,10],[10,9,1],[1,1,8],[1,9,10],[8,1,1]] | |
private List patternI = [[1,1,1],[10,10,10]] | |
private List patternT = [[9,1,10],[1,1,9],[10,1,9],[9,1,1]] | |
private List patternO = [[1,9,1]] | |
private List patternS = [[1,10,1],[1,8,1],[10,1,10],[9,1,9]] | |
String judge(List coordinates) { | |
if (isOverEdge(coordinates)) | |
return "-" |
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 BrainFuck | |
def convert(src) | |
dst = Array.new(65536, 0) | |
src_position = 0 | |
dst_position = 0 | |
while src_position < src.size | |
case src[src_position] | |
when ?> | |
dst_position += 1 | |
when ?< |