This file contains hidden or 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 javax.swing.JDialog | |
import javax.swing.JPanel | |
import java.awt.* | |
import java.awt.image.BufferedImage | |
import static java.lang.System.exit | |
import static javax.swing.JOptionPane.* | |
class TimerPanel extends JPanel { |
This file contains hidden or 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 javax.swing.* | |
import java.awt.* | |
import java.nio.file.Path | |
import java.nio.file.Paths | |
import java.util.List | |
import static javax.swing.JOptionPane.* | |
/* | |
Display a checklist selected from a folder and write the user selection in a log file |
This file contains hidden or 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
void displayOptions(String name, List<String> options) { | |
print("Select $name ::") | |
options.eachWithIndex { String entry, int i -> | |
print(" $entry [${i + 1}]${i + 1 == options.size() ? ": " : ","}") | |
} | |
} | |
int readUserInput(List<String> options) { | |
displayOptions(options) | |
def input = ++new Scanner(System.in) |
This file contains hidden or 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 progressColor(int percent) { | |
def red = "${(char) 27}[31;49m" | |
def yellow = "${(char) 27}[33;49m" | |
def green = "${(char) 27}[32;49m" | |
if (percent <= 25) | |
return red | |
if (percent <= 75) | |
return yellow | |
return green | |
} |
This file contains hidden or 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 fg = 30 | |
def bg = 46 | |
def style = "${(char)27}[$fg;$bg"+"m" | |
println(style+"HELLO") | |
/* | |
+~~~~~~+~~~~~~+~~~~~~~~~~~+ | |
| fg | bg | color | | |
+~~~~~~+~~~~~~+~~~~~~~~~~~+ | |
| 30 | 40 | black | | |
| 31 | 41 | red | |
This file contains hidden or 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 org.junit.Test; | |
import static java.util.Arrays.stream; | |
import static java.util.stream.IntStream.range; | |
import static org.junit.Assert.assertEquals; | |
public class Bowling { | |
private int score(int[][]f) { | |
return range(0,9).boxed().mapToInt(i->stream(f[i]).sum()+((f[i][0]+f[i][1]==10)?f[i+1][0]:0)+((f[i][0]==10)?(f[i+1][0]!=10?f[i+1][1]:(i!=8?f[i+2][0]:f[i+1][2])):0)).sum()+stream(f[9]).sum(); | |
} |
This file contains hidden or 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 log.appender; | |
import org.apache.logging.log4j.core.Filter; | |
import org.apache.logging.log4j.core.Layout; | |
import org.apache.logging.log4j.core.LogEvent; | |
import org.apache.logging.log4j.core.appender.AbstractAppender; | |
import org.apache.logging.log4j.core.config.plugins.Plugin; | |
import org.apache.logging.log4j.core.config.plugins.PluginAttribute; | |
import org.apache.logging.log4j.core.config.plugins.PluginElement; | |
import org.apache.logging.log4j.core.config.plugins.PluginFactory; |
This file contains hidden or 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.Arrays; | |
public class StairCaseSolution { | |
public static String staircase(int n) { | |
if (n <= 0) | |
return ""; | |
StringBuilder resultBuilder = new StringBuilder(); | |
for (int spaceNumber = n - 1; spaceNumber >= 0; spaceNumber--) { | |
resultBuilder.append(createLine(n, spaceNumber)).append('\n'); | |
} |
This file contains hidden or 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 is a script template used for code golf on codingame | |
use scriptSize to compute the size of the code between two tags | |
use runCode to execute the golfCode with custom STDIN/OUT for your unit tests | |
*/ | |
/** | |
* Read this file lines and return the number of char between two line marked with the given tags | |
* @param startTag the tag of the starting line ex : //START | |
* @param endTag the tag of the end line ex : //END |
This file contains hidden or 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 Bowling { | |
static int score(def rolls) { | |
def score = scoreWithoutBonus(rolls) | |
def frames = 0..9 | |
frames.each { | |
def firstRollInFrame = it * 2 | |
if (isStrike(rolls, firstRollInFrame)) { | |
score += strikeBonus(rolls, firstRollInFrame) | |
} else if (isSpare(rolls, firstRollInFrame)) { | |
score += spareBonus(rolls, firstRollInFrame) |
NewerOlder