Any programmer geeks to help? - Sajha Mobile
SAJHA MOBILE
Any programmer geeks to help?
Posts 20 · Viewed 14412 · Go to Last Post
donald_duck
· Snapshot 0
Like · Likedby · 0
Any geek programmer around here to help. Either in java or C#?
Will post the problem statement if any programmer responds to the thread. This is a take home interview question.
Last edited: 15-Apr-14 08:53 AM
sojoketo
· Snapshot 18
Like · Liked by · 0
post it. sajha is full of programmers.
I ain't the one though. :)
donald_duck
· Snapshot 42
Like · Liked by · 0
My God, nobody?
vasudev
· Snapshot 81
Like · Liked by · 0
Have you heard of Cunningham's Law ?

You probably might try a different approach and will be surprised by the result.
Kiddo
· Snapshot 90
Like · Liked by · 0
YOu are asking as if you are doing us a favor. Do you plan to be a programmer when you graduate? If the answer is yes, then you should do it yourself. If no, then post the question, somebody might help;.
bittertruth
· Snapshot 105
Like · Liked by · 0
प्रश्नै नगरी उत्तर खोज्ने हरु नि हुदो रहेछ | क्या गजब छ बा |
donald_duck
· Snapshot 145
Like · Liked by · 0
I am in software development profession for quite a while.
When I interview programmers I give this question as a part of screening. It might be helpful to new programmers who are seeking placement. Thanks for good thoughts.

Here you go.
When a car breaks, it is sent to the car repair shop, which is capable of repairing at most CountPerDay cars per day. Given a record of the number of cars that arrive at the shop each morning, your task is to determine how many days the shop must operate to repair all the cars, not counting any days the shop spends entirely workless.

For example, suppose the shop is capable of repairing at most 8 cars per day, and over a stretch of 5 days, it receives 10, 0, 0, 4, and 20 cars, respectively. The shop would operate on days 1 and 2, sit idle on day 3, and operate again on days 4 through 7. In total, the shop would operate for 6 days to repair all the cars.

Write a class CarRepairs containing a method GetDays that takes a sequence of In-coming counts InComing(of type int[]) and an int CountPerDay, and calculates the number of days of operation.

Definition
Class: CarRepairs
Method: GetDays
Parameters: int[], int

Method signature: int GetDays (int[] InComing, int CountPerDay )
Returns: int

Conditions:
-InComing contains between 1 and 20 elements, inclusive.
-Each element of InComing is between 0 and 100, inclusive.
-CountPerDay is between 1 and 50, inclusive.
 
Last edited: 15-Apr-14 11:04 AM
sojoketo
· Snapshot 441
Like · Liked by · 0
oiee Nas(ey), tero jagir khatrama xa hai keta. :)

foreach (var car in InComing)
{
numOfCars += car;
}
--------------------------------

analysis as according to your soln:

int[] incoming = { 10, 0, 0, 4, 20 };

numOfCars = 34;

numOfCars/countPerDay = Math.Ceiling will give you 5

but actual answer should be 6.
:)
plz redo it without dreaming about priyanka  and re-post it.
That'st your assignment.  :)
Last edited: 01-May-14 02:24 PM
Last edited: 01-May-14 02:25 PM
gairamailo
· Snapshot 580
Like · Liked by · 0
I hope I understood the reqs coz I am very bad at that. Tested with few sample inputs and seems to be fine.

public class CarRepairs {

public static void main(String[] args) {
CarRepairs theRepairs = new CarRepairs();

int theDays = theRepairs.GetDays(new int[]{10,0,0,4,20} , 8);
System.out.println("10,0,0,4,20 With 8 Cars/day.This should take 6 days :" +theDays);

theDays = theRepairs.GetDays(new int[]{17,0,0,5,13,8,10,12,4} , 8);
System.out.println("17,0,0,5,13,8,10,12,4 With 8 Cars/day.This should take 10 days :" +theDays);

theDays = theRepairs.GetDays(new int[]{5,5,1,0,0,4} , 3);
System.out.println("5,5,1,0,0,4 With 3 Cars/day.This should take 6 days :" +theDays);



}

int GetDays (int[] InComing, int CountPerDay )
{
if(CountPerDay == 0)
return 0;
int lagneDin = 0 ;
int baakiRahekoGadi = 0;
for(int numOfCarsPerDay : InComing)
{
int totalCarsToWork = numOfCarsPerDay+baakiRahekoGadi;
System.out.println("Ajako car "+numOfCarsPerDay);
System.out.println("Baaki raheko gadi "+baakiRahekoGadi);
baakiRahekoGadi = 0;
System.out.println("Totals Car to work "+totalCarsToWork);
System.out.println("------------------------ ");
if(totalCarsToWork != 0)
{

if(totalCarsToWork < CountPerDay)
{
++lagneDin;
baakiRahekoGadi = 0 ;
}
else
{
int carsSetPerDay = totalCarsToWork / CountPerDay;
lagneDin+= carsSetPerDay;
baakiRahekoGadi += (totalCarsToWork % CountPerDay);
}
}


System.out.println("Lagne din "+lagneDin);
System.out.println("---------");
}
int additionalDays = 0;
System.out.println("Last ma baki "+baakiRahekoGadi);
if(baakiRahekoGadi > 0)
additionalDays = baakiRahekoGadi / CountPerDay;
lagneDin += additionalDays;
if(baakiRahekoGadi%CountPerDay > 0)
++lagneDin;

return lagneDin;
}

}

gairamailo
· Snapshot 614
Like · Liked by · 0
नाश ब्रो ले त सबै आएको कार जोडेर भाग मात्र गर्या छ त कोडमा | यान्सर औछ त ? येत्ति सिम्प्ल त हुन नपर्ने सोलुशन | अनि के के सिलिङ्ग फिलिंग लगाछ | सिलिङ्गमा त पंखा पो झुण्ड्याउनु पर्छ |
ल यो इन्पुटले के दिन्छ त्यो कोड मा : १७,०,०,५,१३,८,१०,१२,४ . दिनमा ८ ओटाको दरले |

यसको जवाफ मेरो विचार मा १० हुन्छ |
Shere
· Snapshot 766
Like · Liked by · 0
I've a solution here. Just a skeleton code for business logic portion not the whole code.
Please advise a condition where and when this won't work. I'll try to modify the code accordingly. But for the scenario dd has posted, this should work like a charm.

int remainingCar = 0
int day = 0;
int i = 0;
for(int car: carArr) {
i++;
totalCarWaitingForRepair = car + remainingCar;
if(totalCarWaitingForRepair >= 8) {
day += totalCarWaitingForRepair/8;
remainingCar = totalCarWaitingForRepair%8;
}
else if (totalCarWaitingForRepair > 0) {
day++;
remainingCar = 0;
}
if(i == carArr.size() && remainingCar > 0) {
day++;
}
}
KaliKoPoi
· Snapshot 827
Like · Liked by · 0
totalCarWaitingForRepair%8; fails when there are more than 16 cars.
KaliKoPoi
· Snapshot 828
Like · Liked by · 0
sorry 15.
I didnt check other lines but that line should be

remainingCar = (totalCarWaitingForRepair-8)<0?0:(totalCarWaitingForRepair-8);
Shere
· Snapshot 911
Like · Liked by · 0
Why should it fail when there are more than 15 cars. At that time, day will come as more than 1. So when there are 19 cars, day will be 2 and remaining car will be 3.
Shere
· Snapshot 911
Like · Liked by · 0
Why should it fail when there are more than 15 cars. At that time, day will come as more than 1. So when there are 19 cars, day will be 2 and remaining car will be 3.
Shere
· Snapshot 911
Like · Liked by · 0
Why should it fail when there are more than 15 cars. At that time, day will come as more than 1. So when there are 19 cars, day will be 2 and remaining car will be 3.
Shere
· Snapshot 911
Like · Liked by · 0
Why should it fail when there are more than 15 cars. At that time, day will come as more than 1. So when there are 19 cars, day will be 2 and remaining car will be 3.
Shere
· Snapshot 911
Like · Liked by · 0
Why should it fail when there are more than 15 cars. At that time, day will come as more than 1. So when there are 19 cars, day will be 2 and remaining car will be 3.
Shere
· Snapshot 912
Like · Liked by · 0
Sorry guys. Hit submit multiple times thinking that the button didn't work. So are there multiple entries. Coudn't delete the duplicates from mobile version.
helpjava11
· Snapshot 1577
Like · Liked by · 0
cant figure out until u paste the code..
Please log in to reply to this post

You can also log in using your Facebook
View in Desktop
What people are reading
You might like these other discussions...
· Posts 12 · Viewed 1548
· Posts 1 · Viewed 63
· Posts 1 · Viewed 62
· Posts 1 · Viewed 110
· Posts 1 · Viewed 85
· Posts 2 · Viewed 365
· Posts 5 · Viewed 1308
· Posts 1 · Viewed 416
· Posts 1 · Viewed 107
· Posts 1 · Viewed 100



Your Banner Here
Travel Partners
Travel House Nepal