Jow Forums Interview

Hi user,

We’d like to take the next step in our interview process - our code challenge.

Please answer the following question to the best of your ability, and keep in mind the test is more for code quality than speed.


Q) Implement a method that takes 3 numbers as input and finds the minimum of the three without using the built-
in min function.

Attached: download.jpg (286x176, 8K)

Other urls found in this thread:

pastebin.com/vjQPXEW6
twitter.com/NSFWRedditImage

def min(*args):
args = sorted(args)
return args[0]

public class FactoryBuilderArrayFactoryBuilder extends BuilderFactoryBuilder {
// shit nigga fuck java
}

>the built-in min function.
Oh, sorry, I didn't know this was a Python interview. Good bye.

>he doesn't have the most basic utilities built-in to his programming language of choice

What a poorfag

>dilbert

Attached: 1518665689193.png (657x539, 110K)

Are the numbers integers? What is the max possible value of the inputs? What is the minimum, can it be negative?

Thank you for giving us the opportunity to consider you for employment. We have reviewed your background and qualifications and find that we do not have an appropriate position for you at this time. We appreciate your interest and wish you success in your job search.

get input, split into 3 floats a, b, and c

if a

First I'd like to ask you a question. Which came first, Ranch or Cool Ranch?

Attached: 1503415092247.png (320x240, 79K)

Your function may take less or more than 3 numbers.

def min_func(a,b,c):
return reduce(lambda x, y: x if x < y else y, [a,b,c])


get on my level

def minthree(a, b, c):
return a < b ? a < c ? a : c : b < c ? b : c

int min(const int &a, const int &b, const int &c)
{
if(a

This doesn't matter. The function is easy to generalise for any type for which an order exists.

It isn't in the specification that the function is not allowed to take more or less than 3 arguments.

Implement a highly generalised pure function that operates on any ordered type with any number of inputs then also implement a specialised three input function constrained to numeric types. Shit ain't hard.

Ps your array param version fails at runtime for empty array inputs. Would not hire.

return std::min(a, std::min(b,c));

Also, don't pass ints as references. They are just pointers in disguise.

See the (12) next to my post? It's not my function.

The function works for 3 args which is a requirement. Working with 0 args is not.

>Would not hire.
Of course you're not. You're not in position to hire anyone in the first place.

int min(int a, int b, int c)
{
bool foundMin = false;
int min;

std::thread ta([&min, &foundMin, a](){
std::this_thread::sleep_for(std::chrono::milliseconds(a));
if (!foundMin)
min = a;
foundMin = true;
});
std::thread tb([&min, &foundMin, b](){
std::this_thread::sleep_for(std::chrono::milliseconds(b));
if (!foundMin)
min = b;
foundMin = true;
});
std::thread tc([&min, &foundMin, c](){
std::this_thread::sleep_for(std::chrono::milliseconds(c));
if (!foundMin)
min = c;
foundMin = true;
});
ta.join();
tb.join();
tc.join();

return min;
}

May not work for numbers close together

Rejecting invalid input safely is always an implicit part of the spec.

It never is. Specifications always explicitly specify what should happen. If yours doesn't, it's your fault for doing a sloppy job writing it.

That's what const keyword is for, if you'd try to modify those ints, your compiler will scream about illegal operation. So why allocate any new memory beyond function call stack?

No new memory is not going to be allocated, those ints would be placed in stack, same as addresses if you use references. In fact, on a 64 bit system, non-reference version will take less memory on stack because ints are commonly 32 bit (at least in GCC and Microsoft's compilers for x64) and pointers 64 bit.

doesn't python need math?

type nums {
[3]int{}
}
//it's a ~~~method~~~
func (nums n) min int themin {
m := n[0]
n1 := n[1]
n2 := n[2]
switch {
n1 < m:
n[0] = n1
n[1] = m
m = n.min()
n2 < m:
n[0] = n2
n[1] = m
m = n.min()
default:
return m

return m
}

Define your own min function for 2 parameters and use that

damn manual indentation

Use atomics and change sleep to microseconds

>std::min
>without using the built-in min function.
I dunno, that's kinda cheating.

I'm in my fourth CS class in college for CS and I could do this, for a second it made me feel good about myself but then I realized this was way too easy and it gets much harder doesn't it. Now i'm depressed what the hell guys. Is this really the kind of stuff they ask you?

Attached: tumblr_onxkyoloha1w05w8zo1_500.gif (426x318, 816K)

It's possible that some places use this as a filter question to weed out people who just apply without any programming knowledge.

I'm not doing your homework for you faggot, do it yourself.

Makes sense. Funny how people apply with no programming knowledge. I wouldnt have the balls to do that

OP here

This was one of the 7 questions I got part of a take-home assessment at the beginning stage of a software engineer interview.

Do your own homework.

>take-home assessment

post the rest, dude

>pass user since

Attached: pepe.jpg (227x222, 9K)

pastebin.com/vjQPXEW6
yw

>tfw error: field too long

Hi. My solution-

List numbs =new ArrayList;
numbs.add(1);
numbs.add(2);
numbs.add(3);
numbs.remove(Collections.max(numbs));
numbs.remove(Collections.max(numbs));
System.out.println(numbs.get(0));
when can I start?

Inb4 no inputs!
yah. Just showing algorithm. Phone posting is hard.

Here you go. When can I get started?

import subprocess
import unittest


class Sorterizer(object):
def __init__(self):
pass

def sort(self, n, m, k):
input_ = ('\n'.join(str(x) for x in [n, m, k])).encode('utf-8')
output = subprocess.check_output(["sort", "-n"], input=input_)
minimum = int(output.decode('utf-8').split('\n')[0])
return minimum


class TestSorterizer(unittest.TestCase):
def setUp(self):
self.s = Sorterizer()

def test_first(self):
self.assertEqual(self.s.sort(-1, 99, 5), -1)

def test_second(self):
self.assertEqual(self.s.sort(99, -1, 5), -1)

def test_third(self):
self.assertEqual(self.s.sort(99, 5, -1), -1)


if __name__ == '__main__':
unittest.main()

template
T min(T1 num) constexpr { return num; }

template
T min(T1 num1, T2 num2, Targs... targs) constexpr {
return (static_cast(num1)

foo

; min3 - takes 3 numbers, passed on stack, finds the minimum
; result is also passed on stack

min3: pla ; pull low byte of return address
sta retl
pla
sta reth
pla ; pull C from stack
sta res ; save C into res

pla ; pull B from stack
cmp res ; compare B and C
bpl bltc ; branch if B > C
sta res ; if C is smaller, save it to res

bltc: pla ; pull A from stack
cmp res ; compare A and whatever is in res
bpl ret ; branch if A > res
sta res ; otherwise save A to res

ret: lda res ; load res
pha ; save result to stack
lda reth ; restore return address
pha
lda retl
pha
rts ; return from function