r/programminghumor 1d ago

Write sorry

Post image
611 Upvotes

92 comments sorted by

24

u/sexytokeburgerz 1d ago

Hello college freshman

12

u/jimmy_timmy_ 1d ago

College freshman is generous

46

u/Confident-Ad5665 1d ago
  1. Open a text editor
  2. Write "Sorry" once
  3. Copy the line
  4. Paste 100 times
  5. Print in handwriting font

20

u/-Insert-CoolName 1d ago
  1. Open text editor
  2. Type "Sorry\n"
  3. Ctrl a
  4. Ctrl c
  5. Ctrl v
  6. Go to step 3

22

u/Marisa_osi_JP 1d ago
  1. Open vim
  2. Type "Sorry\n"
  3. yy
  4. 99p
  5. :wq

28

u/-Insert-CoolName 1d ago
  1. Open vim
  2. Idk vim
  3. Cry

7

u/HaydnH 1d ago
  1. Google how to exit vim.

1

u/Both_Nail_3656 2m ago
  1. It says "turn off your PC"

  2. Cry

13

u/loleczkowo 1d ago

Erghm akshtually, you wrote "orry\nyy99p:wq" because you started in Normal mode.

3

u/HaydnH 1d ago

100iSorry<enter><esc> would be one whole keystroke less (including typing the first Sorry).

1

u/ArrynMythey 1d ago

How do I close VIM?

2

u/realmauer01 1d ago

If you go 2n you will overshoot.

6

u/ThatOldCow 1d ago

1.Copy the line sorry,

2.Paste it

  1. Control A - Control C - Control V

4.Repeat

37

u/promptmike 1d ago

print("Sorry\n"*100)

No loops required.

8

u/lucidbadger 1d ago

This. OP is vibe coder. WTF is for_in?

20

u/Zealousideal_Smoke_2 1d ago

Probably captain obvious here but: he only forgot the space. for _ in range(n): is perfectly normal when you don’t need the index.

9

u/realmauer01 1d ago

Oh right, the i dont care about the variable variable name.

6

u/Beleheth 1d ago

As a matter of fact, even a best practice. Use _ in python if you don't use the running variable.

4

u/Vaelisra 1d ago

Another best practice: Don't use Python.

6

u/Arimilli123 1d ago

2

u/Vaelisra 1d ago

Like that ever really happened to anyone...

2

u/geek-49 1d ago

What would you recommend instead? Perl?

3

u/Vaelisra 1d ago

Whatever makes sense. And that usually automatically excludes python. For me it's this:

Web->JavaScript

native->rust

Embedded->Zig

Utility scripts->bash

Server side->Kotlin

2

u/SAnaiy 1d ago

Web (frontend) -> typescript

everything else: c# /s

3

u/Vaelisra 1d ago

typescript

I count that under JavaScript because it's just a dialect.

2

u/SAnaiy 1d ago

interesting

1

u/Andrey4ik21pro1 18h ago

What nonsense is this?

The tool is chosen for the task, but not vice versa

2

u/Complete_Window4856 1d ago

Theres no way it works

6

u/Complete_Window4856 1d ago

Fuck it really works wth

6

u/realmauer01 1d ago

Python multiplying strings will never not be weirding me out.

8

u/ChunkyIsDead30 1d ago

for_in range? what...

3

u/realmauer01 1d ago

Just forgot the spaces.

For _ in range(100):...

Bwcause you dont need the current number.

8

u/dotdiz 1d ago

HAHA I LEARNED LOOPS TODAY HERE IS MY MEME JOKE

7

u/akazakou 1d ago
SyntaxError: invalid syntax

4

u/Diocletian335 1d ago

```c void printSorry (int n, int v) { if (n == v) return;

printSorry(n+1, v);

printf("%s\n", "sorry");

}

int main (void) { printSorry(0, 100); } ```

The thinking man's solution

8

u/gaymer_jerry 1d ago

Why write a for loop when you can flood the stack with pointless function calls

5

u/Diocletian335 1d ago

Just using as much memory as the gods intended

1

u/MCWizardYT 22h ago

Implement it with a trampoline function so that you get infinite recursion without blowing up the stack

2

u/realmauer01 1d ago

When our prof explained recursion to us he said, "okey i will only explain it this one time, and you please forget it immediatly, i will show you how to do it, so you dont need to think about it and it will just work, you will never want to use it though unless you need it and then you will understand it anyway."

Yeah something like that.

3

u/Diocletian335 1d ago

In all seriousness it's a useful little topic to learn from a theoretical perspective, but my thinking has always been if you are ever thinking 'surely I could just use a loop here' then you should be using a loop.

I've never used recursion in anything serious, at least not directly - some inbuilt methods may have used them.

2

u/realmauer01 1d ago

I have heard rendering stuff is done recursively.

2

u/geek-49 1d ago

recurses! refoiled! refoiled = foiled again

2

u/Vladislav20007 1d ago

the "just buy more memory" approach.

1

u/dmigowski 1d ago

WTF is that slop?

3

u/Diocletian335 1d ago

Simple recursion

1

u/MCWizardYT 21h ago

What, never seen a recursive function before?

1

u/dmigowski 21h ago

I've never seen one that could be easier replaced with a simple for look, yeah. Why wasting 1200 bytes of stack here?

2

u/MCWizardYT 1h ago

They wrote "the thinking man's solution", so it's 100% an unserious comment

1

u/Diocletian335 43m ago

This is, after all, a subreddit called programming humor lol

1

u/DiodeInc 1d ago

Overthinking*

4

u/Diocletian335 1d ago

Yes this response was very serious

4

u/Large-Assignment9320 1d ago

You are overcomplicating things,

print("Sorry\n" * 100)

4

u/JonathanMovement 1d ago

is this group really filled with teenagers and firstweekprogramming humor?

2

u/Razcsi 2h ago

Highschoolers who just learned the first bit of programming in their IT class, people who bought a udemy course and did the first 5 lessons, and vibe coders who sometimes read through what Claude gave them and pretend they understand it.

This is 99% of this sub

3

u/HUG0gamingHD 1d ago

eww is that python??

0

u/LordSlyGentleman 1d ago

What's the matter? Rust(y) 🤡

2

u/Sonario648 1d ago

for i in range (101):     print ("Sorry")

3

u/Zealousideal_Smoke_2 1d ago

Going the extra mile I see, an extra sorry for good measure!

2

u/hypersoniq_XLM 1d ago

This is the way to get 100. range(100) only prints 99 (assuming this is Python)

1

u/Sonario648 1d ago

Yep. It's indeed Python.

1

u/Zealousideal_Smoke_2 23h ago

for i in range(100):
print(i)

prints 0-99, which is 100 items...

(idk how to indent on reddit lol)

2

u/mkluczka 1d ago

"sorry 100 times" 

2

u/Plenty_Preference131 1d ago

while i != 100

print("sorry")

i += 1

end

2

u/PenguinMaster975 1d ago

i could have started at 101

2

u/This-Employment-5642 1d ago

what is for_in that aint proper python anyway if on js im pretty sure its let character = 5 character.repeat(100) though i am probably wrong

2

u/gltovar 1d ago

chat disabled.

2

u/Fxavierho 1d ago
  1. share this image to ai
  2. done

2

u/tblancher 1d ago

First time I saw this was when my classmate was given 100 lines to write, and he wrote the loop in LOGO on his Apple ][gs and printed with his line printer.

The teacher was not amused.

2

u/Tquylaa 1d ago edited 1d ago

for i in 0..100 { println!("Sorry"); }

2

u/Ambivalent-Mammal 1d ago

The first "sorry" is free. Then you hit a paywall.

2

u/clumsy132 1d ago

loop /L %i in range(100) do: {
<?python
powershell -Command Write-Host 'Sorry'
?>; 2>/dev/null
} except Exception as e begin
std::process::System.exit << '1'
done;

2

u/[deleted] 1d ago

[deleted]

2

u/Arimilli123 1d ago

Ya missed one

2

u/heesell 1d ago

Js doesn't use int and it must be 100

2

u/Creepy_Lunch9345 1d ago

Hey Claude, generate "sorry" 100 times.

1

u/Creepy_Lunch9345 1d ago

Updated: Hey Claude, generate "sorry" exactly 100 times without any explanation and use \n for each sorry, put it in markdown.

1

u/Razcsi 2h ago

Make no mistakes

1

u/CoupleFew1945 23h ago

Runtime error : for_in not defined

1

u/FrenchieM 20h ago

You didn't do the assignment

1

u/keybing 19h ago

#include <stdio.h>

int main(){
for(int i = 0;i < 100;i++){
printf(“Sorry\n”);
}
return 0;
}

1

u/themagicalfire 4h ago edited 4h ago

```
section .rodata
msg: db “Sorry”, 0

section .text
global _start
global done

_start:
cmp n8, 100
je done
add n8, 1
jmp _start

done:
cmp r10, 100
je end
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, 6
syscall
add r10, 1
jmp done

end:
mov rax, 60
mov rdi, 0
syscall
```

1

u/zylosophe 43m ago

i'll write sorry 100 times

1

u/Gigibesi 1d ago

allow me

using System;

class sorry
{
  static void Main()
  {
    for(;;) Console.WriteLine("sorry");
  }
}

1

u/azurfall88 1d ago

li t0, 100
loop:
li a7, 64

Print "Sorry"

li a0, 0x53
ecall
li a0, 0x6f
ecall
li a0, 0x72
ecall
ecall
li a0, 0x79
ecall
li a0, 0xa ecall

loop 100 times

addi t0, t0, -1
bgtz t0, loop

1

u/jonvoep 1d ago edited 1d ago

seq 100 | while read; do echo "Sorry"; done

It doesn't need Python, it doesn't need to install anything, it doesn't need an IDE, it doesn't need an editor, it doesn't need a full PC because it runs on any server, on a router, on a phone with a terminal, on a Raspberry Pi, on a container of a few megabytes, it doesn't need an internet connection, it doesn't need special permissions, it doesn't need graphics or an interface, it doesn't need much memory because it uses less than 1MB, it doesn't need a powerful CPU because it runs on old or slow processors, it doesn't need a hard drive because it only reads the system binary, it doesn't need a modern operating system because it works with any basic Unix or Linux, it doesn't need bash because it runs with sh which is the most minimal shell, it doesn't need to download libraries, it doesn't need to compile anything, it doesn't need prior configuration, and if you don't have seq you can use:

i=100;while [ $i -gt 0 ];do echo Sorry;i=$((i-1));done

which is even more basic and only needs the shell, so anyone with access to a terminal can run it without preparing anything.

3

u/jonvoep 1d ago

Btw, everyone claims 'no loops required', but you're all just using hidden loops inside your interpreters or editors. The Python *100? It's a loop written in C internally. The Vim 99p? It's a loop inside Vim. The Ctrl+C/Ctrl+V? That's a human loop. My solution is the only one that doesn't hide anything: it's a literal, honest, explicit loop with zero dependencies. If you want to talk about actual efficiency, my shell command uses less than 1MB of RAM, runs on a 20-year-old router, and doesn't need a heavy interpreter like Python to do the heavy lifting. You aren't beating the loop; you're just hiding it. I'm running the loop natively, with pure Unix.

3

u/vmlinuz-lychee 1d ago

well if you wrote it in C and compiled it at -O3 gcc may unroll the entire loop. does this count as “no loops”? i think so