[Show all top banners]

donald_duck
Replies to this thread:

More by donald_duck
What people are reading
Subscribers
:: Subscribe
Back to: Computer/IT Refresh page to view new replies
 Any programmer geeks to help?
[VIEWED 15659 TIMES]
SAVE! for ease of future access.
Posted on 04-15-14 8:45 AM     Reply [Subscribe]
Login in to Rate this Post:     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

 
Posted on 04-15-14 8:56 AM     [Snapshot: 18]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

post it. sajha is full of programmers.
I ain't the one though. :)
 
Posted on 04-15-14 9:31 AM     [Snapshot: 42]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

My God, nobody?

 
Posted on 04-15-14 10:16 AM     [Snapshot: 81]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Have you heard of Cunningham's Law ?

You probably might try a different approach and will be surprised by the result.
 
Posted on 04-15-14 10:20 AM     [Snapshot: 90]     Reply [Subscribe]
Login in to Rate this Post:     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;.
 
Posted on 04-15-14 10:32 AM     [Snapshot: 105]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

प्रश्नै नगरी उत्तर खोज्ने हरु नि हुदो रहेछ | क्या गजब छ बा |
 
Posted on 04-15-14 11:02 AM     [Snapshot: 145]     Reply [Subscribe]
Login in to Rate this Post:     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

 
Posted on 05-01-14 2:17 PM     [Snapshot: 441]     Reply [Subscribe]
Login in to Rate this Post:     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

 
Posted on 05-01-14 6:28 PM     [Snapshot: 580]     Reply [Subscribe]
Login in to Rate this Post:     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;
}

}


 
Posted on 05-01-14 6:48 PM     [Snapshot: 614]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

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

यसको जवाफ मेरो विचार मा १० हुन्छ |
 
Posted on 05-02-14 11:14 AM     [Snapshot: 766]     Reply [Subscribe]
Login in to Rate this Post:     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++;
}
}

 
Posted on 05-02-14 1:06 PM     [Snapshot: 827]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

totalCarWaitingForRepair%8; fails when there are more than 16 cars.
 
Posted on 05-02-14 1:11 PM     [Snapshot: 828]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

sorry 15.
I didnt check other lines but that line should be

remainingCar = (totalCarWaitingForRepair-8)<0?0:(totalCarWaitingForRepair-8);
 
Posted on 05-02-14 7:27 PM     [Snapshot: 911]     Reply [Subscribe]
Login in to Rate this Post:     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.
 
Posted on 05-02-14 7:27 PM     [Snapshot: 911]     Reply [Subscribe]
Login in to Rate this Post:     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.
 
Posted on 05-02-14 7:27 PM     [Snapshot: 911]     Reply [Subscribe]
Login in to Rate this Post:     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.
 
Posted on 05-02-14 7:27 PM     [Snapshot: 911]     Reply [Subscribe]
Login in to Rate this Post:     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.
 
Posted on 05-02-14 7:27 PM     [Snapshot: 911]     Reply [Subscribe]
Login in to Rate this Post:     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.
 
Posted on 05-02-14 7:30 PM     [Snapshot: 912]     Reply [Subscribe]
Login in to Rate this Post:     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.
 
Posted on 05-27-14 4:11 PM     [Snapshot: 1577]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

cant figure out until u paste the code..
 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 30 days
Recommended Popular Threads Controvertial Threads
TPS Re-registration case still pending ..
and it begins - on Day 1 Trump will begin operations to deport millions of undocumented immigrants
From Trump “I will revoke TPS, and deport them back to their country.”
ढ्याउ गर्दा दसैँको खसी गनाउच
To Sajha admin
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters