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
//https://www.hackerrank.com/challenges/hackerland-radio-transmitters/problem | |
s= new Scanner(System.in); | |
int n = s.nextInt(); | |
int portee = s.nextInt(); | |
maisons=new TreeSet<>() | |
for(int x_i=0; x_i < n; x_i++){ | |
maisons.add(s.nextInt()) | |
} | |
min = maisons.min() |
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
input = new Scanner(System.in); | |
r = input.nextInt() | |
l = input.nextInt() | |
c = [[r],[1,r]] | |
(2..l-1).each { | |
List list = c[it - 1] | |
result = [] | |
i = 1 |
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
input = new Scanner(System.in); | |
N = input.nextInt() | |
numbers=[] | |
for (i = 0; i < N; ++i) { | |
numbers << input.next() | |
} | |
int numberOfDigit(List<String> phoneNumbers) { | |
masterNode = new Node('#') |
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) |
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
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
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 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
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
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 | |
} |
OlderNewer