The Sup Forums Challenge

We all know about FizzBuzz and the facts that:
1. there are more then 1 way to solve it
and
2. it filters out the incompetent
But FizzBuzz isn't perfect.

Please suggest new challenges other than FizzBuzz which would weed out morons like pic related but allow potential experts through. Multiple suggestions in series are accepted.

>inb4 - this is to make everyone on Sup Forums more productive, help us all sharpen our skills, and give me something to do.

Other urls found in this thread:

en.wikipedia.org/wiki/Cycle_detection#Floyd.27s_Tortoise_and_Hare
css-tricks.com/tales-of-a-non-unicorn-a-story-about-the-trouble-with-job-titles-and-descriptions/
github.com/ashaindlin
twitter.com/NSFWRedditGif

FizzBuzz without modulo.

Woah dude then i would have to divide and use an operator

Not with a reimplementation of modulo, idiot. You've failed for not understanding the problem.

Print the first 25 palindromic primes.

Very easy, but in an interview scenario 95% would fail.

>divide
it's like you want to be a noob
i multiply the fuck out of it

are you telling me that convenience is a less professional word than sanity?

Well it's your fault for not making thay clear.

What about something that checks for leap years? It certainly would be on the same level of FizzBuzz and has as well a few ways how to approach the problems.

Neet.
Mind pseudo-coding it to show that is possible and not imaginary?

>without modulo
Seems pretty clear. Implementing modulo is still using modulo.

Roman to Decimal function. The other way around is really straight forward, but here you have to consider the subtraction rule

There simplest way is to use multiple counters and resetting them at 3, 5, and 15. It's possible with fewer, though.

Nah, its not. Dont use % means no %'s in code. If you dont want people to % or / then say no % or /

I didn't say "without percent signs," you thick skulled fool.

Sieve of Eratosthenes
Recursive Fibonacci
Reverse a binary tree
Implement a (doubly)Linked list

Recursive anything, and then "how would you convert this to an iterative approach?"

Retarded idea

Retarded post

Recursive string palindromicity test.

8 queens
15 puzzle Solver.

When it comes to a more mathematical problem: How about writing a function that calculates the determinant of a (n,n) matrix. Great example to use recursion here.

Thats the mod operator

>fizzbuzz
>more than one way to solve it
Wrong.

Care to enlighten us to your line of reasoning?

It's useless to try to challenge Sup Forums at anything harder than fizzbuzz. Every time I try, I get almost zero replies and get accused of trying to ask for homework help. A recent code challenge on Sup Forums was to see if two strings were anagrams, a one-liner in most high level languages. And yet, many people in the thread still got it wrong.

The only reason fizzbuzz is popular on Sup Forums is because it's incredibly simple and it lets morons who solve it feel superior to the even more moronic who can't even do that.

We had a couple of great threads about evolving images the other day.

>he doesn't know what a circular lookup table is

A 15 element circular linked list containing precomputed values for 1-15 that is then iterated through.
However trivial this problem to solve, the problem is that I've been noticing that even if I'm able to solve these questions in interviews I still get rejected without explanation. Looks like I'm going to be a NEET forever, what a shame.

Am I missing something, is there some secret convoluted neckbeard method that you're supposed to use for this or is the "99% of programmers fail" just a meme

>"but i can write fizzybuzzy in a meme way... i dont even use modulus sir... please sirr.... i learnet this in mumbai school of computers science sir...."

> However trivial this problem to solve, the problem is that I've been noticing that even if I'm able to solve these questions in interviews I still get rejected without explanation. Looks like I'm going to be a NEET forever, what a shame

How are your social skills?

>i < 100
Whoops, pretend that's

>he has branching
main(){
for (char i=0;++i

Umm, I'm one of those people who think stupid (read: white, cis, or straight) people should be eaten alive. Does this qualify me as being social?

Holy Shit. Did they reject the PR? I would reject that so hard.

>Please suggest new challenges other than FizzBuzz which would weed out morons like pic related but allow potential experts through.
For this it is better to ask character questions, for example "what is the difference between a computer and a human being". If they can't answer accurately then you know there is a problem with them

No, beside maybe using a Stringbuilder, this is the optimal solution for FizzBuzz.

A lot of people just did 4 cases (Fizz, Buzz, FizzBuzz, number) checking both modulo in various combinations though, which is the rather naive approach to it

We need more challenges like that. That was a fun problem to solve

Do you think this comes across during the interview process?

This is a pretty good one because it lends itself so nicely to recursion, and would be annoying to do without it.

I don't think this is a question of how professional the words are.

They have different meanings in a lot of cases. I don't really know what the context of this code is, but it could very well be the case that sanity is the more applicable descriptor.

I try to hide it and pretend to be normal as much as I can

Fizzbuzz but with 0 and INF instead of 3 and 5

Compute and sum the primes under 2 million.

Trying to imply that having things laid out in a sane way is merely convenient is a rather absolutely, isn't it?

>absolutely
*abhorrent

The issue is that most people don't know about leap year rules other than divisible by 4.

The good questions are normally posted on /sci/ where you have lurking math,physics and engineering, and competent cs students instead of Sup Forums try there.

triple ref pointers? I'll just kill myself right now, thanks.

Just check if it's divisible by 3

Full disclosure: I would only be able to solve this through gaussian elimination if i didn't have access to google.

Brainlet here, can someone explain this for me?

Have you tried asking them why you're rejected?

>which would weed out morons like pic related
I mean, yeah the commit is stupid but she is anything but a moron.

I would like to remove Appleish language.

No more "APP" "APP" "APP" "APP" !

that's still easily reachable. Just for filling a 2d array via function you already need to use ***

Coding challenges in interviews are useless if you search more than a code shitting monkey.

The problem is that it needs to trickle down. You just can't introduce another programming problem to Sup Forums and have them interested in it. The average Sup Forums-tard is a illiterate coder at most. Meaning he's dabbling in his chosen language which is mostly python or javascript or pajeet tier. Introducing another problem makes all their known routines of fizzbuzz obsolete. They need to lurk more first in order to get at this problem. So you need to provide solutions yourself to feed them. You need to do this in probably 100 threads a month so that you get enough attention from the average faggots here and having them spoonfed enought since they sure as hell wouldn't have been able to wipe their ass without assistance. Never forget most posters here are the bottom of the barrel, sweetie

% is modulus. Basically divide 2 numbers and the remainder is returned.

So 9 % 3 would be 0, 10 % 3 would be 1. Since we want to see if the number is divisible by 3 or 5 we just check to see if the remainder is 0.

solving problems has nothing to do with being able to "code". you could write it out in psuedocode if you want.
if u think syntax is hard ur fuckin gay and dum.

I'm talking about illiterate people nigger. Every combination of tasks exponentially rises the complexity of problems if you don't know what you're doing. If you fail read and comprehend you should just fuck off

t. retard

I've got a decent test.

You have a singly linked list. You are unaware if it is linear or circular. All you have is a pointer to an element in the list. Each node in the list looks like this:

typedef struct node{
int value;
node* next;
} node;


Devise a way to determine whether the list is linear or circular.

The algorithm is rather simple though with the Laplace expansion.
It's basically just the sum of all values (1, x) * the absolute value of it's Minor (determinant of the sub-matrix without the first row and the column x). Cascade that down to a (3,3) matrix and do Sarrus.
Or you do it down to a 2x2 and do a11*a22-a12*a21

Knight's tour.

Will that even compile when you specify "node" twice?

So why not work for safe space faggots at Mozilla?

>Recursive Fibonacci
>not just
>nth Fibonacci number
>and asking for a number close to buffer overflow

That you're retarded was obvious but thanks for clearing that up

The naive approach would be to keep a pointer to where you started, and traverse until you get to the end (ostensibly null) or where you started (by simple comparison).

This is a classic problem, people will have the solution memorized

More interesting is if the list can have a linear first section, then terminate in a cycle, because you may never return to your head node. In that case, you have to store everywhere you've been as you check.

An interesting one I was asked is to populate an m*n table with numbers in a spiral.
E.g.
1 2 3 4 5
12 13 14 15 6
11 10 9 8 7

Wow, so fucking hard

function mod(x,d)
while x>=d do
x = x-d
end
return x
end

Here's your homework
private static bool CheckAnagram(string word1, string word2)
{
var word1Array = word1.ToCharArray();
var word2Array = word2.ToCharArray();
Array.Sort(word1Array);
Array.Sort(word2Array);

var loopLength = word1Array.Length < word2Array.Length ? word1Array.Length : word2Array.Length;

var word1Pos = 0;
var word2Pos = 0;

while (word1Array[word1Pos] == ' ')
{
word1Pos++;
}
while (word2Array[word2Pos] == ' ')
{
word2Pos++;
}

for (var x = 0; x < loopLength; ++x)
{
if (word1Pos >= word1Array.Length
|| word2Pos >= word2Array.Length
|| word1Array[word1Pos] != word2Array[word2Pos])
return false;
word1Pos++; word2Pos++;
}
return true;
}

I actually like this. Similar to FizzBuzz, it's testing your grasp of basic control flow more than anything math related, and yet most people would still fail it.

implementing modulo yourself doesn't satisfy the prompt: you're still using modulo. Try something more creative.

Really your only options are re-implementing modulo or using a look up table. Really obtuse re-implementations of modulo inside your main loop are still re-implementations of modulo.

It's a pretty stupid problem.

Just ask them to solve a fucking pixel maze with where squares are 2d boolean-arrays with DFS or BFS.

There you go.

This

Also bubblesort on the whiteboard

Iterative Fibbonaci anyone?

>Absolute unreadable mess.
I wouldn't hire you for sure. Enjoy being a 1337 h4xx0r and poverty.

#include
#include
#include
#include
#include
#include
#include

std::string exec(const char* cmd) {
std::array buffer;
std::string result;
std::shared_ptr pipe(popen(cmd, "r"), pclose);
if (!pipe) throw std::runtime_error("popen() failed!");
while (!feof(pipe.get())) {
if (fgets(buffer.data(), 128, pipe.get()) != nullptr)
result += buffer.data();
}
return result;
}

int64_t totalMemorySize()
{
std::stringstream ss;
ss result;
return result;
}

struct node{
int value;
node* next;
};


bool isListLinear(node* xnode)
{
int64_t memSize = totalMemorySize();
int64_t checkedBytes = 0;
while (checkedBytes < memSize - sizeof(node)){
if (!xnode->next){
return true;
}
checkedBytes += sizeof(node);
xnode = xnode->next;
}
return false;
}

int main(){
node linearNode;
linearNode.next = NULL;
node circularNode;
circularNode.next = new node;
circularNode.next->next = &circularNode;
std::cout

One is "struct node" which is typedef'd to "node"

For my interview I had to implement an averaging digital filter for a signal. They got me to read in a CSV file full of data and write out the filtered example. They checked it by using excel to graph the data :^)

Might be too much for a basic code monkey job, but it shows that you know how to read / write files, needing a loop in a loop for the filtering and that basic bounds checking.

Seen this question before, an there's a really nice solution which works for a linear section before a loop as well. The name is great too, Tortoise and Hare, and the implementation can be explained simply.

Iterate through the list with two pointers, but one moves 2 steps each time (the hare). If the tortoise and hare pointers ever meet, then there is a cycle.

en.wikipedia.org/wiki/Cycle_detection#Floyd.27s_Tortoise_and_Hare

Yes, but unless you took a linear algebra exam yesterday you're probably not going to remember the exact operations of that algorithm, making it unsuitable for a coding test that doesn't allow google.

Well I just wrote it down, and I took that exam 2 years ago

>Assembly FizzBuzz
>x86 instruction set
>1 hour

That might actually be a decent challenge if you allow google and know the candidate hasn't done assembly before.

Fizzbuzz is trivial enough that it's not impossible to complete, but the challenge is still hard enough that you can set the bar at various places depending on what kind of candidate you're looking for. You'll get to see how they cope with a difficult problem and how they research things they don't know, and how they can adapt to completely unfamiliar contexts.

Who would actually use this as a hiring metric? We give candidates a complex take home assignment that requires basic recursion skills and graph traversal.

Add two arrays of int of different lengths together.

Read it and weep:
css-tricks.com/tales-of-a-non-unicorn-a-story-about-the-trouble-with-job-titles-and-descriptions/

Be more specific. Do you mean sum the values of the two arrays, stopping once you've reached the end of one array?

I once remember Falcon saying he was able to weed out a lot of idiots just by asking them to count down from like... 700 to 200 in decrements of 13.

>Please suggest new challenges other
>than FizzBuzz which would weed out morons like pic related but allow potential experts through.
Just ask them to write a recursive function that can only be solved through recursion. This is a trick question, of course; but without basic math/programming knowledge you'll have them there wasting time like morons.

For example;

Input

int[] a = {3, 6, 2};
int[] b = {4, 2, 5, 3, 1};

Output

{7, 8, 7, 3, 1}

What you say is "without modulo" but what you mean is "without math operands" seeing you shoot down anything that uses math to work it out.

fibonacci sequence using tail recursion

I found this snowflake's git profile.
github.com/ashaindlin