package de.sebhn.algorithm.excercise2;

import java.math.BigInteger;
import java.util.Scanner;

public class Quaternstrings {

  private int n;
  private BigInteger a0;
  private BigInteger a1;
  private BigInteger a2;
  private BigInteger a3;

  public Quaternstrings(int n) {
    this.n = n;
    a0 = a1 = a2 = a3 = BigInteger.ONE;
    System.out.println("n=" + n);
  }

  public static void main(String[] args) throws Exception {
    System.out.println("Bitte geben sie eine Zahl ein: ");
    int n;
    try (Scanner s = new Scanner(System.in)) {
      n = Integer.parseInt(s.next());
    }
    Quaternstrings.calculate(n);
  }

  public static BigInteger calculate(int n) {
    return new Quaternstrings(n).calculate();
  }

  private BigInteger calculate() {
    for (int i = 1; i < n; i++) {
      addInPlace();
    }
    BigInteger amountOfPaths = getAmountOfPaths();
    System.out.println("Amount of paths: " + amountOfPaths);
    return amountOfPaths;
  }

  private BigInteger getAmountOfPaths() {
    BigInteger amountOfPaths = a0.add(a1).add(a2).add(a3);
    return amountOfPaths;
  }

  private void addInPlace() {
    BigInteger newa0 = a0.add(a2).add(a3); // exclude 1
    BigInteger newa1 = a1.add(a0).add(a3); // exclude 2
    BigInteger newa2 = a2.add(a0).add(a1); // exclude 3
    BigInteger newa3 = a3.add(a0).add(a1).add(a2); // every number allowed

    a0 = newa0;
    a1 = newa1;
    a2 = newa2;
    a3 = newa3;
  }
}

@@ -94,16 +94,175 @@
 ner;%0D%0A%0D%0A
+/**%0D%0A * Find all numbers for a specific pattern %3Cbr%3E%0D%0A * Disallowed numbers are: i,i+1%0D%0A * %0D%0A * @author Phi Long Tran %3C191624%3E & Manuel Wessner %3C191711%3E%0D%0A */%0D%0A
 public c
@@ -905,32 +905,144 @@
 late();%0D%0A  %7D%0D%0A%0D%0A
+  /**%0D%0A   * Calculates all possible combinations%0D%0A   * %0D%0A   * @return calculated number of combinations%0D%0A   */%0D%0A
   private BigInt
@@ -1135,36 +1135,35 @@
  BigInteger 
-amountOfPath
+combination
 s = getAmoun
@@ -1166,19 +1166,34 @@
 mountOfP
-ath
+ossibleCombination
 s();%0D%0A  
@@ -1229,30 +1229,45 @@
 of p
-aths: %22 + amountOfPath
+ossible combinations: %22 + combination
 s);%0D
@@ -1274,36 +1274,35 @@
 %0A    return 
-amountOfPath
+combination
 s;%0D%0A  %7D%0D%0A%0D%0A 
@@ -1333,19 +1333,34 @@
 mountOfP
-ath
+ossibleCombination
 s() %7B%0D%0A 
@@ -1373,28 +1373,35 @@
 Integer 
-amountOfPath
+possibleCombination
 s = a0.a
@@ -1440,20 +1440,27 @@
 urn 
-amountOfPath
+possibleCombination
 s;%0D%0A

add javadoc / rename path to combinations