I will never be a good programmer, right?

I will never be a good programmer, right?

Other urls found in this thread:

codewars.com/
repl.it/Ib1k/1
repl.it/Ib1k/3
repl.it/Ib1k/4
twitter.com/SFWRedditVideos

You don't have to count all of them, only the first 3, this is how you know whether to start scanning for evens or odd numbers.

Pretty much Pajeet tier, OP.

Don't worry, if you have a vagina you'll still get hired.

drink bleach already

You won't be a clever one with that attitude.
If you just want us to reaffirm your lazy self-image, sure, you're and never will be a clever programmer.

holy shit, you are right

i don't have :(

clever != good

Dude, as long as it works at first that's a great first step.
after that try and gradually improve it. Programming skills improve with time and practise.
Don't drink the bleach yet...

Kek wtf is that? It's cool if it's you're new to programming because you can only solve things with the tools you know. Also just because something has less lines doesn't mean it's better. I wouldn't use split, why have a function go through every possibility when the first 3 can give you the answer. If you have list of 1000 even numbers and the odd one is isn't last you're wasting time and power.

Didn't read a word of that horseshit.
But the real reason why you never be a good programmer is simple - you are using python.

This. Op if you want to be a good programmer, don't start with a nigger language

>You don't have to count all of them, only the first 3

why exactly?

>only the first 3
You aren't actually serious, are you?

If you check only the first, it might be even or odd, you don't know how to continue.
If you check only the first 2, they might both be even/odd or it might be one of each, you don't what to look for.
If you check the first 3, it could be 3 evens, or 3 odds, or 2 evens and 1 odd, or 2 odds and 1 even, you'll be able to determine which is the majority in only 3 numbers and you simply scan through the rest looking for the outlier.

It depends on the order of the numbers. If the first two are even, you know to look for the first odd. If it is 2 6 3, you found it.

this. if there is only allowed to be 1 outlier then you can tell exactly what to look for by checking the first 3

Also, it helps to think of it like this:
It wouldn't make sense to provide less than 3 numbers to this function because you require at least 3 numbers to describe the requirements.

I said can, not will. The first 3 can give you the answer therefore there is no need to search the entire list of numbers.

what if its something like 2 2 2 3?
am i not understanding the instructions?

link to website?

what not nigger language do you recommend?

You're supposed to return the index of the outlier number.

if it's 2 2 2 3, you already know it's an even-majority list and you're gonna look for the first odd.

codewars.com/

3 is the minimum required, not guaranteed

id recommend you java.the others probably gonna say c but you cant really do anything with c except for writing kernels and compilers.also java is a million times easier to learn and you dont need the speed that c provides anyway.

I get it now. Only **one** number differs in evenness.

Why would returning the index call for searching through the entire list?

thanks ,my man

>Only **one** number differs in evenness.
oh fuck, that's what i missed.

thanks lads, for a moment i thought i'm actually retarded. it's just that i can't read.

the outlier might be at the very end of the list?
You don't have to keep going if you already found it

why am I even explaining this shit I write driver code for a living

Don't learn java, too easy to fall into bad habits. Learn C, the guy saying you can only build kernels is delusional. At least do c++, java is too automated.

>preparing to pass iq test
>indexes
I think the author might need to take one of those tests.

OP, consider learning a language that encourages functional programming like Lisp, it'll teach you to think of these kind of problems in terms of recursion or mapping a function over a list which leads to very neat solutions.
The Little Schemer is a fantastic book for just this.

This.
I started coding at Uni with Java and got too comfy with it. Adopting other languages were a nightmare.

Work on reading comprehension. That or you responded to the wrong person with the index nonsense.

why would you tell a hobby programmer to learn c or c++?why would you put him through the pain of managing your own memory,STL,preprocessor directives,templates and the other retarded shit c and c++ does?
why do you think a hobby programmer wants to fuck around with /0 terminated character arrays and shit when we both know that its completely useless to learn c and c++ for their use case.they are not gonna write speed critical applications or an OS anyway.they want results.and now please go back to your c circlejerk thread grandpa

Same that's why I tell people not to do it, especially without guidance.

C is a great first language.
How can you understand all those abstractions like split and join without knowing how to write them yourself?
Could you even extend your language as needed if if your language didn't have nice things like split and join?

Also, this post reeks of someone who has never touched C or C++.

What would an Scheme solution to OP's problem actually look like?
I see posts all the time talking about how great CL and Scheme are, but I've yet to see any actual Lisp on Sup Forums.

Kek found the pajaeet. Java has too many built in functions. If you're trying to make a shitty app quickly, sure use java. If you want to learn and understand programming, use C

there's nothing wrong with your solution aside from insignificant inefficiency per You just didn't jam the logic into one line is all

oh my fucking god from the skies please help me.CANT YOU ETCH IT INTO YOUR SKULL THAT HE IS NOT A PROFESSIONAL?CANT YOU FUCKING UNDERSTAND THAT HE DOESNT GIVE A SINGLE FUCK HOW SOMETHING GETS ABSTRACTED ANYWAY?THATS WHY HE STARTED WITH PYTHON IN THE FIRST CASE.

i think one of my blood vessels gonna pop can we please start banning c posters already?

How are you supposed to become a professional if you don't even know what your magic standard library is doing?

>this post reflects 99% of posters on Sup Forums

The post implies he wants to be a good programmer. C>Java, end of story.

you really just cant understand it can you?literally when a kid sees a dead body and his mind blocks it to defend itself from the trauma.user's problem is literally a one-sided mirror to you isnt it?

Are you ok?
You write like you're having a mental breakdown.
Get help.

Everyone here is now stupider after reading that. Thanks a lot user

Don't learn both of those. Start with FASM it's really easy and it has a good README file. But before this learn something about how OS works and kernel calls. Then you should learn x86 instruction set and do FASM for practicing.

>list
(((((()))))))))))))))

Ok, tell me, where did the pointer touch you?

Mov is the most idiotic thing ever invented.

the problem is that your religious love of c is blinding you and you literally dont have enough brain cells to comprehend that c is not the appropiate language for what user wants.

So you guys are telling me this is the right solution?
repl.it/Ib1k/1

you two should just stop
you are not even speaking the same language
once you get on the same page, you can restart
until then, I forbid you to carry this discussion any further

yes, but you only need one loop
you have 3 in there (4 if you count the 4th (obviously))

Why?

how do I do that?

>i don't have :(
you don't have too! See application options

>the first three can give you the answer
Why are you retards saying this as if it means anything? OP's code is bad because it iterates through the entire list regardless of where the important number is instead of stopping when it is found.

Does it say anywhere that there will be 5 and only 5 inputs?

import std.stdio;
import std.string;
import std.range;
import std.conv;

void main()
{
string[] inputs = readln().strip().split();
int[] numbers;
foreach (number; inputs)
numbers ~= number.to!int;

ulong[] uneven_indices, even_indices;
foreach (index, number; numbers)
if (number % 2)
{
uneven_indices ~= index + 1;

}
else
{
even_indices ~= index + 1;
}

writeln(even_indices.length < uneven_indices.length ? even_indices : uneven_indices);
}

Handles unlimited inputs.
$ echo 1 12 12 3 90 11 7 15 | ./evenness
[2, 3, 5]
$ echo 22 34 5 98 86 90 | ./evenness
[3]

repl.it/Ib1k/3
it's shit, but only one loop

How about this?

Boring

Let's see your sieve, then.

I don't get it. What are the people who ask this question testing for?
Is it a retard test? Are they trying to see if you understand what the question is asking?
Is it a pajeet test? Are they trying to see if you will actually write your own prime sieve?
Why wouldn't I just copy someone else's prime sieve and save time?

I've heard that just having a list of all primes up to x is good to do, instead of doing it yourself. How true is that really?

It's on Wikipedia

repl.it/Ib1k/4
improved it a tad

You're book smart but you don't make paper

-Java programmer

Why aren't you reading from the input stream? Why are you expecting only one (un)evenness?

>the best solution
Requires intimate knowledge of the language. Given it's python, so whatever crappy solution is fine because it's gonna be fucking slow anyway, I'd prefer yours. If I found it slow I could easily make it faster. It really is trivial code. I don't even write python and I understand exactly what you're doing.
The other shit has so many things where I'd have to assume semantics of the language.

Also.
>best practices
Is just something people say to claim superiority.

>Expecting a complete program from pythonfaggots

But it actually is more efficient not to indiscriminately go over all the numbers counting odds and evens.
Go over the first two or three (depending on input,) and set a flag to true or false.
Then iterate over the remaining numbers until list[index]%2 == flag, at which point return index+1. Simple.
The "elegant" approach is computationally wasteful.

Because the question dictates that there is only going to be one (1) (un)even number???

>Why aren't you reading from the input stream?
Are you an idiot?
>Why are you expecting only one (un)evenness?
Read the OP and the thread again.

I have never programmed in Python. I just showed the dude how it could be done in a single loop.

If you can't write your own sieve off the top of your head, you're incompetent. It's a trivial algorithm - mark off multiples of primes. There's nothing to "copy", unless you can't actually program.

I'm incompetent and can't actually program, then. Thank you for your analysis.

What's wrong with reading from stdin?

How sad.

Writing your own sieve is literally a waste of time. Any employer that doesn't recognize that is probably staffing Pajeets.

>a waste of time
It's like 6 LOC in Python. The waste of time is you if you can't write it. The concept is trivial, meaning it's fizzbuzz-tier. Are you telling me you also struggle with writing fizzbuzz?

You are very proud of your 6LoC program, aren't you

You are very defensive in your inability to write a sieve. What trivial algorithm can you write, actually?

What's wrong with not reading from stdin?

Cute

Bubble Sort, if I get the pseudocode from somewhere

You have to compile program each time you want to compute different arguments

You don't get it, but you are missing the point
Can't tell if actually autistic

Why would I bother writing my own fizzbuzz when I can just get right answer off of stackoverflow?
like am I supposed to memorize this modular nonsense that will never be used in 99% of programs?

>but you are missing the point
what point?

>Wastes of time are acceptable because it's not a massive waste of time
Hello good sir Sanjeev Balakrishna! Please do the needful and make finished your JavaScript assignment.

THIS
Always write shitty code and refine.

>Always write shitty code and refine.
This is the best way to code that I've found

>the best solution
feh
If argument is passed sensibly as an array of numbers:
let iqTest = n => n.findIndex(a=>(a%2)^(n.slice(0,3).map(x=>x%2).sort()[1]))+1
If argument is passed as a stupid space separated string like in OP's pic:
let iqTest = n => n.split(' ').map(m=>parseInt(m)).findIndex(a=>(a%2)^(n.split(' ').map(m=>parseInt(m)).slice(0,3).map(x=>x%2).sort()[1]))+1

>' '
what if there tabs in between?

They aren't

def sieve(limit):
if limit >= 2:
yield 2
l = [1]*(limit + 1)
for i in range(3, limit + 1, 2):
if l[i]:
yield i
for j in range(i*i, limit, i):
l[j] = 0

print(sum(sieve(2000000)))

142913828922

real 0m0.441s
user 0m0.404s
sys 0m0.012s
Easy. If you struggle with this, you must be mentally deficient.

what if there is? And what happens if you get multiple ' ' s?

>If argument is passed sensibly as an array of numbers
it isn't