Half of the vir/g/ins can't give an O(1) iterative implementation of this function

>half of the vir/g/ins can't give an O(1) iterative implementation of this function
jesus chirst why are you even here?

Attached: g.png (983x187, 26K)

>math

So you can only be a programmer/CS guy to post here? nice gatekeeping

who the fuck says gatekeeping?

Put this in a notation I understand and I'll do it.

let m = n => Math.max(91, n - 10)

Did you read the OP?

Create a lookup table for n in {0,1,2,...,100}. The cases for n>100 only need one operation anyway.

tfw the problem is actually simple and lineal, and people aren't saying this and instead bitching arround.

doesn't have anything to do with my question.

>Create a lookup table for n in {0,1,2,...,100}
What are you going to do about (-Infinity, -1]?
Also you should go ahead and create that lookup table. maybe it would make you realize why you don't need to.

Uh, okay. That's where the gatekeeping is, however.

Show us a solution then.

There's already one in the thread

I'm asking what kind of person says gatekeeping nowadays retard

This is correct This problem is just fucking braindead, it's made to waste your time trying to figure out that it always outputs 91 for values

Those aren't natural numbers.
n is only used for naturals unless explicitly declared otherwise.

He can't because it's his homework assignment.

Dude please, just solve the problem, is not actually recursive, just a couple of sums.

>A couple
as in 0

Also OP you are a gigantic faggot, fuck off

Relevant how? This is an anonymous imageboard. Or would you rather like it to be muh sekret club?

no, you said:
>who the fuck says gatekeeping?
I don't see "nowadays retard" anywhere.

how do you not understand a piecewise defined function lmao

what are you even talking about
I'm just asking because I've never heard anyone say "gatekeeping" ever.

JESUS FUCKING CHRIST THIS IS JUST AN INTERESTING PROBLEM YOU COULD THINK ABOUT IF YOU HAVE FREE TIME, AND THE OP MESSAGE IS JUST INTENTIONALLY PROVOCATIVE TO STIMULATE YOU.

90

>O(1)
>Iterative

Even the most primitive recursive implementation is in O(1) namely
(define (M n)
(if (> n 100)
(- n 10)
(M (M (+ n 11)))))

That is because the number of operations is bounded by the worse case which is M(0).
Prove me wrong.

it's not a waste of time because it's not quite obvious WHY it always outputs 91 if n

Jesus christ why is everyone in this thread such a spastic retard

We are way out of the Jow Forumsolden age

>you need to be a fucking mathematician to talk about computers

OP is a faggot

Go back to arguing about Nvidia vs AMD

int M(int n) {
if (n == 10)
return n - 10;
else
return M(M(n + 11));
}

All you have to do is try one test case (doesn't even matter which number) to realize that this will go up and stop at 91 for all n Scheme
My nigga

M(-1)

>go back to doing what Jow Forums is designed for, talking about technology
OK

to avoid this

it has fairly recently became a hot new meme word on reddit, whenever somebody is trying to uphold some kind of a standard you call him a gatekeeping elitist and post him on Jow Forumsgatekeeping

please stop

t. never took a Course About algorithm design/Analysis

Without even saying it, it's OBVIOUS that n is a natural number

nope. even for n < 0 the result is interesting

fuck off spacenigger we're full

I haven't learned it, or I learned it so long ago I forgot it.
Should I (re)learn it? Will it be useful to me outside of this thread?

Made a stupid mistake in the if statement.

The notation is quite self-explanatory. Just think.

it's just a notation user
it means:
function M(n)
{
if(n > 100)
return n - 10;
else
return M(M(n + 11));
}

Many algorithms are only provided in mathematical notation. That being said, the function in the OP reads almost like source code.

>not using ternary notation
(n > 100) ? return ( n - 10) : return M(M(n + 11));

It's called a conditional expression.

>>not using ternary notation
why? so that the user who asked would have lower chances to understand?

>lower chances to understand
if you can read your own name, you can understand would ( n > 100) ? should mean even with almost no programming experience.

>(n > 100) ? return ( n - 10) : return M(M(n + 11));
>not return (n > 100) ? (n - 10) : M(M(n + 11));

m(N, K) :- N > 100, K is N - 10, !.
m(N, 91).

There's no reason to ever use a ternary, it fucks with readability and has wonky precedence.

I'm not a virgin and still can't do this.
Not a programmer either

>pedantic

> it fucks with readability
literally how? It compresses a 3-4 line if else statement into one line, as if that's not the definition of making something more readable?

>It compresses a 3-4 line if else statement into one line, as if that's not the definition of making something more readable?
What kind of fucking retard-land do you live in?

>literally how?
>It compresses a 3-4 line if else statement into one line
exactly, pic related is 160 lines into 23 lines, does it look any readable to you? let me know what you think it does if it's so readable

Attached: file.png (721x405, 40K)

>that picture
you're showing something which is a cherry picked picture of something that's CLEARLY illegible and claiming it's the same as the thing I'm talking about

Attached: 2kuffv.jpg (350x420, 20K)

>Cares about "compresing lines" over readability.
Shithead, the compilators are there for something you know?

Fewer lines are often more readable. Not always though.

he's calling you a redditor nigger

the point is that reducing the size of code just for the sake of reducing it isn't really helpful, ternary achieves nothing and makes it arguably harder to follow than a simple if-else branch which you're accustomed to

I'm here to learn. The methods taught here is the only way I will be able to play Oblivion without crashing. 13 years later, I have gotten through a section of the Imperial City without crashing. Now, I haven't been able to recreate that, but the benchmark exists. One day I dream of having the technology that will allow me to get a benchmark of crossing the entire length without a crash.

/v/ is filled with idiots that just obsess over Morrowind or Skyrim. I know I can get Oblivion to be fun, I just need the technology.

int g(int n) {
if (n>101)
return n-1;

else
return 91;
}

>do my homework
No thanks.
>jesus chirst
Heathen.

>the point is that reducing the size of code just for the sake of reducing it isn't really helpful
That's not always true. It's often much easier to understand a method that fits entirely in one screen than the same method stretched out across multiple screens. Readibilty of code is not a monotomic function that always increases with more lines of code and decreases with fewer. You just have to find a point where further reducing starts to lower readibility and stop at that point.

>g
>n-1

People really need to start treating function composition as an actual operator. Here the equation is
(x-10)°(x-10)°(x+11) , it doesn't take a genius to understand the expression is just x-9.

I like computers, not autism

Yeah that should be a pretty low bar honestly. Ability to post on boards based on IP should be granted based on successfully solving a simple yet non-entry level brain teaser every 24 hours. That way even if you want to shitpost you gotta put some effort into it.
Like for Jow Forums it should unironically be to write code that produces fizzbuzz output in C with the divisors randomly changing so that completely braindead crossboarder retards can't just copy and paste stackoverflow answers. Have the server verify the solution and add an IP to a whitelist for 24 hours.
For /sci/ you solve a math problem. For /co/, /a/ and /v/ you captcha like pictures where you match well known characters to franchises, release years, etc. So on and so forth.

Yes, when you call it 2 times, but is it still correct when you set n = 30?

Why does Jow Forums keep doing other people's home work? I remember when I first started here I would only post a challenge if I had done it before.

I don't really care as long as it's interresting enough.

const fn = require('weird-m-m-n-problem');

obviously this is not homework because this is a very well know function in literature: mccarthy's F91

Anyone can post a proof that it's 91?

Nice try, but the straightforward implementation *is* already O(1) since there is a bounded number of inputs where there will be recursive calls.

Attached: 1505596068867.jpg (838x638, 145K)

def M(n):
return 91 if n

IndentationError: expected an indented block

function M(n)
if n

It's not 91. It's 91 if the input is less than or equal to 101. Do you want a proof of that specific subset of behavior?

why is that, though?

Yes I know. Yes that subset is enough, but a full proof is also ok.

why doesn't someone make a website like this

is this haskell?

notice that if n between 90 and 101, M(n) = 91 (you can calculate each one). especially that M(91) = 91
now if n < 90, you'll apply the formula M(M(n+11)) as many times as possible, so finally you'd get something like M(M(M(...M(n+11k)...))) where n+11 is between 90 and 101. So applying the innermost function call, M(n+11k) becomes 91. The rest is just a lot of applications of M on 91 which will always stay 91.
informal proof but i guess you get the idea.

That's javascript

Just buy more RAM lol. But he's actually right. The solution is a lookup table. He just doesn't realize how small it needs to be.

>iterative

Here's a proof by exhaustion
let m_rec = n => n > 100 ? n - 10 : m_rec(m_rec(n + 11))
let m_const = n => Math.max(91, n - 10)
console.log([...Array(102)].map((_,i)=>i).every(i => m_rec(i) == m_const(i)))

// true

Programmers don't know shit about tech.
t. IT goblin

>O(1)
>iterative
Pick one

now there are the real idiots who don't belong here

Here's an O(1) iterative solution to returning 5 for any input

int foo(int n) {
int i;
for (i = 0; i < 5; i++);
return i;
}

>*runtime* complexity is about the static appearance of the code

Attached: 1554134792898.png (581x525, 55K)

>using conditionals like some betamale homo
int M(int n)
{
return (!!(n > 100) * (n - 10)) + (!(n > 100) * (M(M(n + 11))));
}

I am , what's wrong with what I said? the algorithm has to be O(1) and iterative (no recursion allowed) at the same time. So recursive calls aren't allowed even if the solution is O(1).