Software Development and Programming Careers (Official Discussion Thread)

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,290
Reputation
5,551
Daps
83,478
Quick question: php or python for a login database:lupe:

Whichever language you know better and feel comfortable working in. If you're starting out, PHP would probably be better, as derided as it is, because there's way more resources for it when it comes to server-side programming, so if you get stuck, it'll be easier to find help.
 

///Vega+++

All Star
Joined
Jun 7, 2012
Messages
4,682
Reputation
-221
Daps
7,868
I would love to try it but I don't understand the input and output formats, despite me being familiar with the game.
yeah it's quite a hurdle at first but it really isn't that complicated actually
just understand that the sequence of numbers is the sequence of pegs holding the disc whose radius is equal to the position of the disc in the sequence (with the count starting from 1)
in other words, theses lines:
6 4
4 2 4 3 1 1
1 1 1 1 1 1

match this configuration "visually":

starting config:
Code:
5     1
6 2 4 3 _ _

final config:
Code:
1
2
3
4
5
6 _ _ _ _ _

where _ represents an empty peg

so the problem is to write a program that can give you the minimal number of moves needed to go from the starting config to the final one and enumerates those moves following this pattern
X Y means move disc on top of peg number X to the top of peg number Y
So for this particular configuration a minimal solution has the following moves (visually again):
move #1: 3 1
Code:
4
5     1
6 2 _ 3 _ _


move #2: 4 3
Code:
4
5
6 2 1 3 _ _

move #3: 4 1
Code:
3
4
5
6 2 1 _ _ _

move #4: 2 1
Code:
2
3
4
5
6 _ 1 _ _ _


and .... move #5: 3 1
Code:
1
2
3
4
5
6 _ _ _ _ _

Got it now ?
The first time I read this problem a little over 2 years ago now, the mere fact that you had to figure out the input and output syntax made me want to solve it.
I have a solution that's not quite optimal yet. I used recursion but the algorithm is dumb, basically trying every configuration possible starting from the first peg and checking each time if the final config has been found and if its "path" is shorter than previous final config found in a previous iteration/recursive call. yea, real ugly. the only intelligent thing it does is to avoid moving the same disk in two successive moves, also moving a disk over a disk of smaller radius, obviously.
Right now I want to add more intelligence to that code to solve it like how I do when I go about it manually, like trying first to put in its final position the disc of greater radius among the discs that get moved between starting and final config. THAT alone should make my code spare thousands and thousands of unnecessary iterations/recursive calls.
And when I'm done with that, if I'm satisfied with its performance - let's say...if it's able to find a solution for a non trivial config of 8 discs and 5 pegs - then I'd like to translate my code from java to C,
yea I'm quite a masochist.





 
Last edited:

///Vega+++

All Star
Joined
Jun 7, 2012
Messages
4,682
Reputation
-221
Daps
7,868
I'm up for doing programming exercises, but we should start with something simpler
aight, I start, something simple
1 - write a function that take 2 integers and return the greater of the two
2 - write a function that take 3 integers and return the greater of the three...using the function written in question 1
 

keepemup

Banned
Joined
Jun 9, 2012
Messages
4,743
Reputation
-977
Daps
5,349
yeah it's quite a hurdle at first but it really isn't that complicated actually
just understand that the sequence of numbers is the sequence of pegs holding the disc whose radius is equal to the position of the disc in the sequence (with the count starting from 1)
in other words, theses lines:
...
Got it now ?
Got it. I'm almost certain I've seen this problem years ago however I don't think it was described this way.

I think you may have made a mistake though,

For the first example, disc 1 and 3 should be on peg 4.

6(discs) 4(pegs)
4 2 4 3 1 1 [Peg]
1 2 3 4 5 6 [Disc]
I read this that disc 1 is on peg 4, disc 2 is on peg 2, disc 3 is on peg 4, disc 4 is on peg 3, disc 5 is on peg 1 and disc 6 is also on peg 1.

Keeping in mind the property that higher number discs/radius are first

it should be

5 1
6 2 4 3 (Disc arrangement on pegs indicated below)
1 2 3 4 (Pegs 1 through 4)
 
Last edited:

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,290
Reputation
5,551
Daps
83,478
aight, I start, something simple
1 - write a function that take 2 integers and return the greater of the two
2 - write a function that take 3 integers and return the greater of the three...using the function written in question 1

Javascript:
Code:
function greater(a, b)
{
  if(a != b)
      return  a > b ? a : b;
  else
      return 'there are equivalent values';
}

function greater3(a, b, c)
{
  var holder = greater(a, b);
  if(typeof holder != 'string')
      return greater(holder, c);
  else
      return 'there are equivalent values';
}

greater3(4,8,3);

Ruby
Code:
def greater2(a,b)
  if a != b
  a > b ? a : b
  else
  puts 'There are equivalent values'
  return false
  end
end
   
def greater3(a, b, c)
  if greater2(a, b) != false
  holder = greater2(a,b)
  holder2 = greater2(holder, c)
  end
end


greater3(1, 4, 4)
 
Last edited:

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,290
Reputation
5,551
Daps
83,478
I've been playing around with Ruby on Rails and ASP.NET MVC. I've also spent time with Node.js. My opinion?

Ruby on Rails is quite easy to use, but due to lack of parenthesis, sometimes it can be hard to comprehend Ruby. I love how it has facilities for testing and an ORM built in, but in a way, I almost feel like it makes things 'too easy', and it gets hard to understand exactly what is going on because so much is hidden away to make it simpler. ROR is fast and simple to get into, but if you want to server-side development on a more deeper level, you'll probably be better off exploring the other two options. The best thing about ROR is the community and the books are great at teaching you how to put an app in production. I learned about using Github and then deploying on Heroku. I also did a tiny bit of testing, but I'll have to focus more on this subject.

Node.Js is low-level and I felt like I was spending more time learning about the eco-system than actually doing anything with it. Due to how low level Node.js and how the approach in the node community is to use tiny 'middleware' for various functionality, this can be very confusing. Couple this with having to deal with asynchronous code and the nested callbacks that result, I decided to put this on the backburner.

ASP.net MVC. Overall, I like this the best due to the fact that it is very convenient and not overly low-level like Node, but it's not trying to abstract things away so much that it almost hides the base technologies like Rails can do, especially with Active Record, which does the SQL for you. The only problem is that it's a lot easier to find options to deploy Rails or Node apps and you don't have to worry about licensing fees with those two as you do with using a Microsoft stack.

I'll probably keep on rotating between all three technologies because you learn a lot seeing how different things are handled in different communities. You see rails practices seep over to the Node community, and you see Node technologies like Grunt seep over to the ASP.net community, etc.
 

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,290
Reputation
5,551
Daps
83,478
yeah it's quite a hurdle at first but it really isn't that complicated actually
just understand that the sequence of numbers is the sequence of pegs holding the disc whose radius is equal to the position of the disc in the sequence (with the count starting from 1)
in other words, theses lines:
6 4
4 2 4 3 1 1
1 1 1 1 1 1

match this configuration "visually":

starting config:
5 1
6 2 4 3 _ _

final config:
1
2
3
4
5
6 _ _ _ _ _

where _ represents an empty peg

so the problem is to write a program that can give you the minimal number of moves needed to go from the starting config to the final one and enumerates those moves following this pattern
X Y means move disc on top of peg number X to the top of peg number Y
So for this particular configuration a minimal solution has the following moves (visually again):
move #1
4
5 1
6 2 _ 3 _ _


move #2
4
5
6 2 1 3 _ _

move #3
3
4
5
6 2 1 _ _ _

move #4
2
3
4
5
6 _ 1 _ _ _


and .... move #5
1
2
3
4
5
6 _ _ _ _ _

Got it now ?
The first time I read this problem a little over 2 years ago now, the mere fact that you had to figure out the input and output syntax made me want to solve it.
I have a solution that's not quite optimal yet. I used recursion but the algorithm is dumb, basically trying every configuration possible starting from the first peg and checking each time if the final config has been found and if its "path" is shorter than previous final config found in a previous iteration/recursive call. yea, real ugly. the only intelligent thing it does is to avoid moving the same disk in two successive moves, also moving a disk over a disk of smaller radius, obviously.
Right now I want to add more intelligence to that code to solve it like how I do when I go about it manually, like trying first to put in its final position the disc of greater radius among the discs that get moved between starting and final config. THAT alone should make my code spare thousands and thousands of unnecessary iterations/recursive calls.
And when I'm done with that, if I'm satisfied with its performance - let's say...if it's able to find a solution for a non trivial config of 8 discs and 5 pegs - then I'd like to translate my code from java to C,
yea I'm quite a masochist.


What book did you use to learn algorithms? I really want to spend more time on data structures and algorithms, and I will once I get a few other things out of the way.
 

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,290
Reputation
5,551
Daps
83,478
Anyone here does any Machine Learning? Trying to figure out the best way to jump in. Usually don't program outside of work (AngularJS/Java mostly) but it seems Machine Learning is the future.

Machine learning is something that requires a sizable investment of time and a strong mathematics background as well as a strong hold on data structures and algorithms I believe. If you're going to go into it because it's the supposed 'next best thing', I'd avoid it.
 

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,290
Reputation
5,551
Daps
83,478
On a language note, thank God for ES6 and Typescript, which is an ES6 subscript. Doing OO code in ES5 and below creates headache inducing code. Here is Typescript, and then here follows the generated ES5 compatible code.

Code:
class Greeter {
  greeting: string;
  constructor(message: string) {
  this.greeting = message;
  }
  greet() {
  return "Hello, " + this.greeting;
  }
}

class Greeter2 extends Greeter {}

var greeter = new Greeter("world");

var button = document.createElement('button');
button.textContent = "Say Hello";
button.onclick = function() {
  alert(greeter.greet());
}

document.body.appendChild(button);

Code:
var __extends = (this && this.__extends) || function (d, b) {
  for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  function __() { this.constructor = d; }
  __.prototype = b.prototype;
  d.prototype = new __();
};
var Greeter = (function () {
  function Greeter(message) {
  this.greeting = message;
  }
  Greeter.prototype.greet = function () {
  return "Hello, " + this.greeting;
  };
  return Greeter;
})();
var Greeter2 = (function (_super) {
  __extends(Greeter2, _super);
  function Greeter2() {
  _super.apply(this, arguments);
  }
  return Greeter2;
})(Greeter);
var greeter = new Greeter("world");
var button = document.createElement('button');
button.textContent = "Say Hello";
button.onclick = function () {
  alert(greeter.greet());
};
document.body.appendChild(button);

Generated code was taken from here:
Playground - Welcome to TypeScript

So as you can see, getting something resembling classic OO was a headache. Although you have some JS devs complaining about the 'class' keyword obscuring the prototype system, I'm 100% for it. It makes code 10,000 times easier to read and understand and saves a ton of time.
 

///Vega+++

All Star
Joined
Jun 7, 2012
Messages
4,682
Reputation
-221
Daps
7,868
I think you may have made a mistake though,

For the first example, disc 1 and 3 should be on peg 4.
I didn't make a mistake, it's just that the board formatting deleted the spaces between discs 5 and 1
as you can see in your own msg
don't know if wrapping it up between code tags will correct it. edit: it does

Javascript:
Code:
function greater(a, b)
{
  if(a != b)
      return  a > b ? a : b;
  else
      return 'there are equivalent values';
}

function greater3(a, b, c)
{
  var holder = greater(a, b);
  if(typeof holder != 'string')
      return greater(holder, c);
  else
      return 'there are equivalent values';
}

greater3(4,8,3);

Ruby
Code:
def greater2(a,b)
  if a != b
  a > b ? a : b
  else
  puts 'There are equivalent values'
  return false
  end
end

def greater3(a, b, c)
  if greater2(a, b) != false
  holder = greater2(a,b)
  holder2 = greater2(holder, c)
  end
end


greater3(1, 4, 4)
yes
but I wouldn't have bothered testing if the numbers are equal though. just return their value if that's the case.
so javascript and ruby let you write functions that return different types ?
I don't really know either language but I gathered that from your code

What book did you use to learn algorithms? I really want to spend more time on data structures and algorithms, and I will once I get a few other things out of the way.
most of my training comes from university. no go-to book really. I just have a basic understanding of some key concepts and data structures.
what I find funny about recursion is that it lets you write in a more simplier way what you'll have a hard time expressing iteratively, simplier code yes but most times far from optimal. So learning to tweak code to make it run faster is something I find quite rewarding.
about data structures, learning java probably helped me most, the API is very rich and you cannot really do without it. trees and hashsets are my favorite to work with.
edit: taking a course on/reading about compilers helped me a lot too
 
Last edited:

kevm3

follower of Jesus
Supporter
Joined
May 2, 2012
Messages
16,290
Reputation
5,551
Daps
83,478
I didn't make a mistake, it's just that the board formatting deleted the spaces between discs 5 and 1
as you can see in your own msg
don't know if wrapping it up between code tags will correct it. edit: it does


yes
but I wouldn't have bothered testing if the numbers are equal though. just return their value if that's the case.
so javascript and ruby let you write functions that return different types ?
I don't really know either language but I gathered that from your code


most of my training comes from university. no go-to book really. I just have a basic understanding of some key concepts and data structures.
what I find funny about recursion is that it lets you write in a more simplier way what you'll have a hard time expressing iteratively, simplier code yes but most times far from optimal. So learning to tweak code to make it run faster is something I find quite rewarding.
about data structures, learning java probably helped me most, the API is very rich and you cannot really do without it. trees and hashsets are my favorite to work with.
edit: taking a course on/reading about compilers helped me a lot too

The beauty of dynamic languages... which also have their downsides. I'm a beginner on Ruby, so I can't speak definitively on it, but JS pretty much lets you return what you feel. You can return functions, whether they are called or not. For example:
Code:
function a()
{
  return function() {console.log("testing")}
}

var a = a();  /* you call the outer function, it is evaluated and since you didn't call the inner function it is assigned to variable a */

a(); // prints "testing"

This freedom JS offers you allows you to create all sorts of mind-bending things, which can also make it very difficult to read and understand at times.
 

///Vega+++

All Star
Joined
Jun 7, 2012
Messages
4,682
Reputation
-221
Daps
7,868
another exercice (taken from hackerrank 's sample test): Test :: powered by HackerRank question 2
1439037673.jpg

using this java class for representing a node/tree:
Java:
/* Write your custom functions here */
static int diameterOfTree(Node root) {
/* For your reference
   class Node {
       Node left, right;
       int data;
               Node(int newData) {
           left = right = null;
           data = newData;
       }
   }
*/    
}
or this structure if you prefer C/C++
Code:
/* Write your custom functions here */
int diameterOfTree(node * root) {
/* For your reference
  struct node {
   struct node *left,*right;
   int val;
};
*/
}
you can follow the link, log in and test your code there right on the page
using this input
Code:
1
6
40
30
65
78
22
38
that should output
Code:
5

In my solution I actually made use of the 2 functions from the previous exercise
 

///Vega+++

All Star
Joined
Jun 7, 2012
Messages
4,682
Reputation
-221
Daps
7,868
At this time, my solution for the Hanoi tower inspired exercice, after a recent cleanup. I'll tweak it to make it run faster and post the tweak later.
Code:
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
* @author LivArmandNoumi_(l-a-n)
*
*         Facebook hiring sample test
*
*         There are K pegs. Each peg can hold discs in decreasing order of
*         radius when looked from bottom to top of the peg. There are N discs
*         which have radius 1 to N; Given the initial configuration of the pegs
*         and the final configuration of the pegs, output the moves required to
*         transform from the initial to final configuration. You are required
*         to do the transformations in minimal number of moves.
*
*         A move consists of picking the topmost disc of any one of the pegs
*         and placing it on top of anyother peg. At anypoint of time, the
*         decreasing radius property of all the pegs must be maintained.
*
*         Constraints: 1<= N<=8 3<= K<=5
*
*         Input Format: N K 2nd line contains N integers. Each integer in the
*         second line is in the range 1 to K where the i-th integer denotes the
*         peg to which disc of radius i is present in the initial
*         configuration. 3rd line denotes the final configuration in a format
*         similar to the initial configuration.
*
*         Output Format: The first line contains M - The minimal number of
*         moves required to complete the transformation. The following M lines
*         describe a move, by a peg number to pick from and a peg number to
*         place on. If there are more than one solutions, it's sufficient to
*         output any one of them. You can assume, there is always a solution
*         with less than 7 moves and the initial confirguration will not be
*         same as the final one.
*
*         Sample Input #00:
*
*         2 3
*         1 1
*         2 2
*
*         Sample Output #00:
*
*         3
*         1 3
*         1 2
*         3 2
*
*         Sample Input #01:
*
*         6 4
*         4 2 4 3 1 1
*         1 1 1 1 1 1
*
*         Sample Output #01:
*
*         5
*         3 1
*         4 3
*         4 1
*         2 1
*         3 1
*
*         Sample Input #02
*         6 4
*         1 2 1 2 3 4
*         2 2 1 1 3 4
*
*         Sample Output #02
*         7
*         1 3
*         1 4
*         2 4
*         2 1
*         4 2
*         3 2
*         4 1
*
*         NOTE: You need to write the full code taking all inputs are from
*         stdin and outputs to stdout If you are using "Java", the classname is
*         "Solution"
*
*/
/* Represents a move in a path candidate solution by its start and end pegs
    and its position or depth in said path which is of type ArrayList<Node> */
class Node {
    int from;
    int to;
    int depth;

    public Node(int from, int to, int depth) {
        this.from = from;
        this.to = to;
        this.depth = depth;
    }
    public int getFrom() {
        return from;
    }
    public int getTo() {
        return to;
    }
    public int getDepth() {
        return depth;
    }
}

/* The main class*/
public class Solution {
    private int discs;                /* the number of discs, each one being represented by its radius of type integer between 1 and the value of discs */
    private int pegs;                /* the number of pegs, each one being represented by an integer between 1 and the value of pegs */
    public static List<Node> path;        /* will contain the succession of moves solving the problem if there's one for the specified max number of moves*/
    private int[] in;                /* represents the initial configuration */
    private int[] out;                /* represents the final configuration */
    private int[] tops;                /* contains for each peg the radius (hence the number) of its topmost disc */
    private int[] notAllowed;            /* if notAllowed[p] == r then disc of radius r (r>0) CANNOT be put on top of peg p and if notAllowed[p] == -1 then any disc of radius lower than
                                                   getTop(conf,p) can be put atop peg p */
    private boolean limitReached;        /* set at true whenever the maximum number of moves have been reached for the path that is being built at that moment */
    public final int MAX_MOVES;            /* the desired maximum number of moves for the solution */

    /* Constructor. Initializes what needs to be */
    public Solution(int discs, int pegs, int maxMoves) {
        this.discs = discs;
        this.pegs = pegs;
        MAX_MOVES = maxMoves;
        init();
    }

    /* Initialization */
    private void init() {
        path = new ArrayList<Node>(MAX_MOVES);
        limitReached = false; /* not really necessary according to the Java language spec but still */
        in = new int[discs];
        out = new int[discs];
        tops = new int[pegs];
        notAllowed = new int[pegs];
        for (int i=0; i < pegs; i++) {
            notAllowed[i] = -1;
        }
    }

    /* Used for filling up an array of integers with integers */
    private void fillTab(int [] tab, int elt, int idx) {
        if ((idx >= 0) && (idx < tab.length))
            tab[idx] = elt;
    }

    /* Used for filling up the in array */
    public void fillIn(int elt, int idx) {
        fillTab(in, elt, idx);
    }

    /* Used for filling up the out array */
    public void fillOut(int elt, int idx) {
        fillTab(out, elt, idx);
    }

    /* Fills up the tops array */
    public void fillTops() {
        int i;

        for (i=0; i < pegs; i++) {
            tops[i] = getTop(in, i);
        }
    }

    /* Returns the number of the topmost disc of a given peg for a given configuration */
    public int getTop(int [] tab, int peg) {
        int i, result = -1;

        for(i=0; i < tab.length; i++) {
            if (tab[i] == peg + 1) {
                result = i;
                break;
            }
        }
        return result;
    }

    /* Performs a move from peg1 to peg2 */
    public void move(int [] tabIn, int [] tabTops, int[] tabNotAllowed, int peg1, int peg2) {
    int moved_disk = tabTops[peg1];    
    tabIn[moved_disk] = peg2 + 1;
        tabTops[peg1] = getTop(tabIn, peg1);
        tabTops[peg2] = moved_disk;
        tabNotAllowed[peg1] = moved_disk;
        if (tabNotAllowed[peg2] != -1) tabNotAllowed[peg2] = -1;
    }

    /* The procedure doing the main job.
       For a given temporary path being built and the current configuration of
       the discs and pegs, attempts to perform a move from peg1 to peg2 if the
       limit of moves hasn't been reached yet. If the move is possible, it is
       performed and a recursive call is made only if neither the subsequent path
       matches the final configuration nor the limit of moves is reached */
    private void step(List<Node> l, int [] tabIn, int [] tabTops, int [] tabNotAllowed, int peg1, int peg2) {
        List<Node> tmp = new ArrayList<Node>(l), tmp_;
        int [] tmpIn = Arrays.copyOf(tabIn, tabIn.length), tmpIn_;
        int [] tmpTops = Arrays.copyOf(tabTops, tabTops.length), tmpTops_;
        int [] tmpNotAllowed = Arrays.copyOf(tabNotAllowed, tabNotAllowed.length), tmpNotAllowed_;
        int top1, top2;

        if (tmp.size() >= MAX_MOVES)
            limitReached = true;
        else if (limitReached)
            limitReached = false; /* This is useful for making sure we backtrack for just one step when a recurvive call returns */
        if (!limitReached) {
            top1 = getTop(tmpIn, peg1);
            top2 = getTop(tmpIn, peg2);
            if ((top1 != tmpNotAllowed[peg2]) && (top1 >= 0) && ((top1 < top2) || (top2 == -1))) {
                move(tmpIn, tmpTops, tmpNotAllowed, peg1, peg2);
                tmp.add(new Node(peg1 + 1, peg2 + 1, tmp.size() + 1));
                if (tmp.size() == MAX_MOVES) {
                    limitReached = true;
                }
                if (Arrays.equals(tmpIn,out)) {
                    if (path.isEmpty() || (path.size() > tmp.size())) path = tmp;
                    return;
                } else {
                    if (limitReached)
                        return;
                    int i, j;
                    for (i=0; i < pegs; i++) {
                        tmp_ = new ArrayList<Node>(tmp);
                        tmpIn_ = Arrays.copyOf(tmpIn, tmpIn.length);
                        tmpTops_ = Arrays.copyOf(tmpTops, tmpTops.length);
                        tmpNotAllowed_ = Arrays.copyOf(tmpNotAllowed, tmpNotAllowed.length);
                        if (i != peg2) {
                            for (j=0; j < pegs; j++) {
                                if (j != i) step(tmp_, tmpIn_, tmpTops_, tmpNotAllowed_, i, j);
                            }
                        }
                    }
                }
            }
            else return;
        }
    }

    // Path builder
    public void buildPath() {
        List<Node> path_ = new ArrayList<Node>(MAX_MOVES);
        int i, j;
        double startTime = System.nanoTime();

        for (i=0; i < pegs; i++) {
            for (j=0; j < pegs; j++) {
                if (i != j) step(path_, in, tops, notAllowed, i, j);
                path_.clear();
            }
        }
        if (!path.isEmpty()) {
            System.out.println("Solution found in " + (System.nanoTime() - startTime) / 1000000000 + " second(s):");
            this.display(path);
        }
    }

    /* If a solution was found, displays its moves */
    public void display(List<Node> l) {
        if (!l.isEmpty()) {
            System.out.println(l.get(l.size() - 1).getDepth());
            for (Node n: l) {
                System.out.println(n.getFrom() + " " + n.getTo());
            }
        }
    }

    /* Reads the input data, calculates a solution and eventually displays it */
    public static void main(String[] args) {
        int i, discs, pegs, maxMoves;
        maxMoves = Integer.valueOf(args[0]).intValue();
        if (maxMoves > 18) {
            System.err.println("Number of moves must not be greater than 18");
            System.exit(-1);
        }
        Scanner scanner = new Scanner(System.in);
        discs = scanner.nextInt();
        pegs = scanner.nextInt();
        if (discs * pegs <= 0) {
            System.err.println("Number of discs/pegs must be greater than 0");
            System.exit(-2);
        }
        else {
            Solution solution = new Solution(discs, pegs, maxMoves);
            for (i=0; i<discs; i++) {
                solution.fillIn(scanner.nextInt(), i);
            }
            for (i=0; i<discs; i++) {
                solution.fillOut(scanner.nextInt(), i);
            }
            solution.fillTops();
            solution.buildPath();
        }
    }
}
 
Last edited:
Top