Are the numbers integers? What is the max possible value of the inputs? What is the minimum, can it be negative?
Isaiah Peterson
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.
Cameron White
get input, split into 3 floats a, b, and c
if a
Evan Bell
First I'd like to ask you a question. Which came first, Ranch or Cool Ranch?
Your function may take less or more than 3 numbers.
John Sanders
def min_func(a,b,c): return reduce(lambda x, y: x if x < y else y, [a,b,c])
get on my level
Kevin Lewis
def minthree(a, b, c): return a < b ? a < c ? a : c : b < c ? b : c
Ian Thomas
int min(const int &a, const int &b, const int &c) { if(a
Ryder Wright
This doesn't matter. The function is easy to generalise for any type for which an order exists.
Asher Perez
It isn't in the specification that the function is not allowed to take more or less than 3 arguments.
Leo Robinson
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.
Connor Lewis
return std::min(a, std::min(b,c));
Also, don't pass ints as references. They are just pointers in disguise.
Leo Russell
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.
Kevin Walker
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
Michael Adams
Rejecting invalid input safely is always an implicit part of the spec.
Daniel Martin
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.
Asher Roberts
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?
Landon Jenkins
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.
Colton Moore
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 }
Eli Miller
Define your own min function for 2 parameters and use that
Asher Sanchez
damn manual indentation
Colton Taylor
Use atomics and change sleep to microseconds
Jack Gutierrez
>std::min >without using the built-in min function. I dunno, that's kinda cheating.
Charles Moore
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?
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?
Dominic Brooks
Inb4 no inputs! yah. Just showing algorithm. Phone posting is hard.
Justin Evans
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()