started with the TicTacToe_MinMax Project. Finished the rendering of the game.

TODO: Make a playable version and add MinMax
This commit is contained in:
2020-06-14 23:13:33 +02:00
parent c1ebe11e2f
commit 99d9170365
145 changed files with 8952 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
package numbers;
public class CarryingTheDigits {
//Edabit-Challange:
//https://edabit.com/challenge/5snfPLPbvjAsZ5kjo
public static int carryDigits(int n1, int n2){
String firstNum = String.valueOf(n1);
String secondNum = String.valueOf(n2);
String first = new String();
String second = new String();
if (firstNum.length() > secondNum.length()){
String filler = new String();
for (int i = 0; i < firstNum.length()-secondNum.length();i++){
filler += "0";
}
first = firstNum;
second = filler + secondNum;
} else {
String filler = new String();
for (int i = 0; i < secondNum.length()-firstNum.length();i++){
filler += "0";
}
first = filler + firstNum;
second = secondNum;
}
System.out.println(first+ ", "+ second);
int tempCarry = 0;
int carry = 0;
for (int i = first.length()-1; i >= 0; i--){
int num = Integer.parseInt(Character.toString(first.charAt(i))) + Integer.parseInt(Character.toString(second.charAt(i))) + tempCarry;
if (num > 9){
tempCarry = num - 9;
if (tempCarry <= 0) {
tempCarry = 0;
}
carry++;
}
}
return carry;
}
public static void main(String[] args) {
System.out.println( carryDigits(671, 329));
}
}

View File

@@ -0,0 +1,21 @@
package numbers;
public class FindPrimorial {
//Edabit-Link
//https://edabit.com/challenge/Tyzp6S67dtXPAAQan
static int[] primes = {2, 3, 5, 7, 11, 13, 17, 19};
public static int primorial(int n) {
if (n > 0) {
int primorial = primes[n-1] * primorial(n - 1);
return primorial;
} else {
return 1;
}
}
public static void main(String[] args) {
System.out.println(primorial(1));
}
}

View File

@@ -0,0 +1,27 @@
package numbers;
public class HowManyPrimes_NOT_SOLVED {
//Edabit link
//https://edabit.com/challenge/z8vvSdWjAPu5ufBuR
public static int findPrimes(int boundary){
int primes = 0;
for (int i = 0; i < boundary; i++){
if (i % 2 != 0 && i!= 0){
for (int j = 1; j < 10; j = j+2){
if (i/j == 1){
}
}
}
}
return primes;
}
public static void main(String[] args) {
int boundary = 100;
System.out.printf("There are %d primes within the range of 0-%d",findPrimes(boundary),boundary);
}
}

View File

@@ -0,0 +1,27 @@
package numbers;
public class MaxFirstNum {
public static int maxPossible(int n1, int n2) {
String firstNum = n1 + "";
String secondNum = n2 + "";
String maxNum = null;
for (int i = 0; i < firstNum.length(); i++){
int num1 = Integer.parseInt(Character.toString(firstNum.charAt(i)));
boolean found = false;
for (int j = 0; j < secondNum.length(); j++){
if (num1 < Integer.parseInt(Character.toString(secondNum.charAt(i)))){
firstNum.replace(Character.toString(firstNum.charAt(i)), Character.toString(secondNum.charAt(j)));
secondNum.replace(Character.toString(secondNum.charAt(j)),"");
}
}
}
return Integer.parseInt(firstNum);
}
public static void main(String[] args) {
System.out.println(maxPossible(9132, 5564));
}
}

View File

@@ -0,0 +1,29 @@
package numbers;
public class SimplifyFractions {
//Edabit-Challange
//https://edabit.com/challenge/bmwpoeCybNWnBxn7M
public static String simplify(String str) {
String[] numbers = str.split("/");
int firstNum = Integer.parseInt(numbers[0]);
int secondNum = Integer.parseInt(numbers[1]);
int lowNum = Math.min(firstNum, secondNum);
for (int i = lowNum; i > 0; i--){
if (firstNum % i == 0 && secondNum % i == 0){
firstNum = firstNum/i;
secondNum = secondNum/i;
}
}
if (firstNum % secondNum == 0){
return firstNum/secondNum+"";
} else{
return firstNum+"/"+secondNum;
}
}
public static void main(String[] args) {
System.out.println(simplify("100/400"));
}
}

View File

@@ -0,0 +1,38 @@
package numbers;
// Link: https://edabit.com/challenge/RvxGLMzoPoBgXhcaC
public class ValidateCreditCard {
public static boolean validateCard(long num) {
if ((num+"").length()<14 || (num+"".length()<20)){
return false;
}
int checkDigit = Integer.parseInt((num+"").substring((num+"").length()-1));
int[] numInArray = new int [(num+"").length()-1];
for (int i = 1; i < numInArray.length+1; i++){
numInArray[i-1] = Integer.parseInt((num+"").substring((num+"").length()-i-1, (num+"").length()-i));
if (i % 2 == 1){
numInArray[i-1] *= 2;
if (numInArray[i-1]>9){
numInArray[i-1] = (numInArray[i-1]/10) + (numInArray[i-1]-10);
}
}
}
int sum = 0;
for (int i = 0; i < numInArray.length; i++){
sum += numInArray[i];
}
return 10 - (sum-((sum/10)*10)) == checkDigit;
}
public static void main(String[] args) {
System.out.println(validateCard(1234567890123456L));
}
}