Skip to content

Commit

Permalink
Refactor the project CodeNerve#71
Browse files Browse the repository at this point in the history
All algorithms implementations moved to new module 'Algorithms'. All games implementations modules moved to module new 'Games'.
Small naming refactoring so maven doesn't yell at me.
  • Loading branch information
Chris authored and Chris committed Oct 22, 2020
1 parent 056d1fb commit 09eed19
Show file tree
Hide file tree
Showing 83 changed files with 91 additions and 412 deletions.
19 changes: 0 additions & 19 deletions AddFibonacciNumbers/pom.xml

This file was deleted.

2 changes: 1 addition & 1 deletion BubbleSort/pom.xml → Algorithms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>BubbleSort</artifactId>
<artifactId>Algorithms</artifactId>


</project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Example code of binary search
*/
public class BinarySearch {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

/**
* Code for finding minimum in rotated sorted array using binary search
*/
public class FindMinimumInRotatedSortedArray {

public int findMin(int[] nums) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package dynamic_programing;

class Solution {

public int fib(int n) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package dynamic_programing;

import java.util.Arrays;

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package encryption;

import java.util.*;
public class S_Des{
public class SimpleDESEncryptionAlgorithm {
String[] keyGeneration(String key0,int[] p10,int[] p8){
StringBuilder Key1 = new StringBuilder(key0);
for(int i = 0;i<p10.length;i++){
Expand Down Expand Up @@ -178,7 +180,7 @@ public static void main(String[] args) {
String key = s.nextLine();
int pTen[] = {3,5,2,7,4,10,1,9,8,6};
int pEight[] = {6,3,7,4,8,5,10,9};
S_Des cipher= new S_Des();
SimpleDESEncryptionAlgorithm cipher= new SimpleDESEncryptionAlgorithm();
String keys[] = cipher.keyGeneration(key,pTen,pEight);

System.out.println("Key1 is:- "+keys[0]+"\n"+"Key2 is:- "+keys[1]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package matrix_operation;

import java.util.Arrays;
import java.util.Random;

Expand Down Expand Up @@ -83,7 +85,7 @@ public static double[][] elementMatrixMultiplication(double[][] A, double b) {
public static double[][] matrixAddition(double[][] A, double[][] B) {

if (A.length != B.length || A[0].length != B[0].length) {
System.out.println("Matrix A and Matrix B must have equal dimensions.\n Returing matrix A.");
System.out.println("matrix_operation.Matrix A and matrix_operation.Matrix B must have equal dimensions.\n Returing matrix A.");
return(A);
}

Expand All @@ -102,7 +104,7 @@ public static double[][] matrixAddition(double[][] A, double[][] B) {
public static double[][] matrixMultiplication(double[][] A, double[][] B) {

if (A[0].length != B.length) {
System.out.println("Matrix A number of rows must be equal to Matrix B number of columns.\nReturning matrix A");
System.out.println("matrix_operation.Matrix A number of rows must be equal to matrix_operation.Matrix B number of columns.\nReturning matrix A");
return(A);
}

Expand All @@ -125,19 +127,19 @@ public static double[][] matrixMultiplication(double[][] A, double[][] B) {
public static void main(String[] args) {

double[][] I = identityMatrix(4);
System.out.println("\nIdentity Matrix 4x4: "+Arrays.deepToString(I));
System.out.println("\nIdentity matrix_operation.Matrix 4x4: "+Arrays.deepToString(I));

double[][] A = randomMatrix(4, 4, -5, 5);
System.out.println("\nRandom Matrix A: "+Arrays.deepToString(A));
System.out.println("\nRandom matrix_operation.Matrix A: "+Arrays.deepToString(A));

A = elementMatrixMultiplication(A, 2);
System.out.println("\nMatrix A multiplied by 2: "+Arrays.deepToString(A));
System.out.println("\nmatrix_operation.Matrix A multiplied by 2: "+Arrays.deepToString(A));

double[][] A_T = transposeMatrix(A);
System.out.println("\nMatrix A Transpose: "+Arrays.deepToString(A_T));
System.out.println("\nmatrix_operation.Matrix A Transpose: "+Arrays.deepToString(A_T));

double[][] B = randomMatrix(4, 4, -5, 5);
System.out.println("\nRandom Matrix B: "+Arrays.deepToString(B));
System.out.println("\nRandom matrix_operation.Matrix B: "+Arrays.deepToString(B));

double[][] C = matrixAddition(A, B);
System.out.println("\nA + B: "+Arrays.deepToString(C));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package numbers;

import java.util.Scanner;

public class ArmstrongNum {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package numbers;

import java.util.Scanner;

/**
* Calculate Pi using infinite series
*/
public class CalculatePi {

Scanner s = new Scanner(System.in);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package numbers;

import java.util.Scanner;

class LCM {
Expand All @@ -9,7 +11,7 @@ public static void main(String arg[]) {
System.out.println("enter number 2");
b = sc.nextLong();
lcm = lcmCalculation(a, b);
System.out.println("LCM of " + a + " and " + b + " is =" + lcm);
System.out.println("numbers.LCM of " + a + " and " + b + " is =" + lcm);
}
static long lcmCalculation(long n1, long n2) {
long temp, i = 2, res;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
package numbers;/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package numbers;

import java.io.*;
public class Palindrome{
public class PalindromeNumber {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the number :");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package numbers.add_fibonacci_numbers;

import java.io.*;

public class BruteForce {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package numbers.add_fibonacci_numbers;

import java.util.HashMap;
import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package numbers.add_fibonacci_numbers;

import java.io.*;
import java.util.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package numbers.find_prime;

public class FindPrime{
public static void main(String[] args) {
int num = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package numbers.find_prime;

import java.io.*;
import java.math.*;
import java.security.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package sorting;

import java.util.Arrays;
import java.util.Scanner;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package sorting;

/* Bubblesort algorithm in Java
@Author: Rasmus Knoth Nielsen
*/
public class BubbleSort
public class BubbleSort2
{
// Method that implements the bubblesort algorithm
void bubbleSort(int arr[])
Expand Down Expand Up @@ -30,7 +32,7 @@ void printArray(int arr[])
// Main method to test if the bubblesort works as intended.
public static void main(String args[])
{
BubbleSort sort = new BubbleSort();
BubbleSort2 sort = new BubbleSort2();
int arr[] = {35, 13, 76, 9, 58, 39, 20, 1, 80, 55, 5};
System.out.println("Array before being sorted:");
sort.printArray(arr);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package sorting;

import java.util.Scanner;

public class HeapSort{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package sorting;

class MergeSort {
private void merge(int arr[], int l, int m, int r) {
int n1 = m - l + 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import java.util.Scanner;
package sorting;

import java.util.Scanner;

public class Main
public class SelectionSort
{
public static void main(String args[])
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package strings;

import java.util.Scanner;

class longestPalindromicSubString {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package strings;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package strings;

public class PermutationOfString {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package trees;

import java.util.*;
public class MirrorTree{
public class MirrorBinaryTree {
static class Node{
int data;
Node left;Node right;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class NumArray
package trees;

class NumArray
{
int[] tree;
int n;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Tree;
package trees.tree;
public class Node {


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Tree;
package trees.tree;
public class Tree extends Node {

public Tree(int data) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Tree;
package trees.tree;
// Java program to demonstrate insertions in TreeSet
import java.util.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.let.us.java.tree.avltree;
package trees.tree.tree.avltree;

import java.util.Scanner;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.let.us.java.tree.binarytree;
package trees.tree.tree.binarytree;

import java.util.Scanner;

Expand Down
19 changes: 0 additions & 19 deletions ArmstrongNumber/pom.xml

This file was deleted.

15 changes: 0 additions & 15 deletions BinarySearch/pom.xml

This file was deleted.

1 change: 0 additions & 1 deletion BinarySearch/src/main/java/ReadMe.md

This file was deleted.

15 changes: 0 additions & 15 deletions BinaryTrees/pom.xml

This file was deleted.

19 changes: 0 additions & 19 deletions CalculatePi/pom.xml

This file was deleted.

1 change: 0 additions & 1 deletion CalculatePi/src/main/java/ReadMe.md

This file was deleted.

Loading

0 comments on commit 09eed19

Please sign in to comment.