Skip to content

Develop #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion algorithm-exercises-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ configurations.checkstyle {

def jacocoExclusions = [
'**/*App.class',
'**/CustomLogger.class'
'**/util/*'
];

test {
Expand Down
6 changes: 3 additions & 3 deletions algorithm-exercises-java/src/main/java/ae/Problem0000.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package ae;

import util.Log;

/**
* {TITLE}.
*
Expand All @@ -13,16 +15,14 @@ public class Problem0000 {

private Problem0000() {}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();

/**
* Problem template method.
*/
public static Integer problem0000() {
Integer result = null;

String log = String.format("Problem 00XX solved: %d", result);
logger.info(log);
Log.info(log);

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
*/
public class ArraysLeftRotation {

private ArraysLeftRotation() {
}
private ArraysLeftRotation() {}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();
static final int FIRST_POSITION = 0;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
*/
public class CrushBruteForce {

private CrushBruteForce() {
}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();
private CrushBruteForce() {}

private static final int INITIALIZER = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
*/
public class CrushOptimized {

private CrushOptimized() {
}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();
private CrushOptimized() {}

/**
* arrayManipulation.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ae.hackerrank.projecteuler;

import util.Log;

/**
* Multiples of 3 and 5.
*
Expand All @@ -9,8 +11,6 @@ public class Euler001 {

private Euler001() {}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();

/**
* Greatest common divisor.
*/
Expand Down Expand Up @@ -45,7 +45,7 @@ public static Long euler001(Integer a, Integer b, Integer n) {
- sumOfArithmeticProgression((long) n, lcm);

String log = String.format("Problem 001 solved: %d", result);
logger.info(log);
Log.info(log);

return result;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ae.hackerrank.projecteuler;

import util.Log;

/**
* Even Fibonacci numbers.
*
Expand All @@ -9,8 +11,6 @@ public class Euler002 {

private Euler002() {}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();

private static Long fibbo(Integer n) {
Long total = 0L;
Long fibo;
Expand All @@ -37,7 +37,7 @@ public static Long euler002(Integer n) {
Long result = fibbo(n);

String log = String.format("Problem 002 solved: %d", result);
logger.info(log);
Log.info(log);

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
*/
public class BirthdayCakeCandles {

private BirthdayCakeCandles() {
}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();
private BirthdayCakeCandles() {}

/**
* birthdayCakeCandles.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public class CompareTriplets {

private CompareTriplets() {}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();

/**
* compareTriplets.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public class DiagonalDifference {

private DiagonalDifference() {}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();

/**
* diagonalDifference.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public class MiniMaxSum {

private MiniMaxSum() {}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();

/**
* miniMaxSum.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
*/
public class PlusMinus {

private PlusMinus() {
}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();
private PlusMinus() {}

/**
* plusMinus.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ae.hackerrank.warmup;

import java.util.List;
import util.Log;

/**
* Simple Array Sum.
Expand All @@ -11,8 +12,6 @@ public class SimpleArraySum {

private SimpleArraySum() {}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();

/**
* simpleArraySum.
*/
Expand All @@ -24,7 +23,7 @@ public static int simpleArraySum(List<Integer> ar) {
}

String log = String.format("simpleArraySum solved: %d", total);
logger.info(log);
Log.info(log);

return total;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ public class SolveMeFirst {

private SolveMeFirst() {}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();

/**
* solveMeFirst.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
*/
public class Staircase {

private Staircase() {
}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();
private Staircase() {}

/**
* staircase.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
*/
public class TimeConversion {

private TimeConversion() {
}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();
private TimeConversion() {}

/**
* timeConversion.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
*/
public class VeryBigSum {

private VeryBigSum() {
}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();
private VeryBigSum() {}

/**
* aVeryBigSum.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ae.projecteuler;

import java.util.logging.Logger;
import util.Log;

/**
* Multiples of 3 and 5.
Expand All @@ -11,8 +11,6 @@ public class Problem0001 {

private Problem0001() {}

static Logger logger = util.CustomLogger.getLogger();

/**
* Problem0001.
*/
Expand All @@ -23,14 +21,14 @@ public static Integer problem0001(Integer top) {
for (i = 0; i < top; i++) {
if (i % 3 == 0 || i % 5 == 0) {
String log = String.format("Line result: %d", i);
logger.fine(log);
Log.debug(log);

result += i;
}
}

String log = String.format("Problem 0001 solved: %d", result);
logger.info(log);
Log.info(log);

return result;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ae.projecteuler;

import java.util.logging.Logger;
import util.Log;

/**
* Even Fibonacci numbers.
Expand All @@ -11,8 +11,6 @@ public class Problem0002 {

private Problem0002() {}

static Logger logger = util.CustomLogger.getLogger();

/**
* Problem template method.
*/
Expand All @@ -28,7 +26,7 @@ public static Integer problem0002(int top) {
fibo = last2 + last1;

String log = String.format("Fibonacci(%d) = %d", i, fibo);
logger.fine(log);
Log.debug(log);

if (fibo % 2 == 0) {
evenSum += fibo;
Expand All @@ -41,7 +39,7 @@ public static Integer problem0002(int top) {
} while (fibo < top);

String log = String.format("Problem 0002 result: %d", evenSum);
logger.info(log);
Log.info(log);

return evenSum;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ae.projecteuler.helper.Divisors;
import ae.projecteuler.helper.NaturalNumber;
import java.util.Arrays;
import util.Log;


/**
Expand All @@ -14,7 +15,6 @@ public class Problem0003 {

private Problem0003() {}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();

/**
* Problem 0003.
Expand All @@ -28,7 +28,7 @@ public static Long problem0003(Long top) {

String log;
log = String.format("Divisors of %d: %s", top, Arrays.toString(divs));
logger.info(log);
Log.info(log);

Long maxPrimeFactor = null;
Integer i = middle;
Expand All @@ -38,13 +38,13 @@ public static Long problem0003(Long top) {
boolean prime = NaturalNumber.isPrime(divs[i]);

log = String.format("%d is Prime?: %b", i, prime);
logger.fine(log);
Log.debug(log);

if (prime) {
maxPrimeFactor = divs[i];

log = String.format("Problem 0003 solved: %d", maxPrimeFactor);
logger.info(log);
Log.info(log);

return maxPrimeFactor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package ae.projecteuler;

import ae.projecteuler.helper.Palindrome;
import util.Log;

/**
* Largest palindrome product.
Expand All @@ -20,7 +21,6 @@ public class Problem0004 {

private Problem0004() {}

static java.util.logging.Logger logger = util.CustomLogger.getLogger();

/**
* Problem template method.
Expand All @@ -42,7 +42,7 @@ public static Integer problem0004(int bottom, int top) {

if (Palindrome.isPalindrome(Long.valueOf((long) j * (long) i))) {
String log = String.format("FOUND: %d x %d = %d is Palindrome", i, j, i * j);
logger.fine(log);
Log.debug(log);

if (foundPalindrome == null || i * j > foundPalindrome) {
foundi = i;
Expand All @@ -64,7 +64,7 @@ public static Integer problem0004(int bottom, int top) {
foundPalindrome,
cycles);

logger.info(log);
Log.info(log);

return foundPalindrome;
}
Expand Down
Loading