Class PE0061

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Vector<java.util.ArrayList<java.lang.Integer>> mem
      Memory for all Triangle, Square, Pentagonal, Hexagonal, Heptagonal, and Octagonal numbers with 4 digits.
    • Constructor Summary

      Constructors 
      Constructor Description
      PE0061()
      A simple constructor to set number and title.
    • Method Summary

      Modifier and Type Method Description
      private boolean check​(int a, int b)
      Checks if the given numbers follow each other.
      private int find()
      Starts the recursion by testing every Triangle number.
      private int find​(int level, int used, int first, int current)
      Tries to find a number that follows the given current number.
      void prepare()
      All 4 digit numbers are calculated and stored in the memory attribute.
      java.lang.String solve()
      This method solves the problem bei calling find() method as starting point of recursion.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • mem

        private java.util.Vector<java.util.ArrayList<java.lang.Integer>> mem
        Memory for all Triangle, Square, Pentagonal, Hexagonal, Heptagonal, and Octagonal numbers with 4 digits.
    • Constructor Detail

      • PE0061

        public PE0061()
        A simple constructor to set number and title.
    • Method Detail

      • solve

        public java.lang.String solve()
        This method solves the problem bei calling find() method as starting point of recursion.
        Returns:
        sum of the found six cyclic numbers
      • find

        private int find()
        Starts the recursion by testing every Triangle number.
        Returns:
        the found sum of the six cyclic numbers
      • find

        private int find​(int level,
                         int used,
                         int first,
                         int current)
        Tries to find a number that follows the given current number. If it finds such a number it calls itself recursively with a higher level. If level 6 is reached it checks if the current number can have the first number as follower.
        Parameters:
        level - the current level
        used - a binary number that stores all used figurate levels
        first - the very first number (a Triangle)
        current - the current number
        Returns:
        the sum of all cyclic number to the current level
      • check

        private boolean check​(int a,
                              int b)
        Checks if the given numbers follow each other.
        Parameters:
        a - the previous number
        b - the follower
        Returns:
        true if the last two digits of a are equal to the first two digits of b