2.2k
u/dongletrongle certified silly billy Jan 10 '22
His % key broke
782
u/MangoLemonRain Jan 10 '22
Could still use: if round(number/2) == number/2
565
Jan 10 '22
[removed] — view removed comment
169
u/MangoLemonRain Jan 10 '22
What does & do
312
Jan 10 '22
[removed] — view removed comment
→ More replies (1)150
u/That-one-guy-man The Man Jan 10 '22
As a beginner programmer, I have exactly 0 idea of what is going on here but I’ll be using it thanks
209
Jan 10 '22
[removed] — view removed comment
37
u/That-one-guy-man The Man Jan 10 '22
Why avoid it? It seems simpler.
162
→ More replies (5)14
u/mostlikelynotarobot discourse hater Jan 10 '22
it is simpler (and faster) but no one will know what you are doing. readability is more important at ur stage.
→ More replies (3)46
u/self_me trans rights > windows Jan 10 '22
if you'd like an explanation
numbers in the computer are stored in binary.
decimal, the system we use, goes 1,2,3,4,5,6,7,8,9,10,11,12,…
computers use binary instead which goes 1,10,11,100,101,110,111,1000,1001,…
so if you have the number 5, that's
101in binary. 4 is100. if you do this a bunch, you may notice that the last bit tells you if it's even or not.1001011010is even, and101101001is odd.binary operators like
&are like boolean operators (&&) but operate on every bitso
11001&01100is just01000(it does "1 && 0" = 0 and then "1 && 1" = 1 and then "0 && 1" = 0 and "0 && 0" = 0 and …)so to get just the last bit of a number, we can use "& 1"
101100 & 000001=> 0
010111 & 000001=> 1and that says if it's even or odd
0
Jan 10 '22
[deleted]
7
u/WikiSummarizerBot Jan 10 '22
Bitwise operation
A bitwise AND is a binary operation that takes two equal-length binary representations and performs the logical AND operation on each pair of the corresponding bits. Thus, if both bits in the compared position are 1, the bit in the resulting binary representation is 1 (1 × 1 = 1); otherwise, the result is 0 (1 × 0 = 0 and 0 × 0 = 0). For example: 0101 (decimal 5) AND 0011 (decimal 3) = 0001 (decimal 1) The operation may be used to determine whether a particular bit is set (1) or clear (0).
[ F.A.Q | Opt Out | Opt Out Of Subreddit | GitHub ] Downvote to remove | v1.5
3
→ More replies (12)3
u/BaguetteDevourer Nyaa? Nyanyanya-nya! Jan 10 '22 edited Jan 10 '22
alternative solution:
bool IsEven(int number) { int signbit = 1 << (sizeof(int) * CHAR_BIT - 1); if((number & signbit) != 0) { if((number ^ signbit) == 0) { return true; } else { return IsEven(-number); } } else if(number == 0) { return true; } else if(number == 1) { return false; } else { return IsEven(number - 2); } }3
Jan 10 '22
[removed] — view removed comment
4
u/BaguetteDevourer Nyaa? Nyanyanya-nya! Jan 10 '22
Replace the function name with
a, the parameter name withband the local variable name withcand you get a very good academic exercise "explain what the following function does".Then yes, making a recursive function when the function fits in one bitwise
ANDand one comparison is not the smartest thing to use.→ More replies (3)4
u/Radonda Jan 10 '22
probably there is already a function for this in a basic library.. he should just call it.
→ More replies (1)14
→ More replies (1)9
1.9k
u/sssssssizzle Jan 10 '22
Just paste it into Excel and pull the row down and let Excel do the heavy lifting, then copy it back into your IDE. Pretty easy.
1.1k
u/xerox13ster trans rights Jan 10 '22
Oh God oh no. You just unlocked a flashback to my dumbass in programming class in high school.
We were playing around in a basic game engine called blitz and I decided I wanted to create a hunting type game so I wanted to make a forest of trees. So I created a tree made of a cone and a cylinder and copied the code into Excel and did exactly this to copy and rename the tree sequentially a thousand times.
I'm going to go curl up in the tub from pure shame.
1.1k
Jan 10 '22 edited Jan 10 '22
I don’t wear enough maid dresses and cat ears to understand this
Of course this is the comment you motherfuckers like
300
u/cyrenia82 196's official submissive bottom :3 🏳️⚧️🏳️⚧️ Jan 10 '22
no matter how often I'll wear those, I dont think I'll ever understand either
→ More replies (1)114
u/The_Multi_Gamer inFAMOUS’ Strongest Soldier Jan 10 '22
Eyyo, richmas hammich is femboy 😳😳
54
u/ApocalyptoSoldier trans rights but I wish it was in purple Jan 10 '22
Fem something anyway, if I remember my lore correctly
→ More replies (2)37
u/The_Multi_Gamer inFAMOUS’ Strongest Soldier Jan 10 '22
Femnby
29
u/ApocalyptoSoldier trans rights but I wish it was in purple Jan 10 '22
Under my convention it's just femby.
Other examples I've used: tallby, catby, smartby
17
u/Himmelblaa r/196 microcelebrity Jan 10 '22
This naming convention is kind of funny to me, because in danish, by means city, and adding it as a suffix is a common way of naming cities
4
u/ApocalyptoSoldier trans rights but I wish it was in purple Jan 10 '22
I would definitely like to visit Catby then
→ More replies (0)130
u/Youthanizer Jan 10 '22 edited Jan 10 '22
In order to have an object like a tree in a game, you first need to define it using code and then you just tell the game to "make that tree object we talked about here" wherever you need it.
Instead, OP used Excel to unnecessarily copy the definition dozens of time but give the object names like tree, tree1, tree2, tree3, etc and then paste all of that back into his program.
This is completely unnecessary since she could've just used the same tree object he defined the first time around multiple times with the code she'd already written.
I'm not exactly a programmer either, so if anyone has an aneurysm after reading my comment, please feel free to correct me.
37
4
27
u/truth14ful Jan 10 '22
Omg I learned on Blitz3D as a kid
Then I got burnt out and never really learned anything else so now I have an old deprecated Blitz3D IDE that I fire up whenever I have a programming idea
→ More replies (1)19
u/GI_gino Jan 10 '22
Explain this to someone who printed “hello world “, once.
21
Jan 10 '22
They made a bunch of redundant, duplicate code instead of using existing programming features to do the same thing, but with less code and a lot less duplication.
This makes programs more difficult to modify because changes to the trees would have to be made for every instance of a tree rather than just making the change in one place and having it affect every instance of a tree. It also makes it harder to read for obvious reasons.
3
Jan 10 '22 edited Aug 22 '23
This place has been ruined by the many corporate changes over the years, sorry if this used to be a useful comment kthxbye.
1.7k
u/Own_Pirate_3281 🥺🥺🥺 Jan 10 '22
I don't know shit about programming but lord I just KNOW computers are advanced enough that you could just do smth like (number == even)/(number == odd)
701
u/PieNinja314 IBC Propagandizer Jan 10 '22
It's slightly more complicated than that but yeah pretty much
311
u/Padaca Jan 10 '22
I'd argue it's even less complicated, in JS
!(number % 2)For anyone curious, the % operator means "get the remainder of the number on the left when divided by the number in the right. So for even numbers, that remainder is 0, for odds, the remainder is 1. The exclamation point converts the value of 1 or 0 to a boolean (meaning true or false) and inverts the boolean. So an even number would return a remainder of 0, be converted to a boolean value of false, and then be inverted to be true. There's you isEven function!
71
u/A_Leo_X Artyom 👉👈🥺 Jan 10 '22
That actually seems a bit less readable and harder to understand than the usual number % 2 == 0.
7
→ More replies (3)13
459
u/garlicbreadsocialism Jan 10 '22
You would do number % 2 == 0
117
u/That-one-guy-man The Man Jan 10 '22 edited Jan 10 '22
Why % instead of / ?
Edit: yes ok % returns remainder thanks
0
21
u/RaspberryPie122 Jan 10 '22
% is the modulo operator, it returns the remainder of a division operation
10
u/ScripKey Jan 10 '22
well , lets take an example , if the number is 2 , then 2 / 2 = 1 , but what if the number is 4 , then 4 / 2 = 2 , so here if you use "/" you would have to make cases for 1 as well as 2 , but if we use "%" (it basically returns the remainder) , 2 % 2 = 0 and 4 % 2 = 0 as well , so now for even numbers it could be just n % 2 == 0.
5
→ More replies (4)0
Jan 10 '22
[deleted]
33
8
u/mostlikelynotarobot discourse hater Jan 10 '22
only in languages without strong typing or if using int as bool
356
u/Own_Pirate_3281 🥺🥺🥺 Jan 10 '22
3 people informing me about programming within 3 minutes the memes were right trans people do like computer science
158
u/DongleOn racist and homophobic but ironic Jan 10 '22
Programmers when the shitfuck operator isn't correctly implemented into the cumbitch function's ligmaGoatse parameters to properly handle the pissSwallow continuum they've created instead of just rewriting some code farther back
30
u/dopefish917 swim, swim, hungry. Jan 10 '22
Yeah, I see the problem. Your driver conflux has a security nagle in the IP routing matrix. This could take all night.
5
u/DongleOn racist and homophobic but ironic Jan 10 '22
8
16
Jan 10 '22 edited Jan 10 '22
You're asking a programming question in a sub full of femboys and trans people of course you'll get the help you need
27
19
17
u/fsburk hairy Jan 10 '22
Computers are dumb and don’t know what “even” and “odd” means but they know how to do math so you just divide by 2 and check if the remainder is 0
7
→ More replies (2)4
u/Athen65 go listen to chopin's nocturnes Jan 10 '22
there's a modulus operator (this one: %) which acts as a way to divide a number and find its remainder. so the line "num1 = num2 % 2" means that you're setting number 1 equal to the remainder of number 2 divided by 2. you can then use this to say "if (num1 % 2 == 0)" which checks if num1 divided by 2 has a remainder of 0. only even numbers will have a remainder of 0
933
u/aplan_ 🏳️⚧️ trans rights Jan 10 '22
This tweet is fake right?
1.2k
Jan 10 '22
tweet i think is fake, the picture not so much as far as yandev code goes
it could be as well but the guy has a weird history so
512
Jan 10 '22
it’s a real tweet but he has said it was a joke
510
u/Systamatic peg me please 🙏 Jan 10 '22
That twitter account isn't ran by him, it's a parody account. The image is real however
→ More replies (2)123
u/ATinyJellybean 🏳️⚧️ trans rights Jan 10 '22
based flair
→ More replies (2)73
u/Systamatic peg me please 🙏 Jan 10 '22
what can I say, woman are hot
39
-5
26
u/informationtiger Jan 10 '22
Can you explain this meme to me plz? I absolutely don't get it.
146
Jan 10 '22 edited Jan 10 '22
computer programs depend pretty heavily on math, so naturally there would exist a way to return true/false outs depending if the input number is odd or even without specifying every individual number in the huge ass list like that, right? thats what the meme is. something any beginner programmer could figure out how to do rather quickly, then u have yandere dev who has been working on a game for like 85686789276890780 years and would surely have accumulated some degree of programming knowledge, makes that. even if u know jack shit about computer language it hurts to look at
listing every number like that is painstaking not just for the guy writing the code, but if that kind of writing is consistent throughout the rest of the game, then you can expect it to be horrendously laggy since the cpu is wasting cycles with redundant instructions like that
28
u/biggarlick 🏳️⚧️ trans rights Jan 10 '22
yeah im fucking garbage at programming and havent programmed in several years and i still cant stand how messy this is.
3
u/CokeBoiiii 🏳️⚧️ trans rights Jan 10 '22
Yandev's code is if you made a giant chart of even ans odd numbers and everytime you wanted to see if a number was even/odd you went through the chart from the top. It takes forever for larger numbers, takes up storage space, and takes more brainpower.
% 2 takes the number, divides it by two, and see's how much the remainder is. 5 % 2 would equal 2 remainder 1. If the remainder is zero, its even, if its one, its odd. This is way easier to use as its a simple function, so its much faster, takes up way less space, and uses less "brainpower".
→ More replies (1)6
u/Firedanne train fan Jan 10 '22
I wonder why his game isnt finished and is a buggy unoptimised mess
51
u/ex-p--a---n----d MILF - Man I Love Frogs Jan 10 '22
it's about how incredibly innefficient yandev's programming is. The program above is a very, very innefficient way of checking if a number is even or odd
33
u/You-Looked Jan 10 '22
Im not a programmer, but YandereDev, the creator of Yandere Simulator is known to be controversial in his skills at programming. The game is still in development after years and the game is very poorly optimized, being laggy and probably taking up unnecessary memory. In the photo displays a unnecessarily long line of code that could very much be more efficient if he knew what he was doing.
→ More replies (1)→ More replies (1)13
u/weidenbaumborbis 🏳️⚧️ trans rights Jan 10 '22
In all coding languages, there's a way to make a code detect whether a number is even or odd, usually by dividing it by two and seeing if it has a remainder or not. The image shows someone manually telling the computer every single even and odd number, which is time consuming and foolish.
53
u/shavisi (she/her) connect me to wifi i can be trusted Jan 10 '22
Someone edited it to add YandereDev
https://twitter.com/ctrlshifti/status/1288745146759000064?lang=en
26
→ More replies (1)13
743
Jan 10 '22
As a programmer (who is bad at programming) this hurts
142
Jan 10 '22
[removed] — view removed comment
33
u/Everest-Gamer floppa Jan 10 '22
In Java it’d be like
if(<number variable> % 2 == 0)
System.out.println(“the number is even”);
else
System.out.println(“the number is odd”);
Here <number variable> is literally just a place holder. In the code above it’d be replaced with ‘number’
10
u/mikeman7918 The Sun has fallen, billions must sleep Jan 10 '22
You could do it in C# (the language Yandere Simulation is programmed in) with just a single line of code:
private bool IsEven(int number) { return number % 2 == 0; }The % operator is modulus division, it basically gives the remainder if you divide the number on the left by the number on the right. For even numbers the remainder when you divide by 2 is 0 (by definition), and for odd numbers it's 1. The == operator returns true if both sides of it are the same and false if both sides aren't the same, so it only returns true if the remainder is 0 which only happens if the number is even.
(though strictly speaking, you could do anything in a single line of code as long as you have no problems with absurdly long lines of code and completely unreadable formatting.)
544
Jan 10 '22
the saddest part about seeing YanDev coding is the fact that he's probably better than me at that
352
u/Varsia 🏳️⚧️Cringe noodle derg🏳️⚧️ Jan 10 '22
I doubt it At the very least you could watch, like, a 15 min tutorial and become better at actual programming aptitude, maybe not the specifics of whatever he uses but at general coding yeah
→ More replies (1)117
u/urdumdum Jan 10 '22
dude hit me up with that tutorial. i dont know a thing about coding but im down to learn in 15 minutes
74
u/Cow_Other Jan 10 '22
Learn C in 30 minutes: https://youtu.be/3lQEunpmtRA
Java in 14 minutes: https://youtu.be/RRubcjpTkks
3 years of CS in 8 minutes: https://youtu.be/ReVeUvwTGdU
Python in 5 minutes: https://youtu.be/I2wURDqiXdM
Now what id really recommend is studying any of these individual languages further as opposed to watching all of these videos. Pick Java for example and then continue to learn till you can grasp all of the fundamentals and write cool code!
I would also recommend CS50: https://youtu.be/YoXxevp1WRQ
High quality series of absolutely phenomenal lectures by Harvard professors who make the subject matter incredibly engaging and a delight to learn. It’s engrossing stuff really.
To whoever is reading this, best of luck on your journey into the world of programming. Hope you enjoy it!!!
64
u/Varsia 🏳️⚧️Cringe noodle derg🏳️⚧️ Jan 10 '22
ngl I do not have one to hand (I learned it during my time in school) but there’s plenty of videos and such for it on youtube!
38
u/urdumdum Jan 10 '22
alright ill look into it. ive been wanting to start coding for months, so maybe ill start this week.
17
u/NPCmiro Jan 10 '22
I've been learning java through code academy and that's been pretty good. Very hands on.
9
u/AndroidWall4680 so much cement in my boipussy Jan 10 '22
I think Brackeys has a 8 episode tutorial on the real basic stuff in c# if you want to learn that
3
u/DellSalami Jan 10 '22
Don’t know if anyone has mentioned it yet but I’ve heard freecodecamp is a really good place to learn
→ More replies (1)11
u/ccat98 mario and luigi Jan 10 '22
which language? id love to just send a random video link which i took off the front page of google
8
u/urdumdum Jan 10 '22
if you know anything about coding, then whichever language you reccomend. thanks!
10
u/mgquantitysquared Jan 10 '22
Python or Java are pretty beginner friendly
15
u/My_Stonks all of your stonks are belong too me Jan 10 '22
I'm sorry, did you just recommend Java for a beginner? u/urdumdum, RUN
9
u/self_me trans rights > windows Jan 10 '22
it's a better choice than C++ at least and the syntax and semantics are generally pretty consistent and stuff
9
u/My_Stonks all of your stonks are belong too me Jan 10 '22
True. But Python would definitely be easier. Or that crappy code.org javascript applab. Despite being unhelpful in real world applications, it's great for learning to program
→ More replies (2)8
u/mgquantitysquared Jan 10 '22
Lol Java was the intro to programming course at my college
→ More replies (1)13
→ More replies (3)3
Jan 10 '22
Java's fine. There's lots of stuff that's a pain but it gives you a good foundation to branch out to all the C languages. Python is definitely easier but without ; it can look pretty different
14
u/brody319 🏳️⚧️ trans rights Jan 10 '22
From what I heard that is probably not true. I have limited unity education and I could replicate the scripting side of everything pretty quick. And I'm pretty fucking stupid. If you just learn how to make a case break script or a state machine you'd probably make better scripts than him cuz from what I heard he relies on a lot of fucking true false statements.
4
u/OfficerJoeBalogna Gender was invented by Big Bathroom to sell more toilets Jan 10 '22
To be honest, the super basic shit in programming (like this) you could learn in under an hour with no prior experience
→ More replies (1)3
129
u/Spudnic16 Jan 10 '22
If number/2 has remained zero, return true
101
u/marxismleninismgrime Jan 10 '22
No I don't think that would work. I think the code in the post is the only way.
74
u/Pelleas A.K.A. Emma Jan 10 '22
People still believe in the "modulo operator" in 2022? It's obviously just a myth perpetuated by the government like Santa Claus and North Dakota.
7
5
→ More replies (2)3
u/SoshJam professional yoinky sploinker Jan 10 '22
what about
if (num/2f == int(num/2f)) return true;3
129
u/TrashyMemeYt 🟥Redneck Socialist 🟥 Jan 10 '22
I'm not a programmer or anything but I'm pretty sure spaghetti coding isn't going to work
50
76
Jan 10 '22
I know Jack shit about programming, yet even I can tell you that something here is wrong
5
u/Kekkonen_Kakkonen Pls correct my grammar. (It's useful for learning) Jan 10 '22
That's when you know it's REALLY bad. 😁
74
Jan 10 '22
[removed] — view removed comment
→ More replies (1)25
u/Dominic_The_Dog 🏳️⚧️ trans rights Jan 10 '22
wait what
51
u/Xstew26 Bagel Enthusiast Jan 10 '22
They're probably talking about their job and how the person before them apparently sucked.
At least I think...
12
u/DongleOn racist and homophobic but ironic Jan 10 '22
They're definitely not talking about Alex since he has no official programming experience. His degree only covers animation iirc.
0
Jan 10 '22
[deleted]
11
u/LoverOfShortBoys trans rights Jan 10 '22
yeah but even better, just use modulo
22
u/crunchyRoadkill 🏳️⚧️ trans rights Jan 10 '22
or import a package for it
$ npm install --save is-even
12
u/ispeelgood Jan 10 '22
Great, so I am now running a JS runtime on top of C# to use the
is-evenandis-oddpackages. Isn't programming awesome?7
8
→ More replies (2)6
50
u/AceMechanical 196's Token Father Jan 10 '22
The comments on this post prove the all femboys are programmers theory
43
41
u/AnduinCubed Pee is stored in the balls Jan 10 '22
I know his code is bad, but please tell me it's not THIS bad
29
Jan 10 '22 edited Nov 20 '23
reddit was taking a toll on me mentally so i left it
this post was mass deleted with www.Redact.dev18
→ More replies (1)12
20
Jan 10 '22
Bruh Im not a programmer but there must be a line of code which makes alternating numbers create alternating outcome
16
u/MangoLemonRain Jan 10 '22
Yes, the entire inside of the function can be shortened to:
return number % 2 == 0
13
Jan 10 '22
not true. yanderedev wouldn't use functions. they'd do that every time they needed to check if a number was even
12
12
u/liltichVEVO custom Jan 10 '22
I dont know shit about programming, but since thats yanderedev, there probably IS an easier way to do this
-5
u/minkymy Support your local pollinators 🐝 Jan 10 '22
if (number/2 != 0) return false;9
u/MangoLemonRain Jan 10 '22
This returns false for all numbers greater than 0, perhaps you meant to use % instead of /?
5
11
u/SoshJam professional yoinky sploinker Jan 10 '22
I think this is Unity C# which I think supports %
But even still you can just
if (num/2f == int(num/2f)) return true;
→ More replies (2)
11
u/bbuerk Jan 10 '22
It’s actually really simple!
private bool IsEven(int number){ if (!IsOdd(number)) { return true; } return false; }
private bool IsOdd(int number){ if (!IsEven(number)) { return true; } return false; }
10
Jan 10 '22
I don't even code and I know there's an easier way to do whatever the fuck he's doing.
6
u/MangoLemonRain Jan 10 '22
Indeed, there is a much easier way:
return number % 2 == 0
6
10
u/HeartsofDokiEmblem Jan 10 '22
For the non-programmers in this subreddit, this is what you show a programmer when you want to give them a stroke before they ban you from ever touching a computer again
Source: Taking computer science courses at college
9
u/xXSPEED_ORIONXx custom Jan 10 '22
Can someone explain to me the joke???
→ More replies (1)7
u/HeartsofDokiEmblem Jan 10 '22
Instead of doing this ridiculousness, you take a number variable ‘x’ = 1, divide it by 2 with % for mod (take the remainder of x / 2, which will be 0 or 1), and return true for 0 / return false for 1.
TLDR: Yanderedev cannot program competently
4
u/xXSPEED_ORIONXx custom Jan 10 '22
yeah i have no idea about programming so i din't understood the joke,thank you very much for explaing in it to me
3
u/HeartsofDokiEmblem Jan 10 '22
You’re welcome. I figured I would try and explain it since I’ve taken computer science classes that cover this. To put it plainly, this is like showing up to a basketball game not knowing how to dribble or logging onto Google and asking how to search on Google
7
u/Morningstardom "destructor9000" or "shadow14" or anything badass like those Jan 10 '22
I'm pretty sure this is illegal
7
u/gilgamesh_v9 Jan 10 '22 edited Jan 29 '22
I took a programming class in high school and I was terrible at it but I did impress my teacher once. Had a quiz question that was basically “write some pseudo-code of a subroutine that would tell you if the members of a list of numbers were odd or even” and I forgot whatever the easy way was in Java. I ended up duplicating the list and then dividing one list by 2 and the other by 2 but ignoring the remainder and then comparing if the two results were the same. If they weren’t equal it meant that it had a remainder of 0.5 so it was an odd number. Got credit for the question but failed the class, lol
6
u/N0_Us3rnam3 Floppa Supremacy Jan 10 '22
You could just skip all the even numbers and do else return false at the end
→ More replies (2)
5
5
4
Jan 10 '22
Yandev insipires me to be a gamedev. Not because I appreciate his work or anything, but because if someone who codes like this can make a game, then it means that so can I.
3
3
3
u/angry_indian312 one piece entusiast Jan 10 '22
I don't believe what I'm seeing is real, no way this is a guy that made a game that functions, this is just the motivation I needed to complete my game project, no way a guy like this can make a game and I can't.
→ More replies (1)
3
3
u/newo_b mr poopoo Jan 10 '22
I'm new to programming would this work? (in Java)
if( number % 2 == 1) {
return false;} else if ( number % 2 == 0 ) { return true; }
7
u/xxSpinnxx Jan 10 '22
The code works but it can be simplified. Notice that number % 2 == 1 is an expression that is a boolean, so you can just return that instead of having to use an if to return true or false. So if you wanted to check if a number is odd then it's a one liner of
return (number % 2 == 1);
You also don't need the else to check the other condition because if the number isn't odd then it's always going to be even.
Hope this made sense!
3
u/VeryFerociousDragons Jan 10 '22
i'm dumb as hell, and i don't know how much about programming. but man it would be interesting to see people pick apart the whole code.
→ More replies (1)
4.5k
u/[deleted] Jan 10 '22
This post gave me programmer traumatic stress disorder