Epic Systems Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
2
of 2 vote

public int glitch_steps (int x, int y) {
int total_steps = 0;
int count = 1;
while (total_steps != y) {
total_steps += (count*x) - (x+count);
count ++;
}
return y;
}

- epic_tester July 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

lol you are returning one of the i/p of ur method as o/p .You can just write' return y ' instead of doing all calculation steps and while loop.

So your answer is definitely not the question asks u to find.

- xx April 10, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

what is y, here?

- Anonymous June 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

when the glitch turns 180 degree, please clear these things

- Anonymous June 22, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

is y, no of times it will do like this, from x, 2x, ... yx

And we have to calculate summation over i=1to y(x*i + x+i)and the final position

- Anonymous June 22, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think x = number of steps taken each time, y = the number of steps taken before turning 180 degree, and total = total number of steps taken by the robot. Example : total = 50, y = 25 (so the robot turns 180 after taking 25 steps)and x = 5.

- Unknown July 20, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

not sure about problem description, but lets check next sum:

[x-(x+1)] + [2x-(x+2)] + ... [mx - (x+m)] + ... [(y-x)x - (x-y)] => 
   -1 + [x-2] + ... [(m-1)x - m] + ... [(y-x-1)x - x] =>
   SUM(1..y-x-1)x - SUM(1..x) => (replace y-x = d)
   ([d-1] * d / 2) x - (x*[x+1]/2) => x/2 * (d^2 - y - 1)

this would be number indicating steps away from starting point.
total number of steps fwd and bckwd is (y-x)*2

- Anonymous June 23, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

But y is total number of steps taken. So sum of all these steps equals y . Am i right. So i am not sure whether inclusion of y as the last step is correct ?

- Anonymous June 23, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

can u explain the logic please reply asap.??

- Rahul June 27, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

can i have a code for this?

- Anonymous June 23, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

There is no way this is a question on an assessment test. How can any company expect a person to get this question correct with pen and paper.

- No Way July 09, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

sorry, show return total_steps. However, now I am thinking whether x and y are known or unknowns?

public int glitch_steps (int x, int y) {
int total_steps = 0;
int count = 1;
while (total_steps != y) {
total_steps += (count*x) - (x+count);
count ++;
}
return total_steps;
}

- epic_tester July 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

once again, i think it should return count not y or total_number of steps

public int glitch_steps (int x, int y) {
int total_steps = 0;
int count = 1;
while (total_steps != y) {
total_steps += (count*x) - (x+count);
count ++;
}
return count;
}

- Anonymous July 22, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think this question cant be so simple progression, there will be some catch for degree movement of glitch too.

- Anonymous August 12, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int p=1,i=1,step=0,total=0;
while(total < userinputtotal ){
step += (i*x + x + i);
pos += p*(i*x-x-i);
i++;
if(i > y){
p= -1*p;
total += step;
step = 0;
}
}

- Anonymous September 11, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

correction:

int p=1,i=1,step=0,total=0;
while(total < userinputtotal ){
step += (i*x + x + i);
pos += p*(i*x-x-i);
i++;
if(step > y){
p= -1*p;
total += step;
step = 0;
}
}

- Anonymous September 11, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

<pre lang="" line="1" title="CodeMonkey53967" class="run-this">#include <stdio.h>

int main()
{
int x,y,total,i,j,k,chk,m,n,forward,backward,p,tmp;

printf("Enter value of x: ");
scanf("%d",&x);
printf("Enter value of y: ");
scanf("%d",&y);
printf("Enter total no. of steps to be taken: ");
scanf("%d",&total);

i = 0;
j = 1;
k = 0;
chk = 0;
forward = 0;
backward = 0;

while(i<=total)
{
printf("j=%d\n",j);
i += x*j+x+j;
if(i>total)
{
tmp = i-total;
if(backward == 1)
{
k += -(x*j)+x+j-tmp;
}
else
{
k += x*j-(x+j)+tmp;
}
break;
}
if(backward == 1)
{
k += -(x*j)+x+j;
}
else
{
k += x*j-(x+j);
}
if(i>y && chk==0)
{
i += -(x*j)-x-j;
k += x*j-x-j;
m = x*j;
n = x+j;
for(p=0;p<(m+n);p++)
{
if(p<m && (i+p)<=y)
{
k += 1;
}
if(p>m && (i+p)<=y)
{
k -= 1;
forward = 1;
}
}
if(forward != 1)
{
backward = 1;
}
i = y;
chk = 1;
}
j++;
printf("k=%d\n",k);
printf("i=%d\n",i);
}

printf("The robot is %d steps away from its starting point\n",k);

return 0;

}</pre><pre title="CodeMonkey53967" input="yes">x, y, total number of steps
</pre>

- Anonymous October 18, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

<pre lang="" line="1" title="CodeMonkey14753" class="run-this">public class RobotMove {
public static int x = 0;
public static int y = 0;
public static int steps = 0;
public static int away = 0;
public static String direction = "";
public static void main(String[] args) {
x = 5;
y = 100;
getSteps(1);
System.out.println(away + " " + steps + " " + direction);
steps = 0;
if(direction.equals("front")) {
getStepsBack(1);
}
else {
getSteps(1);
}
System.out.println(away + " " + steps + " " + direction);
}

public static void getStepsBack(int n) {
if(y == 0) return;
if( y >= steps + x*n) {
steps += x*n;
away -= x*n;
} else {
steps += y-steps;
away -= y-steps;
direction = "back";
}
if(y > steps) {
if(y >= steps + x + n) {
steps += x+n;
away += x+n;
}
else {
steps += y-steps;
away += y-steps;
direction = "front";
}
}
if(y > steps){
getStepsBack(n+1);
}
}

public static void getSteps(int n) {
if(y == 0) return;

if( y >= steps + x*n) {
steps += x*n;
away += x*n;
} else {
steps += y-steps;
away += y-steps;
direction = "front";
}
if(y > steps) {
if(y >= steps + x + n) {
steps += x+n;
away -= x+n;
}
else {
steps += y-steps;
away -= y-steps;
direction = "back";
}
}
if(y > steps){
getSteps(n+1);
}
}
}

It seems that many people misunderstand the question..
It has 2 type of moving(start point facing front and facing back)
Steps
1.Move y steps with the rule.
2.turn 180 degree, then move y steps again.
If the Robot facing front after step 1, it will move to start point after step 2.
If the Robot facing back after step 1, it will move to twice more then step 1.</pre><pre title="CodeMonkey14753" input="yes">
</pre>

- SuperK December 09, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

EPIC has some crazy Q&A if it expects such to be answered within an assessment test!

- Anonymous January 14, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

IMHO...

public static void glitchWalk(int x, int y){
		int n = 0;
		int total = 0;
		int distance = 0;
		int externalTrigger = 1;
		int internalTrigger;
		while (externalTrigger > 0){
			++n;
			for(int i=0; i<(x*n+x+n); ++i){
				internalTrigger = 1;
				++total;
				if(total == y){
					externalTrigger = -1;
				}
				if (i == x*n - 1){internalTrigger = -1;}
				distance += externalTrigger*internalTrigger*i;
			}
		}
		System.out.println("# Steps taken: " + total);
		System.out.println("# Distance from origin: " + distance);
	}

- Suz February 23, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

if you dont mind ...could you please explain your logic

- Bugger August 11, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

The number of steps taken forward is x, 2x, 3x...yx. So the total number of steps taken forward is the sum of the first y integers times x, or ((y*(y+1))/2)*x.

The number of steps taken backward is x+1, x+2, x+3...yx + ((y*(y+1))/2), where the second term is, again, the sum of the first y integers.

The total number of steps taken is the sum of these two quantities; the number of steps taken forward is the difference if the first minus the second.

- SixDegrees August 14, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

package glitch;

public class walk {
	public static void counter(int x, int y, int steps){
		int sum=0;
		int side=0;
		int balance =0;
		int distance =0;
		for(int i=1;i<=steps;i++){
			sum += x*i-x-i;
		}
		//sum = (int) (x-1)*steps*(steps+1)/2- x*steps;
		side = sum/y;
		balance = sum%y;
		if(side%2 == 0){
			distance = balance;
		} else {
			distance = y- balance;
		}
		System.out.println(distance);
	
	}
		public static void main(String[] args){
			counter(3,10,8);
		}
}

- Anonymous March 05, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class AAF {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println("Enter x, y and number of steps");
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			int x = Integer.parseInt(br.readLine());
			int y = Integer.parseInt(br.readLine());
			int steps = Integer.parseInt(br.readLine());
			int current = 0;
			while(steps > 0){
				for(int i=1; i<=y; i++){
					steps -= i*x;
					current += i*x;
					steps -= i+x;
					current -= i+x;
					System.out.println("Distance = "+current);
					if(steps <= 0){
						break;
					}
				}
				if(steps <= 0){
					break;
				}
				for(int i=1; i<=y; i++){
					steps -= i*x;
					current -= i*x;
					steps-= i+x;
					current += i+x;
					System.out.println("Distance = "+current);
					if(steps <= 0){
						break;
					}
				}
				
			}
			
			System.out.println("Distance = "+current);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}

}

- rohith.sankarraman September 09, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

what if the robot reaches n steps at the middle of forward or backward steps?

- janicewang03 January 25, 2013 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More