I can't begin to write an answer to a coding interview if the question doesn't make sense

Is this a joke? Are they asking these questions just to screw with people or am I missing something?

I could have solved it if the problem made sense.
Are you given autistic questions like this?

>The function had to be written in Javascript and starts like this...
function Package(small, big, goal) {


}

Attached: Do what?.png (2110x1096, 227K)

Other urls found in this thread:

app.codesignal.com
twitter.com/NSFWRedditGif

Is this a joke or are you trying to get Jow Forums to do this for you?

>Is this a joke or are you trying to get Jow Forums to do this for you?

I already failed as you can see by the time. I just wondered if this question is complete nonsense or I am a moron?

I answered
if (goal - 5) >= 5 {
return goal - 5
} else {
return -1
}

Just because I banged my head against this and thought it was stupid I would like to know what others think of it. Who's absurd? The question or me?

I don't care if it's solved. I said I COULD SOLVE IT IF IT MADE SENSE. Does this question make sense?

Judging by the "answer" you posted and the fact that you even made this thread, I'd say you're probably around room temperature IQ. Not too low so as to be incapable of making a thread on Jow Forums, but not high enough to know better.

It makes perfect sense.

>I'd say you're probably around room temperature IQ.

You'll write to be an asshole but you won't even read the question.
>"Return -1 if it cannot be done"
If what cannot be done?

>"If there isn't enough return -1"
If there isn't enough what? Cookies to use a 5 kilo bag? Bags? Cookies? They didn't give a quantity of bags.

You didn't even look at the question, dickface.

Yes the question makes sense, just return goal % 5

Attached: stackoverflow.jpg (640x640, 76K)

Beat me by 30 seconds

Back in the days people like you worked on the factory floor and had a happy life
Nowadays we have to see this sad display of incompetence
Ted was right

>They didn't give a quantity of bags.
Read. The. Fucking. Question.
>INPUT
>INT SMALL: NUMBER OF SMALL BAGS
>INT BIG: NUMBER OF BIG BAGS
Yes, just ignore the other 2 inputs, retard.

holy fucking brainlet, I hope this isn't a uni course

>They didn't give a quantity of bags.
You don't need to know the quantity to write a program for it. Even a non programmer brainlet like me knows this.

You were supposed to use variables user...

Are you really not capable of doing this?
Why are you even trying then lol.

>failed the question
try actually using the big bag count instead of assuming that you have enough
small bags required = goal%(n big bags * 5)
return (small bags required) failed the english language

US is only country that does this shit. It means nothing at all.

You're just retarded. This is a basic greedy algorithm.

Something like

goal -= big * 5;
if (goal < 0) return 0;
if (goal > small) return -1;
return small;


should solve the problem.

>You don't need to know the quantity to write a program for it
I didn't know what they were talking about.
They're talking about an event where the cookies will only weight exactly 5 kilos or '1' kilo increments above 5?

>failed the english language
I hadn't done any coding questions. I didn't go to college. I build many elaborate projects and pipelines The problems I deal with are typically not riddles and I design the most efficient code to bridge it.

Lmao that code isn't even syntactically correct.

Also JS makes semicolons optional but you should still use them.

I'm typing this on my phone so sorry for the formatting

function Package(small, big, goal){
ayylmao = goal % 5;
if (ayylmaosmall) ? -1:goal;
}

both of these fail on n big bags * 5 > goal

clamp big * 5 to goal - goal%5

They just want you to tell them how many small bags need to be shipped, assuming that you use big bags first. It's just tapping into your remainder knowledge. Pretty basic shit.

>small bags required = goal%(n big bags * 5)
Still wrong.

If goal is 12 and n big bags is 1, this would set small bags required to 2 when it should be 7.

Am I the only employed programmer in this thread?

True.

>You don't need to know the quantity to write a program for it
youre OP right?? and nayrt, but youre fucking stupid
this is basic shit and the question is really easy to understand
maybe you should give the whole... programming thing a miss

>They just want you to tell them how many small bags need to be shipped, assuming that you use big bags first.

So 'if goal

Doesn't work, there might not be enough big bags to fit all of goal.

>youre OP right?? youre fucking stupid

You could have just explained what they were asking for instead of being a dick. Jow Forums are bunch of loser assholes.
It's return goal - 5 else if goal is < 5 return -1?
I can answer a clear question.

Wrote it in C++ and made it ez to read for your puny brain

#include

#define LARGE_SZ 5
#define SMALL_SZ 1

int Package(int small, int big, int goal)
{
const int remainder = goal % LARGE_SZ ;
const int total = (small * SMALL_SZ)
+ (big * LARGE_SZ) ;
if(total >= goal)
return remainder ;
else
return -1 ;
}
int main()
{
std::cout

why is it wrong to just ship 4 small bags with any order over 5 kg?

Are you all retarded?
Check for the big bags, then check the remainder for small bags, then check if they are inside the bounds.
Jesus Christ.

how would that work for 6kg?

doesnt make you not stupid

I’m employed too and the answer according to our protocols is call Rockwell’s support line then fly an engineer to their training facility and have them tell him how it is done. Ship the result directly to customer and leave no documentation whatsoever.

Idiot, what if you have to send 6kg? Or anything that isn't 5*n+4, fucking brainlet.

I'm not even a programmer or CS student and I could solve that.
>goal % 5 = number of small bags
>check if that number

>doesnt make you not stupid
What? You being a depressed rageaholic?
Why'd you respond again without telling me if I got the question clear?

You ship 9kg as computation time is more expensive than 4kg of cookies

Just say they are bonus bags. They are cookies. They don't cost much.

I this has a math error if
goal < (nBigBags * 5). For example 5 % 10 = 5, which would be wrong since you use big bags first
return (goal

which one did u go for OP? :^)

Attached: Zrzut ekranu z 2019-07-24 21-27-46.png (1174x698, 38K)

Who is buying KG of cookies?

I made a mistake, the % should be a /

Amerimutts

:^D

Attached: Screen Shot 2019-07-24 at 21.29.19.png (800x724, 106K)

try Package(10, 1, 12)

>What? You being a depressed rageaholic?
this literally makes no sense as a reply to my statement
and i didnt tell you if you got the question clear because countless other anons have explained it to you and if you STILL dont understand then im just going to double down on what i first said...
youre fucking stupid
making me hungry baka

ugly

function package(small, big, goal)
{
return (goal

Elitist asshole on the internet. I never.

you should still use big bag even if it has more capacity than the goal

just leave

dis nigga doesn't know the % operator
lmfao

and you don't understand the question.

Na this is a fail, what happens if there are two big bags? This function doesn't cut grass.

retard. it's hillarious watching you trying to reverse engineer this simple question from anons' answers

>just leave
You don't understand the question. You just think this thread is an opportunity to pile on someone.

yea i do

his solution doesn't have this problem though

This user is right. Go practice at app.codesignal.com
They have some good basic problems to make you think like a programmer.

Fair. I feel like in a practical sense I would rather use one small bag for 1kg rather than waste a 5kg bag to store that same 1kg if that makes sense.

True but question says 'assuming we always use big bags first'

>yea i do

Then why not just admit it was phrased poorly and add how it should be phrased more clearly with your ad hominems.

The -1 thing is really strange. Why would anyone need to have -1 returned if the cookies are less than 5 kilos?
Just make it use small bags under 5.

"Cookies will be shipped in 5 kilo and 1 kilo bags. Write a function that returns the number of 1 kilos bags unless the amount of cookies is under 5 kilos return -1."

return goal % 5 + (goal - big * 5);

this user seems to have the correct answer
function package(small, big, goal)
{
const weightSmall = 1;
const weightBig = 5;
let smallBagsUsed = 0

while (big > 0 && goal >= weightBig) {
goal -= weightBig;
--big;
}

while (small > 0 && goal >= weightSmall) {
goal -= weightSmall;
--small;
++smallBagsUsed;
}

return !goal ? smallBagsUsed:-1;
}

console.log(package(2,1,17)) // -1
console.log(package(1,3,17)) // -1
console.log(package(12,1,17)) // 12

>They have some good basic problems to make you think like a programmer.

Nobody thinks like the question in the OP

> goal = 17
> big = 3
> goal % 5 + (goal - big * 5)
result = 4

retard

because im not taking this thread seriously

function cookies(small, big, goal) {
var totalkgbig = big * 5;
var totalkg = small + totalkgbig;
var r = goal % 5;
if (r > small || totalkg < goal) return -1;
return r;
}

I won't be leaving my room for anything less than 100k, Mr. Goldberg.

Attached: 1545876345176.jpg (1209x756, 460K)

Better solution

while (goal >= 5 && big > 0) {
big--;
goal -= 5;
}
return goal > small ? -1 : goal;

>I'm sorry Sir, but we only accept one-liners

>because im not taking this thread seriously

Then you're a loser for making this many empty, angry posts in a thread during work hours.

goal-=big*5;
if(goalsmall)
return -1;
else return goal;

you can decrement in the while loop

function package(small, big, goal)
{
const weightSmall = 1,
weightBig = 5;
let smallBagsUsed = 0

while (big-- > 0 && goal >= weightBig)
goal -= weightBig;

while (small-- > 0 && goal >= weightSmall) {
goal -= weightSmall;
++smallBagsUsed;
}

return !goal ? smallBagsUsed : -1;
}

It's night time rn user. Blame everyone else for your deficiency and stay NEET

def package(small, big, goal):
return min(small,goal-5*min(big,goal//5))

right just doing goal - big * 5 is enough

package = lambda small, big, goal: min(small,goal-5*min(big,goal//5))

Wrong.

>you can decrement in the while loop
Ick.

empty? yea
angry? not at all
during work hours? its 10pm here
if youre op? go make a post on r/programming

Attached: 1549472096814.png (1207x587, 122K)

how?

pleb detected

>Blame everyone else for your deficiency
I don't have a deficiency. I'm asking the internet about this question. I'm learning about the autistic language of coding questions.
If you feel making empty insults to strangers asking questions and learning things over the internet gives you power over people you are wrong.

>It's return goal - 5 else if goal is < 5 return -1?
This thread is the gift that keeps on giving.

function foo(int small, int big, int goal) {
if (small+big*5 < goal)
return -1;
return goal % big;
}

Here's your homework, thanks for the laughs.

my code wasn't correct because I forgot about the -1 condition if you don't have enough but whatever

While the more esoteric one liners are impressive, the real world prefers readable well tested code.

>javascript
>declares types in the function signature

don't call us, we'll call you
security please escort this lady out

is Jow Forums always this retarded?

Attached: 1434050937487.gif (640x360, 439K)

I don't touch JS if I can help it, but I assumed it would have static typing.
Anyway I made an error where I assume it can use infinite big bags as long as the sum is larger than the goal, but it's easy to fix.

foo(10, 0, 5) = NaN

> and this gives you power over me?!
Don't feel bad user no one cared who I was untill I put on the mask.

But legit either an elaborate troll or a loiving breathing Dunning-Kruger effect

there's no fucking way this isn't a troll nobody can actually be this stupid

>cookies(12, 1, 17)
>2

hahaha

Issue closed, wontfix.
function foo(var small, var big, var goal) {
if (small+big*5 < goal)
return -1;
if (big)
return goal % (big*5);
return small;
}

If they submit negative integers, it's their fault.

>Technically not in the question
It literally says you will be given an inventory of small and big bags so obviously you have to make sure you have enough big bags.

>var small, var big, var goal
see

It took me forever to understand the question because "small", "big" and "goal" were stylized as parameterized functions and I thought they wanted you to write 3 functions. But it's very ez once you understand the problem

Attached: whirlwindMan.jpg (529x470, 110K)