Honestly not that stupid because unrolling a loop can increase performance in some cases, though the compiler is smart enough to do it on its own in reality
“The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times; premature optimization is the root of all evil (or at least most of it) in programming.” — Donald Knuth
"wow lucky me it's just 1 to 10 that's 10 numbers to print i'll finish this assignment very quick! i must be getting better!" -the person who wrote this code, probably
function didMyInstructorMeanToSayIntegersInsteadOfNumbers(){
string sig = ""
while True{
print("0.")
print(concatenate(sig, "1"))
print("\n")
sig = concatenate("0", sig)
}
Really?? You mean this is more efficient than just printing in a loop? Why is that? Because of loop unrolling (compiler optimization), shouldn't they have exactly equal performance (since same assembly is generated for both cases) ?
Yeah I’d say if that were the prompt, this was a masterclass in trolling unclear instructions. It’s like the CS-101 thing all classes do when starting functions where you tell the TA how make a PB&J.
I don’t think so, it just works. Maybe they haven’t yet learned about loops and this is introduction question to let them know when they could be using loops instead of repetition
English doesn't really have a great option for talking about one person of unknown gender. "It" is generally not acceptable when talking about humans. "He/she" is clunky and doesn't apply to everyone. "They" is generally used in this situation, but some people refuse to use it for anything other than a group of people.
Are plural forms of verbs also gendered? If not, than that might be a solution to the gender neutral speech. It might feel foreign at first but works like a charm once people get used to it.
3
u/kirbomatik Oct 31 '21
oof @ showing the kid's real (assumed) student user id :(
to his credit, it's the most fascinating way I've ever seen someone technically get the correct answer for this
555
u/starryhound Oct 31 '21
Meets acceptance criteria, ticket closed
562
u/AlbertoTrindade Oct 31 '21
r/technicallythetruth
307
u/Rockytriton Oct 31 '21
for (int i=0; i<2; i++) {System.out.println(1 + (i * 5));System.out.println(2 + (i * 5));System.out.println(3 + (i * 5));System.out.println(4 + (i * 5));System.out.println(5 + (i * 5));}2
u/MrStricty Oct 31 '21
Student code doesn’t belong here. The guy/gal is trying to learn.
129
u/CSsharpGO evil Oct 31 '21
Idk man, he did what he was asked.
72
u/[deleted] Oct 31 '21
The anti-loop
57
u/Ypsnaissurton Oct 31 '21
I kinda want to say /r/maliciouscompliance
174
u/[deleted] Oct 31 '21
I mean, from an abstract point of view, you could say he turned an O(n) loop into O(1). A+?
25
u/[deleted] Oct 31 '21
Finally a post that I understand
23
u/ImplementNational165 Oct 31 '21
Question 2: extend said loop to 1000
12
u/friendg Oct 31 '21
Looks like something GitHub autopilot would write
18
u/StochasticTinkr Oct 31 '21
Am I doing this right?
7
u/calio Oct 31 '21
"wow lucky me it's just 1 to 10 that's 10 numbers to print i'll finish this assignment very quick! i must be getting better!" -the person who wrote this code, probably
6
u/dip2leo Oct 31 '21
It works at least lol
6
u/JustAnotherGamer421 shameless Oct 31 '21
Engineers:
11
u/demented_doctor Oct 31 '21
5
u/WarrenBuffetsAnalyst Oct 31 '21
I mean if I did this in a test I’m fighting for the marks
5
u/alrogim Oct 31 '21
"Can you please write the numbers one to ten inside a loop?" - "You mean >inside< a loop?" - "Yes" - "Okay, whatever."
4
u/psst531 Oct 31 '21
In commercial terms, this would be the trial version options. For full& unlimited functionality, purchase the full pack.
17
u/ashmortar Oct 31 '21
It's 10 times more efficient than the expected answer.
7
u/HeroscapeZ Oct 31 '21
The loop is already written.... It's right there ... Why would... What... No.... This is illegal.
1
u/somMelon Oct 31 '21
How did you make the window color dark on Notepad++?
1
u/botle Oct 31 '21
"WEEK5Java"
1
u/[deleted] Oct 31 '21
Zadanie 1...Slovak uni I guess?
3
u/Axolotl_Slayer Oct 31 '21
Uff
3
u/erihel518 Oct 31 '21
The loop is set up properly, so he obviously knew what he was doing.
3
u/Qildain Oct 31 '21
Seems like he did what was asked. QA would agree.
3
u/Phalcorine Oct 31 '21
As long as it works... Right?
3
u/Krzyffo Oct 31 '21
That's your friend's week 5 of PPJ dude, he better get ready to pay for ITN.
3
u/DeeFahw Oct 31 '21
This ain't bad, they unrolled the loop.
3
u/BaudMeter Oct 31 '21
Assignment: "Use a for-loop to print numbers from 1 to 10". He did.
3
u/sleeptil3 Oct 31 '21
Yeah I’d say if that were the prompt, this was a masterclass in trolling unclear instructions. It’s like the CS-101 thing all classes do when starting functions where you tell the TA how make a PB&J.
7
u/BrogCz1 Oct 31 '21
I mean, Hungary 2.0, what do you expect... xd
2
u/KyleDrogo Oct 31 '21
lol
2
u/KyleDrogo Oct 31 '21
lol
2
u/skullman_ps2 Oct 31 '21
Well... hmm now.
2
u/AnonymousRand Oct 31 '21
If only he had removed the loop entirely, then he could claim that he turned O(n) to O(1)
2
u/Knuffya Oct 31 '21
See that shit? That's what AI is gonna do if we don't invest in AI safety.
2
u/the_other_Scaevitas Oct 31 '21
It… technically works
2
u/ShadowArcher21 wicked Oct 31 '21
The real flaw in this image is opening java files in Notepad++
2
u/davidedpg10 Oct 31 '21
He is a god among us
2
u/[deleted] Oct 31 '21
It's not a loop if it goes through the code only once.
for(int i =0; i<2;i++){
System.out.println(1+i*5);
System.out.println(2+i*5);
System.out.println(3+i*5);
System.out.println(4+i*5);
System.out.println(5+i*5);
}
There. Fixed it.
2
u/SMMB98 Nov 03 '21
I think it needs a
if (true){}as well.
2
u/ososalsosal Oct 31 '21
This is perfect haha. Full marks. O(1)
1
u/mullam Oct 31 '21
Week 5 Java...
1
u/Blueflames3520 Oct 31 '21
It's probably faster than the expected way.
1
u/fletch3555 Oct 31 '21
1
u/chrisrrawr Oct 31 '21
O(1)
1
u/Furry_69 Oct 31 '21
It's not wrong, per se, but it's not at all what was asked for.
1
u/MvKal Oct 31 '21
Average Slovak programmer
1
u/[deleted] Oct 31 '21
does java have do..while loops? in Javascript lol
1
u/TabCompletion Oct 31 '21
/r/madlads
1
u/[deleted] Oct 31 '21
I HATE IT
AAAAAAAAAAAAAA
1
u/Chris_Cross_Crash Oct 31 '21
If it's not broken, don't fix it! /s
1
u/mrheosuper Oct 31 '21
Pass the unit test, case done
1
u/DakiAge Oct 31 '21
He doesn't even know why he increments that i :)
1
u/xNamelesspunkx Oct 31 '21
They either could have print (i). in the loop.
Or better:
Declaring an empty String
For each iteration you put "i \n" (or was it "i" + \n)
Then print the String.
This would be faster as you only print once instead of i amount of time.
(Still a beginner so of I made an error somewhere be gentle :P)
1
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Nov 01 '21 edited Nov 01 '21
Image Transcription: Code
[The image is a photograph of code on a computer screen. The code reads as follows:]
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
1
u/BlipBlop69420 Nov 06 '21
fantastic code
1
u/FunLovingMonster Nov 10 '21
He understood the assignment.
1
u/XFaon Nov 13 '21
LMAO
1
u/arewhyaeenn May 15 '22
Technically correct. I taught freshman OOP for a few years and this would have gotten full points and a happy comment
1
u/Lyin25 Jun 20 '22
I mean it's technically right
1
u/[deleted] Jan 12 '23
I hate it
1
u/mariansam Oct 31 '21
Yeah, Slovakia..
1
u/mintas123 Oct 31 '21
Jeśli to piąty zjazd to ITN się szykuje, a jeśli to Tomaszew... Módl się za kolegę :)
1
u/xardas96 Oct 31 '21
Polska górom!
1
u/swietjak Oct 31 '21
kurwa, ale ktoś zjebał xd
0
u/[deleted] Oct 31 '21
[deleted] — view deleted comment
239
u/[deleted] Oct 31 '21 edited Oct 31 '21
[removed] — view removed comment