├── AsciiArt ├── Solution.java ├── Solution.java~ ├── spec.txt └── spec.txt~ ├── ChevauxDeCourse ├── Solution.java ├── Solution.java~ ├── spec.txt └── spec.txt~ ├── ChevauxDeCourseBash ├── Solution.sh └── spec.txt ├── ChuckNorris ├── Solution.java ├── Solution.java~ ├── spec.txt └── spec.txt~ ├── Defibrilateurs ├── Solution.java ├── Solution.java~ ├── spec.txt └── spec.txt~ ├── LICENSE ├── LaDescente ├── Solution.java ├── Solution.java~ ├── spec.txt └── spec.txt~ ├── LePouvoirDeThor ├── Solution.java ├── Solution.java~ ├── spec.txt └── spec.txt~ ├── MarsLanderNiveau1 ├── Solution.java ├── Solution.java~ ├── spec.txt └── spec.txt~ ├── MimeTypes ├── Solution.java ├── Solution.java~ ├── spec.txt └── spec.txt~ ├── Onboarding ├── Solution.java ├── spec.txt └── spec.txt~ ├── README.md ├── SkynetLeSaut ├── Solution.java ├── Solution.java~ ├── spec.txt └── spec.txt~ └── Temperatures ├── Solution.java ├── Solution.java~ ├── spec.txt └── spec.txt~ /AsciiArt/Solution.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Solution { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | int L = in.nextInt(); 14 | in.nextLine(); 15 | int H = in.nextInt(); 16 | in.nextLine(); 17 | String T = in.nextLine(); 18 | List ascii = new ArrayList(); 19 | int group = 0; 20 | 21 | for (int i = 0; i < H; i++) { 22 | String ROW = in.nextLine(); 23 | int beginIndex = 0; 24 | int endIndex = L - 1; 25 | group = ROW.length() / L; 26 | for (int j = 0; j < group; j++) { 27 | //System.err.println("Tour: " + j + " group: " + group + " beginIndex: " + beginIndex + " endIndex: " + endIndex); 28 | ascii.add(ROW.substring(beginIndex, endIndex+1)); 29 | beginIndex = endIndex + 1; 30 | endIndex = beginIndex + (L - 1); 31 | //System.err.println(ascii.get(j).length()); 32 | } 33 | } 34 | 35 | char[] cArray = "ABCDEFGHIJKLMNOPQRSTUVWXYZ?".toCharArray(); 36 | List letters = new ArrayList(); 37 | for(char c : cArray) { 38 | letters.add(c); 39 | } 40 | T = T.toUpperCase(); 41 | char[] ch = T.toCharArray(); 42 | List indexes = new ArrayList(); 43 | for (char c : ch) { 44 | if (!letters.contains(c)) { 45 | indexes.add(26); 46 | //Solution.printSolution(26, H, ascii, group); 47 | } 48 | else { 49 | indexes.add(letters.indexOf(c)); 50 | 51 | } 52 | } 53 | Solution.printSolution(indexes, H, ascii, group); 54 | } 55 | 56 | private static void printSolution(List indexes, int charHigth, List ascii, int group) { 57 | List pointers = indexes; 58 | int pointer = 0; 59 | for (int i = 0; i < charHigth; i++) { 60 | StringBuilder answer = new StringBuilder(); 61 | for (int j = 0; j < pointers.size(); j++) { 62 | int index = pointers.get(j); 63 | index += pointer; 64 | answer.append(ascii.get(index)); 65 | } 66 | pointer = pointer + group; 67 | System.out.println(answer.toString()); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /AsciiArt/Solution.java~: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Player { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | Map mountains = new HashMap(); 14 | // game loop 15 | while (true) { 16 | 17 | int spaceX = in.nextInt(); 18 | int spaceY = in.nextInt(); 19 | for (int i = 0; i < 8; i++) { 20 | int mountainH = in.nextInt(); // represents the height of one mountain, from 9 to 0. Mountain heights are provided from left to right. 21 | mountains.put(i, mountainH); 22 | } 23 | 24 | // Write an action using System.out.println() 25 | int higherMountain = 0; 26 | int index = 0; 27 | for (int i : mountains.keySet()) { 28 | int y = mountains.get(i); 29 | if ( y > higherMountain) { 30 | higherMountain = y; 31 | index = i; 32 | 33 | } 34 | } 35 | System.err.println(spaceX + " -- " + index + " ++++ " + higherMountain); 36 | if (spaceX == index) { 37 | 38 | System.out.println("FIRE"); 39 | continue; 40 | } 41 | else { 42 | System.out.println("HOLD"); 43 | } 44 | mountains.clear(); 45 | // To debug: System.err.println("Debug messages..."); 46 | 47 | //System.out.println("HOLD"); // either: FIRE (ship is firing its phase cannons) or HOLD (ship is not firing). 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /AsciiArt/spec.txt: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/16299233f0371f370024432977b8633af309e93 2 | -------------------------------------------------------------------------------- /AsciiArt/spec.txt~: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/1629792ed245c7320d31b59ecea2853d8bf1f34 2 | -------------------------------------------------------------------------------- /ChevauxDeCourse/Solution.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Solution { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | int N = in.nextInt(); 14 | List power = new ArrayList(); 15 | for (int i = 0; i < N; i++) { 16 | int Pi = in.nextInt(); 17 | power.add(Pi); 18 | } 19 | 20 | Collections.sort(power); 21 | int answer = Integer.MAX_VALUE; 22 | 23 | for (int i = 0; i < power.size()-1; i++) { 24 | int current = power.get(i); 25 | int next = power.get(i+1); 26 | //System.err.println(current + " - " + next); 27 | int D = next - current; 28 | if ( D < answer) { 29 | answer = D; 30 | } 31 | } 32 | 33 | System.out.println(answer); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ChevauxDeCourse/Solution.java~: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Solution { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | String MESSAGE = in.nextLine(); 14 | char[] cArray = MESSAGE.toCharArray(); 15 | StringBuilder answer = new StringBuilder(); 16 | StringBuilder binaryString = new StringBuilder(); 17 | 18 | for (char stringChar : cArray) { 19 | binaryString.append((String) String.format("%7s", Integer.toBinaryString((int) stringChar)).replace(' ', '0')); 20 | } 21 | String groups[] = binaryString.toString().split("(?<=1)(?=0)|(?<=0)(?=1)"); 22 | int counter = 0; 23 | for (String group : groups) { 24 | //System.err.println(group); 25 | if (group.contains("0")) { 26 | answer.append("00 "); 27 | } 28 | else { 29 | answer.append("0 "); 30 | } 31 | for (int i = 0; i < group.length(); i++) { 32 | answer.append("0"); 33 | } 34 | if (counter < groups.length - 1) { 35 | answer.append(" "); 36 | counter++; 37 | } 38 | 39 | } 40 | 41 | System.out.println(answer.toString()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ChevauxDeCourse/spec.txt: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/1635239e82c6d89901f554852ed53526453a8aa 2 | -------------------------------------------------------------------------------- /ChevauxDeCourse/spec.txt~: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/1629933fe2dc3cd6ced14707a8f6743a86fffc2 2 | -------------------------------------------------------------------------------- /ChevauxDeCourseBash/Solution.sh: -------------------------------------------------------------------------------- 1 | # Auto-generated code below aims at helping you parse 2 | # the standard input according to the problem statement. 3 | 4 | read N 5 | for (( i=0; i&2 11 | 12 | answer=10000000 13 | for ((i=0; i<${#power[@]}-1; i++)) 14 | do 15 | current=${power[$i]} 16 | next=${power[$i+1]} 17 | #echo "$current - $next" >&2 18 | D=$((next-current)) 19 | if [ $D -lt $answer ]; then 20 | answer=$D 21 | fi 22 | done 23 | 24 | echo "$answer" 25 | -------------------------------------------------------------------------------- /ChevauxDeCourseBash/spec.txt: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/1635239e82c6d89901f554852ed53526453a8aa 2 | -------------------------------------------------------------------------------- /ChuckNorris/Solution.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Solution { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | String MESSAGE = in.nextLine(); 14 | char[] cArray = MESSAGE.toCharArray(); 15 | StringBuilder answer = new StringBuilder(); 16 | StringBuilder binaryString = new StringBuilder(); 17 | 18 | for (char stringChar : cArray) { 19 | binaryString.append((String) String.format("%7s", Integer.toBinaryString((int) stringChar)).replace(' ', '0')); 20 | } 21 | String groups[] = binaryString.toString().split("(?<=1)(?=0)|(?<=0)(?=1)"); 22 | int counter = 0; 23 | for (String group : groups) { 24 | //System.err.println(group); 25 | if (group.contains("0")) { 26 | answer.append("00 "); 27 | } 28 | else { 29 | answer.append("0 "); 30 | } 31 | for (int i = 0; i < group.length(); i++) { 32 | answer.append("0"); 33 | } 34 | if (counter < groups.length - 1) { 35 | answer.append(" "); 36 | counter++; 37 | } 38 | 39 | } 40 | 41 | System.out.println(answer.toString()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ChuckNorris/Solution.java~: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Solution { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | int L = in.nextInt(); 14 | in.nextLine(); 15 | int H = in.nextInt(); 16 | in.nextLine(); 17 | String T = in.nextLine(); 18 | List ascii = new ArrayList(); 19 | int group = 0; 20 | 21 | for (int i = 0; i < H; i++) { 22 | String ROW = in.nextLine(); 23 | int beginIndex = 0; 24 | int endIndex = L - 1; 25 | group = ROW.length() / L; 26 | for (int j = 0; j < group; j++) { 27 | //System.err.println("Tour: " + j + " group: " + group + " beginIndex: " + beginIndex + " endIndex: " + endIndex); 28 | ascii.add(ROW.substring(beginIndex, endIndex+1)); 29 | beginIndex = endIndex + 1; 30 | endIndex = beginIndex + (L - 1); 31 | //System.err.println(ascii.get(j).length()); 32 | } 33 | } 34 | 35 | char[] cArray = "ABCDEFGHIJKLMNOPQRSTUVWXYZ?".toCharArray(); 36 | List letters = new ArrayList(); 37 | for(char c : cArray) { 38 | letters.add(c); 39 | } 40 | T = T.toUpperCase(); 41 | char[] ch = T.toCharArray(); 42 | List indexes = new ArrayList(); 43 | for (char c : ch) { 44 | if (!letters.contains(c)) { 45 | indexes.add(26); 46 | //Solution.printSolution(26, H, ascii, group); 47 | } 48 | else { 49 | indexes.add(letters.indexOf(c)); 50 | 51 | } 52 | } 53 | Solution.printSolution(indexes, H, ascii, group); 54 | } 55 | 56 | private static void printSolution(List indexes, int charHigth, List ascii, int group) { 57 | List pointers = indexes; 58 | int pointer = 0; 59 | for (int i = 0; i < charHigth; i++) { 60 | StringBuilder answer = new StringBuilder(); 61 | for (int j = 0; j < pointers.size(); j++) { 62 | int index = pointers.get(j); 63 | index += pointer; 64 | answer.append(ascii.get(index)); 65 | } 66 | pointer = pointer + group; 67 | System.out.println(answer.toString()); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /ChuckNorris/spec.txt: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/1629933fe2dc3cd6ced14707a8f6743a86fffc2 2 | -------------------------------------------------------------------------------- /ChuckNorris/spec.txt~: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/16299233f0371f370024432977b8633af309e93 2 | -------------------------------------------------------------------------------- /Defibrilateurs/Solution.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Solution { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | String LON = in.next(); 14 | in.nextLine(); 15 | String LAT = in.next(); 16 | in.nextLine(); 17 | int N = in.nextInt(); 18 | in.nextLine(); 19 | List defibrilateurs = new ArrayList(); 20 | for (int i = 0; i < N; i++) { 21 | String DEFIB = in.nextLine(); 22 | defibrilateurs.add(DEFIB); 23 | } 24 | 25 | String answer = "unknow"; 26 | double distance = Double.MAX_VALUE; 27 | double longitudeUser = Math.toRadians(Double.parseDouble(LON.replace(",", "."))); 28 | double latitudeUser = Math.toRadians(Double.parseDouble(LAT.replace(",", "."))); 29 | for (String defib : defibrilateurs) { 30 | double longitudeDefib = Math.toRadians(Double.parseDouble(defib.split(";")[4].replace(",", "."))); 31 | double latitudeDefib = Math.toRadians(Double.parseDouble(defib.split(";")[5].replace(",", "."))); 32 | //System.err.println(longitudeDefib + " - " + latitudeDefib); 33 | double x = (longitudeDefib - longitudeUser)*Math.cos((latitudeUser+latitudeDefib)/2); 34 | double y = (latitudeDefib - latitudeUser); 35 | double d = (Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)))*6371; 36 | System.err.println(d); 37 | if (d < distance) { 38 | distance = d; 39 | answer = defib.split(";")[1]; 40 | } 41 | } 42 | //System.err.println(distance); 43 | 44 | System.out.println(answer); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Defibrilateurs/Solution.java~: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Solution { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | String MESSAGE = in.nextLine(); 14 | char[] cArray = MESSAGE.toCharArray(); 15 | StringBuilder answer = new StringBuilder(); 16 | StringBuilder binaryString = new StringBuilder(); 17 | 18 | for (char stringChar : cArray) { 19 | binaryString.append((String) String.format("%7s", Integer.toBinaryString((int) stringChar)).replace(' ', '0')); 20 | } 21 | String groups[] = binaryString.toString().split("(?<=1)(?=0)|(?<=0)(?=1)"); 22 | int counter = 0; 23 | for (String group : groups) { 24 | //System.err.println(group); 25 | if (group.contains("0")) { 26 | answer.append("00 "); 27 | } 28 | else { 29 | answer.append("0 "); 30 | } 31 | for (int i = 0; i < group.length(); i++) { 32 | answer.append("0"); 33 | } 34 | if (counter < groups.length - 1) { 35 | answer.append(" "); 36 | counter++; 37 | } 38 | 39 | } 40 | 41 | System.out.println(answer.toString()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Defibrilateurs/spec.txt: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/1635162a39bb52630dca227182813d3176a824c 2 | -------------------------------------------------------------------------------- /Defibrilateurs/spec.txt~: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/1629933fe2dc3cd6ced14707a8f6743a86fffc2 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Kad DEMBELE 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /LaDescente/Solution.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Player { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | Map mountains = new HashMap(); 14 | // game loop 15 | while (true) { 16 | 17 | int spaceX = in.nextInt(); 18 | int spaceY = in.nextInt(); 19 | for (int i = 0; i < 8; i++) { 20 | int mountainH = in.nextInt(); // represents the height of one mountain, from 9 to 0. Mountain heights are provided from left to right. 21 | mountains.put(i, mountainH); 22 | } 23 | 24 | // Write an action using System.out.println() 25 | int higherMountain = 0; 26 | int index = 0; 27 | for (int i : mountains.keySet()) { 28 | int y = mountains.get(i); 29 | if ( y > higherMountain) { 30 | higherMountain = y; 31 | index = i; 32 | 33 | } 34 | } 35 | System.err.println(spaceX + " -- " + index + " ++++ " + higherMountain); 36 | if (spaceX == index) { 37 | 38 | System.out.println("FIRE"); 39 | continue; 40 | } 41 | else { 42 | System.out.println("HOLD"); 43 | } 44 | mountains.clear(); 45 | // To debug: System.err.println("Debug messages..."); 46 | 47 | //System.out.println("HOLD"); // either: FIRE (ship is firing its phase cannons) or HOLD (ship is not firing). 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /LaDescente/Solution.java~: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Player { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | int LX = in.nextInt(); // the X position of the light of power 14 | int LY = in.nextInt(); // the Y position of the light of power 15 | int TX = in.nextInt(); // Thor's starting X position 16 | int TY = in.nextInt(); // Thor's starting Y position 17 | 18 | int thorX = TX; 19 | int thorY = TY; 20 | 21 | // game loop 22 | while (true) { 23 | int E = in.nextInt(); // The level of Thor's remaining energy, representing the number of moves he can still make. 24 | 25 | String directionX = ""; 26 | String directionY = ""; 27 | if (thorX > LX) { 28 | directionX = "W"; 29 | thorX--; 30 | } 31 | else if (thorX < LX) { 32 | directionX = "E"; 33 | thorX++; 34 | } 35 | else 36 | directionX = ""; 37 | 38 | if (thorY > LY) { 39 | directionY = "N"; 40 | thorY--; 41 | } 42 | else if (thorY < LY) { 43 | directionY = "S"; 44 | thorY++; 45 | } 46 | else 47 | directionY = ""; 48 | 49 | // To debug: System.err.println("Debug messages..."); 50 | 51 | System.out.println(directionY + directionX); // A single line providing the move to be made: N NE E SE S SW W or NW 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /LaDescente/spec.txt: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/1629792ed245c7320d31b59ecea2853d8bf1f34 2 | -------------------------------------------------------------------------------- /LaDescente/spec.txt~: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/1629786cfcda99b5a0b5de475cc82cf3087d16f 2 | -------------------------------------------------------------------------------- /LePouvoirDeThor/Solution.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Player { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | int LX = in.nextInt(); // the X position of the light of power 14 | int LY = in.nextInt(); // the Y position of the light of power 15 | int TX = in.nextInt(); // Thor's starting X position 16 | int TY = in.nextInt(); // Thor's starting Y position 17 | 18 | int thorX = TX; 19 | int thorY = TY; 20 | 21 | // game loop 22 | while (true) { 23 | int E = in.nextInt(); // The level of Thor's remaining energy, representing the number of moves he can still make. 24 | 25 | String directionX = ""; 26 | String directionY = ""; 27 | if (thorX > LX) { 28 | directionX = "W"; 29 | thorX--; 30 | } 31 | else if (thorX < LX) { 32 | directionX = "E"; 33 | thorX++; 34 | } 35 | else 36 | directionX = ""; 37 | 38 | if (thorY > LY) { 39 | directionY = "N"; 40 | thorY--; 41 | } 42 | else if (thorY < LY) { 43 | directionY = "S"; 44 | thorY++; 45 | } 46 | else 47 | directionY = ""; 48 | 49 | // To debug: System.err.println("Debug messages..."); 50 | 51 | System.out.println(directionY + directionX); // A single line providing the move to be made: N NE E SE S SW W or NW 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /LePouvoirDeThor/Solution.java~: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Player { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | 14 | // game loop 15 | while (true) { 16 | String enemy1 = in.next(); 17 | int dist1 = in.nextInt(); 18 | String enemy2 = in.next(); 19 | int dist2 = in.nextInt(); 20 | 21 | // Write an action using System.out.println() 22 | // To debug: System.err.println("Debug messages..."); 23 | 24 | if(dist1 < dist2) { 25 | System.out.println(enemy1); 26 | } 27 | else 28 | System.out.println(enemy2); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /LePouvoirDeThor/spec.txt: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/1629786cfcda99b5a0b5de475cc82cf3087d16f 2 | -------------------------------------------------------------------------------- /LePouvoirDeThor/spec.txt~: -------------------------------------------------------------------------------- 1 | La planète CodinGame est attaquée par des aliens insectoïdes. 2 | 3 | L'objectif de votre programme est de détruire le vaisseau ennemi le plus proche de votre canon. 4 | Les vaisseaux ennemis approchent en ligne droite vers votre canon. 5 | 6 | A chaque début d'un tour de jeu (dans la boucle game loop), vous obtenez les informations de deux ennemis : 7 | 8 | variable enemy1 : le nom de l'ennemi 1. 9 | variable dist1 : la distance à laquelle se trouve l'ennemi 1. 10 | variable enemy2 : le nom de l'ennemi 2. 11 | variable dist2 : la distance à laquelle se trouve l'ennemi 2. 12 | 13 | Avant la fin du tour (fin de la boucle), vous devez indiquer en sortie le nom de l'ennemi le plus proche (variable enemy1 ou enemy2) pour que votre canon tire dessus. 14 | 15 | -------------------------------------------------------------------------------- /MarsLanderNiveau1/Solution.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Player { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | int surfaceN = in.nextInt(); // the number of points used to draw the surface of Mars. 14 | for (int i = 0; i < surfaceN; i++) { 15 | int landX = in.nextInt(); // X coordinate of a surface point. (0 to 6999) 16 | int landY = in.nextInt(); // Y coordinate of a surface point. By linking all the points together in a sequential fashion, you form the surface of Mars. 17 | } 18 | 19 | // game loop 20 | while (true) { 21 | int X = in.nextInt(); 22 | int Y = in.nextInt(); 23 | int hSpeed = in.nextInt(); // the horizontal speed (in m/s), can be negative. 24 | int vSpeed = in.nextInt(); // the vertical speed (in m/s), can be negative. 25 | int fuel = in.nextInt(); // the quantity of remaining fuel in liters. 26 | int rotate = in.nextInt(); // the rotation angle in degrees (-90 to 90). 27 | int power = in.nextInt(); // the thrust power (0 to 4). 28 | 29 | // Write an action using System.out.println() 30 | // To debug: System.err.println("Debug messages..."); 31 | 32 | if (vSpeed <= -40) { 33 | System.out.println("0 4"); 34 | } 35 | else { 36 | System.out.println("0 0"); 37 | } 38 | 39 | //System.out.println("-20 3"); // rotate power. rotate is the desired rotation angle. power is the desired thrust power. 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /MarsLanderNiveau1/Solution.java~: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Player { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | 14 | // game loop 15 | while (true) { 16 | String enemy1 = in.next(); 17 | int dist1 = in.nextInt(); 18 | String enemy2 = in.next(); 19 | int dist2 = in.nextInt(); 20 | 21 | // Write an action using System.out.println() 22 | // To debug: System.err.println("Debug messages..."); 23 | 24 | if(dist1 < dist2) { 25 | System.out.println(enemy1); 26 | } 27 | else 28 | System.out.println(enemy2); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /MarsLanderNiveau1/spec.txt: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/1629850ad6708ac0a0381bf8c444645fda3a2e8 2 | -------------------------------------------------------------------------------- /MarsLanderNiveau1/spec.txt~: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/16297788a5d3a3cda52006f0c0bc57acedf0fde 2 | -------------------------------------------------------------------------------- /MimeTypes/Solution.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Solution { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | int N = in.nextInt(); // Number of elements which make up the association table. 14 | in.nextLine(); 15 | int Q = in.nextInt(); // Number Q of file names to be analyzed. 16 | in.nextLine(); 17 | Map mimeType = new HashMap(); 18 | List files = new ArrayList(); 19 | for (int i = 0; i < N; i++) { 20 | String EXT = in.next(); // file extension 21 | String MT = in.next(); // MIME type. 22 | mimeType.put(EXT.toLowerCase(), MT); 23 | in.nextLine(); 24 | } 25 | for (int i = 0; i < Q; i++) { 26 | String FNAME = in.nextLine(); // One file name per line. 27 | files.add(FNAME.toLowerCase()); 28 | } 29 | 30 | for (String file : files) { 31 | int pointer = file.lastIndexOf("."); 32 | String ext = file.substring(pointer+1); 33 | //System.err.println(ext); 34 | if( pointer == -1 || !ext.matches("\\w+") ) { 35 | System.out.println("UNKNOWN"); 36 | } 37 | else { 38 | if (mimeType.keySet().contains(ext)) { 39 | System.out.println(mimeType.get(ext)); 40 | } 41 | else { 42 | System.out.println("UNKNOWN"); 43 | } 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /MimeTypes/Solution.java~: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Player { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | int surfaceN = in.nextInt(); // the number of points used to draw the surface of Mars. 14 | for (int i = 0; i < surfaceN; i++) { 15 | int landX = in.nextInt(); // X coordinate of a surface point. (0 to 6999) 16 | int landY = in.nextInt(); // Y coordinate of a surface point. By linking all the points together in a sequential fashion, you form the surface of Mars. 17 | } 18 | 19 | // game loop 20 | while (true) { 21 | int X = in.nextInt(); 22 | int Y = in.nextInt(); 23 | int hSpeed = in.nextInt(); // the horizontal speed (in m/s), can be negative. 24 | int vSpeed = in.nextInt(); // the vertical speed (in m/s), can be negative. 25 | int fuel = in.nextInt(); // the quantity of remaining fuel in liters. 26 | int rotate = in.nextInt(); // the rotation angle in degrees (-90 to 90). 27 | int power = in.nextInt(); // the thrust power (0 to 4). 28 | 29 | // Write an action using System.out.println() 30 | // To debug: System.err.println("Debug messages..."); 31 | 32 | if (vSpeed <= -40) { 33 | System.out.println("0 4"); 34 | } 35 | else { 36 | System.out.println("0 0"); 37 | } 38 | 39 | //System.out.println("-20 3"); // rotate power. rotate is the desired rotation angle. power is the desired thrust power. 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /MimeTypes/spec.txt: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/16338774e08b0c72bf13fca05ec778c28625c97 2 | -------------------------------------------------------------------------------- /MimeTypes/spec.txt~: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/1629850ad6708ac0a0381bf8c444645fda3a2e8 2 | -------------------------------------------------------------------------------- /Onboarding/Solution.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Player { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | 14 | // game loop 15 | while (true) { 16 | String enemy1 = in.next(); 17 | int dist1 = in.nextInt(); 18 | String enemy2 = in.next(); 19 | int dist2 = in.nextInt(); 20 | 21 | // Write an action using System.out.println() 22 | // To debug: System.err.println("Debug messages..."); 23 | 24 | if(dist1 < dist2) { 25 | System.out.println(enemy1); 26 | } 27 | else 28 | System.out.println(enemy2); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Onboarding/spec.txt: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/16297788a5d3a3cda52006f0c0bc57acedf0fde 2 | -------------------------------------------------------------------------------- /Onboarding/spec.txt~: -------------------------------------------------------------------------------- 1 | La planète CodinGame est attaquée par des aliens insectoïdes. 2 | 3 | L'objectif de votre programme est de détruire le vaisseau ennemi le plus proche de votre canon. 4 | Les vaisseaux ennemis approchent en ligne droite vers votre canon. 5 | 6 | A chaque début d'un tour de jeu (dans la boucle game loop), vous obtenez les informations de deux ennemis : 7 | 8 | variable enemy1 : le nom de l'ennemi 1. 9 | variable dist1 : la distance à laquelle se trouve l'ennemi 1. 10 | variable enemy2 : le nom de l'ennemi 2. 11 | variable dist2 : la distance à laquelle se trouve l'ennemi 2. 12 | 13 | Avant la fin du tour (fin de la boucle), vous devez indiquer en sortie le nom de l'ennemi le plus proche (variable enemy1 ou enemy2) pour que votre canon tire dessus. 14 | 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # codingame 2 | Les solutions aux défis codinGame 3 | 4 | Les solutions sont dans les fichiers Solution.java présent dans les différents réperoires. 5 | Ils sont à exécuter dans l'IDE en ligne de http://codingame.com car seul le code est important, les classes n'étant pas toutes nommées Solution. 6 | 7 | L'objectif de ce projet est surtout de donner un coup de main à ceux qui sont bloqués sur certains défis. 8 | -------------------------------------------------------------------------------- /SkynetLeSaut/Solution.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Player { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | int road = in.nextInt(); // the length of the road before the gap. 14 | int gap = in.nextInt(); // the length of the gap. 15 | int platform = in.nextInt(); // the length of the landing platform. 16 | int distance = road - 1; 17 | // game loop 18 | while (true) { 19 | int speed = in.nextInt(); // the motorbike's speed. 20 | int coordX = in.nextInt(); // the position on the road of the motorbike. 21 | 22 | 23 | if (speed < gap+1) { 24 | System.out.println("SPEED"); 25 | } 26 | else if (speed > gap+1) { 27 | System.out.println("SLOW"); 28 | } 29 | else { 30 | if (coordX == distance) { 31 | System.out.println("JUMP"); 32 | 33 | while (speed > 0) { 34 | System.out.println("SLOW"); 35 | } 36 | } 37 | else 38 | System.out.println("WAIT"); 39 | } 40 | // Write an action using System.out.println() 41 | // To debug: System.err.println("Debug messages..."); 42 | 43 | // A single line containing one of 4 keywords: SPEED, SLOW, JUMP, WAIT. 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /SkynetLeSaut/Solution.java~: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Player { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | 14 | // game loop 15 | while (true) { 16 | String enemy1 = in.next(); 17 | int dist1 = in.nextInt(); 18 | String enemy2 = in.next(); 19 | int dist2 = in.nextInt(); 20 | 21 | // Write an action using System.out.println() 22 | // To debug: System.err.println("Debug messages..."); 23 | 24 | if(dist1 < dist2) { 25 | System.out.println(enemy1); 26 | } 27 | else 28 | System.out.println(enemy2); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SkynetLeSaut/spec.txt: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/1629823a113880f8bbcfae2fe49cb9502aa2002 2 | -------------------------------------------------------------------------------- /SkynetLeSaut/spec.txt~: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/16297788a5d3a3cda52006f0c0bc57acedf0fde 2 | -------------------------------------------------------------------------------- /Temperatures/Solution.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Solution { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | int N = in.nextInt(); // the number of temperatures to analyse 14 | in.nextLine(); 15 | String TEMPS = in.nextLine(); // the N temperatures expressed as integers ranging from -273 to 5526 16 | 17 | // Write an action using System.out.println() 18 | // To debug: System.err.println("Debug messages..."); 19 | int result = 0; 20 | if (TEMPS.isEmpty()) { 21 | System.out.println(result); 22 | } 23 | else { 24 | List list = new ArrayList(); 25 | List originaList = new ArrayList(); 26 | for (int i = 0; i < N; i++) { 27 | list.add(Math.abs(Integer.valueOf(TEMPS.split(" ")[i]))); 28 | originaList.add(Integer.valueOf(TEMPS.split(" ")[i])); 29 | } 30 | if (originaList.size() == 1) { 31 | result = originaList.get(0); 32 | } 33 | else { 34 | Collections.sort(list); 35 | result = list.get(N-1); 36 | for (int i = 0; i < list.size(); i++) { 37 | int tmp = originaList.get(i); 38 | System.err.println(result); 39 | if (Math.abs(tmp) <= Math.abs(result)) { 40 | result = tmp; 41 | } 42 | } 43 | if (Math.signum(result) == -1.0 && originaList.contains(Math.abs(result))) { 44 | result = Math.abs(result); 45 | System.err.println(result); 46 | } 47 | } 48 | System.out.println(result); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Temperatures/Solution.java~: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.io.*; 3 | import java.math.*; 4 | 5 | /** 6 | * Auto-generated code below aims at helping you parse 7 | * the standard input according to the problem statement. 8 | **/ 9 | class Player { 10 | 11 | public static void main(String args[]) { 12 | Scanner in = new Scanner(System.in); 13 | int LX = in.nextInt(); // the X position of the light of power 14 | int LY = in.nextInt(); // the Y position of the light of power 15 | int TX = in.nextInt(); // Thor's starting X position 16 | int TY = in.nextInt(); // Thor's starting Y position 17 | 18 | int thorX = TX; 19 | int thorY = TY; 20 | 21 | // game loop 22 | while (true) { 23 | int E = in.nextInt(); // The level of Thor's remaining energy, representing the number of moves he can still make. 24 | 25 | String directionX = ""; 26 | String directionY = ""; 27 | if (thorX > LX) { 28 | directionX = "W"; 29 | thorX--; 30 | } 31 | else if (thorX < LX) { 32 | directionX = "E"; 33 | thorX++; 34 | } 35 | else 36 | directionX = ""; 37 | 38 | if (thorY > LY) { 39 | directionY = "N"; 40 | thorY--; 41 | } 42 | else if (thorY < LY) { 43 | directionY = "S"; 44 | thorY++; 45 | } 46 | else 47 | directionY = ""; 48 | 49 | // To debug: System.err.println("Debug messages..."); 50 | 51 | System.out.println(directionY + directionX); // A single line providing the move to be made: N NE E SE S SW W or NW 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Temperatures/spec.txt: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/16299064f9e5507d9d2c569fbe82e4c2ed4b1e0 2 | -------------------------------------------------------------------------------- /Temperatures/spec.txt~: -------------------------------------------------------------------------------- 1 | https://www.codingame.com/ide/1629786cfcda99b5a0b5de475cc82cf3087d16f 2 | --------------------------------------------------------------------------------