Posts

Showing posts from February, 2015

How to run npm installed components from commandline in Windows?

Image
When you are working with windows and nodejs, then you might face this problem, whatever npn packages you install might not be accessible through commandline. By this I mean, is that, suppose you did: npm install -g bower And then executed : bower install Windows might give you an error that 'bower' is unrecognized. A solution to the problem is to add npm global repository to your system path. To do so execute npm config get prefix To get the npm global repository path. Copy this path and follow following steps to add to windows path: On your computer, select  Start->Settings->Control Panel->System : A "System Properties" dialog box will appear. Click it's  Advanced  tab: Click the  Environment variables  button: An  Environment Variables  dialog box will appear. In the  System variables  section, scroll down until you find the  PATH  variable. Select this variable: Click the  Edit  button to edit the value of th

AI Planning Tree Search Algorithm for Missionary And Cannibal Problem in Java

I have been doing AI Planning course and I decided to implement the first basic problem in Java. To implement this, i tried to create the algorithm with right level of abstractions so that it can be applied to any problem in future. Some take aways in my package structure is that, I have maintained all the generic reusable code in definitions package and problem specific code in monkcannibal package. To solve the problem, I have implemented State which had successor method, IProblem which defined the problem to solve and IStrategy which defined the strategy to take for state transition. Here I have used two strategies for tree travesal, breadth first search aka, BFS and Depth First Search, aka DFS. The code is available on github at: https://github.com/biplav/aiplanning The main file is : com.biplav.aiplanning.problems.monkcanibbal.MissionaryCannibalPlan.java And the output is: 1:L->3m1cfalseboat R->0m2ctrueboat 2:L->3m2ctrueboat R->0m1cfals

Zopper Programming assignment Question 3 (Project Group)

The third question is also a simple one: Link to the question is on HackerRank:  http://www.hackerearth.com/problem/algorithm/project-team/ The submission code in python can be seen here:

Zopper Programming Assessment Problem 2 with solution

This is the second problem from HackerEarth that I tried for the friend for interview: Problem: HackerMan says that 5 and 8 are smart digits. A positive integer is called a smart number if it has only smart digits in its decimal representation. HackerMan has three sets of numbers. And he needs your help to find out the number of distinct smart numbers that he can make using one number from each of the three sets. You have to help in it Note:  You must not count the same smart number more than once. Constraints The three sets will contain between 1 and 50 elements, inclusive. Each number in the three sets will contain numbers between 1 and 30,000, inclusive. Input Format The first, third and fifth lines will contain a number N that will specify the count of numbers in the sets on the second, fourth and sixth lines of input. The second, fourth and sixth line will contain the three sets of numbers respectively. Output Format Print a single line containing the coun

Zopper online assesment question on HackerEarth with solution.

Recently a friend asked me to solve a problem which he got on one of the interview, online assessment test. I decided to document my solution here. The companies name was Zopper and the question was asked on the initial online screening test on HackerEarth. Problem: HackerMan says that 5 and 8 are smart digits. A positive integer is called a smart number if it has only smart digits in its decimal representation. HackerMan has three sets of numbers. And he needs your help to find out the number of distinct smart numbers that he can make using one number from each of the three sets. You have to help in it Note:  You must not count the same smart number more than once. Constraints The three sets will contain between 1 and 50 elements, inclusive. Each number in the three sets will contain numbers between 1 and 30,000, inclusive. Input Format The first, third and fifth lines will contain a number N that will specify the count of numbers in the sets on the second, fourth