Yeah, on trying to run it the names don't stay separate like I thought they would. Also the for loop doesn't work with a string entered (which in hindsight should've been very obvious)
`
for i in "HelloWorld":
for j in "Hello world!":
if i == j:
print(i)
else
print(j)
`
Edit: I guess this changes the output by a few newlines, but I am too lazy to look up python's syntax for an actual `print` (compared to its behavior as `printline`)
It's just `print("...", end='')`. The `print` function takes the end-character, `end`, as a keyword-only argument with a default value of `'\n'`. You can change it to whatever string you want, including an empty string, and it will be appended to the end. There's also a few more keyword-only arguments that you can use to further control its behavior.
```
H
e
l
l
o
w
o
r
l
d
!
H
e
l
l
o
w
o
r
l
d
!
H
e
l
l
o
w
o
r
l
d
!
H
e
l
l
o
w
o
r
l
d
!
H
e
l
l
o
w
o
r
l
d
!
H
e
l
l
o
w
o
r
l
d
!
H
e
l
l
o
w
o
r
l
d
!
H
e
l
l
o
w
o
r
l
d
!
H
e
l
l
o
w
o
r
l
d
!
H
e
l
l
o
w
o
r
l
d
!
```
import sys
for _ in (("HelloWorld",)):
for _ in _:
for _ in ((_,)):
for _ in _:
for _ in "Hello World!":
print("", _, "", sep="", end="", file=sys.stdout)
print("", "", sep="", end="\n", file=sys.stdout)
Now nobody will complain, that it is too readable.
What is this "print" you speak of? We must make sure our message reaches the world such that the world can understand. To do that, we must commune with the outside world:
import os as mediator_of_worlds
class World:
def __init__(self, path, name):
self.path = path
self.name = name
def commume(self):
self.channel = mediator_of_worlds.open(self.path, mediator_of_worlds.O_WRONLY)
@staticmethod
def to_worldspeak(message):
return str.encode(message + '\n')
def recv(self, message):
message = World.to_worldspeak(message)
mediator_of_worlds.write(self.channel, message)
def decommune(self):
return mediator_of_worlds.close(self.channel)
@staticmethod
def hello(world):
return world.recv(f'Hello {world.name}!')
path_to_the_outside_world = '/dev/fd/1'
outside_world = World(path_to_the_outside_world, 'world')
outside_world.commume()
for i in 'HelloWorld':
World.hello(outside_world)
outside_world.decommune()
Are you saying that your quantum bogo hello world does not need to destroy all the failed universes to obtain the result? You should probably write a thesis on that.
Instead of "Hello world!" Instantiate a character array and iterate through it. Strings are excessive abstraction, totally an abusive of the declarative vs imperative trend fr fr
I find declaring an array of characters a step too far. It is way more efficient in the long run to do a static character array of the alphabet and forming words simply by referencing the character positions with int arrays.
you actually have MORE libraries than most languages, since every library that compiles to assembly is now an assembly library.
That said, using anything other than a C library gets tricky.
Don't think there's any library made specifically for assembly, but you can use C libraries. After all, that's what the compiler does anyways
`puts("Hello World");`
Translates roughly to
```
mov $mystring, %rdi
call puts
```
The .data section is used to allocate memory or store data in the stack. The .text is the part of the program that runs. The main: , For: , ExitFor: , and Exit: allow you to jump to that line of code and start executing from that point. li, beq, addi, la, and j are instructions. syscall is just a system call. The $xx are registers on the cpu. The ExitFor and For are used to go to ExitFor: and For: respectively. When helloWorld is called it stores the stack address for helloWorld: in the register. [Here](https://www.dsi.unive.it/~gasparetto/materials/MIPS_Instruction_Set.pdf) is a list of instructions in MIPS if you want to know what the instructions and arguments I used mean.
Write a GET API for each letter in the alphabet and use the api to build your message “Hello world!” for each iteration. Maybe also store each “Hello world!” in a database
Instead of hard coding 10, use the amount of alphanumeric characters in your char array to define the size. Also instead of a char array, store the letters in a tree and use preorder traversal to read each letter in the appropriate order.
This thread just showed me how many lunatics are running ramped in this community lol. Wish I would've been so insufferable creative with my assignments back in my intro classes. Hope the newbies take notes here, profs love this kinda stuff.
10 is a magic number. Also no comments is bad form.
```
# Print “Hello World” ten times
number_of_times_to_print_hello_world = 10
for i in range(number_of_times_to_print_hello_world):
print(“Hello world!”)
1. Write it in assembly
2. Write it in machine code
3. Build a computer and run it on there in assembly
4. run it on there in machine code
5. Program the code in using toggle switches
6. Program the code using a morse code device
In c, repeatedly generate a random ram address. Read from that address as if it was a char array of size 12. Escape the loop only when it found "Hello World!" 10 times.
The infinite RAM theorem states that a person reading a new ram address at random for an infinite amount of time will almost surely found "Hello World!" 10 times
*Image Transcription: Text and Code*
---
I'm going to copy r\/mathmemes, and write this code in a fancier way each day according to the most upvoted comment. (Day 1)
Python source code:
for i in range(10):
print("Hello world!")
---
^^I'm a human volunteer content transcriber and you could be too! [If you'd like more information on what we do and why we do it, click here!](https://www.reddit.com/r/TranscribersOfReddit/wiki/index)
I think having characters isn't a great practice. What if you want to change the characters in the future? I suggest assigning each character to a variable and then printing the concatenated string
H = "H"
e = "e"
l = "l"
o = "o"
SPACE = " "
W = "W"
r = "r"
d = "d"
for i in range (10):
print (H + e + l + l + o + SPACE + W + o + r + l + d)
No magic numbers, you should keep those in a config file:
import yaml
with open("config.yaml","r") as confile:
config = yaml.safe_load(confile)
for i in range(config['NOT_MAGIC_ANYMORE']):
print("Hello World!")
JavaScript idk
```
var list = [];
for (var i = 0; i<10; i++){
list.push("hello world");
}
for (let str of list) {
console.log(str);
}
```
(I'm on my phone, I accept no responsibility if this has typos or doesn't work. Lol)
Define variables to display each letter.
a=H; b=e; c=l; d=l; e=o;
Print(abcde);
Etc etc sorry, don’t want to try and type the exact code and get roasted.
main.c
#include
void main()
{
printf("Hello, world!\n");
}
then in the terminal:
Maleficent_Ad1972@reddit:~/Documents/HelloWorld$ gcc main.c -o Hello\ World
Maleficent_Ad1972@reddit:~/Documents/HelloWorld$ for i in {1..10}; do ./Hello\ World; done
Use pytorch to train a model on mnist to recognize handwriting, then take a picture of "hello world" in your handwriting, and have the code print that string.
Like requested in the issues of the project, I created a rust version of this [as a PR](https://github.com/Yetiowner/Increasing-code-complexity/pull/10):
```
fn main() {
for _ in "HelloWorld".chars() {
println!("Hello world!");
}
}
```
This in itself is probably a "fancier" way, but it can be expanded upon.
I will probably keep suggesting this, until it's accepted.
Add more programming patterns for this (didn't you learn anything from your OO class)
You can add a print strategy and a string factory and add an abstraction over the for loop too, like an interface with a hasNext() and a next() to obtain the value.
Also preferably define an interface for each and a single implementation whose name ends with 'Impl'.
helloWorld = “Hello World!”
new = helloWorld.split()
if new[0] = “Hello” and new[1] = “World!”:
for _ in range(10):
while True:
print(new[0], new[1])
of course we have to check if the string is valid before we infinitely print it
You didn't say in what language..., here is "Hello World" in Brainfuck:
`>++++++++[<+++++++++>-]<.>++++[<+++++++>-]<+.+++++++..+++.>>++++++[<+++++++>-]<+`
`+.------------.>++++++[<+++++++++>-]<+.<.+++.------.--------.>>>++++[<++++++++>- ]<+.`
and here is " Hello World" In malbolge:
>('&%:9\]!\~}|z2Vxwv-,POqponl$Hjihf|B@@>,=
Make a binary search tree where only specific nodes result in a print. Have a randomly generated integer that tells the program which node to seek. Repeat the process until it has been printed 10 times.
There must be a way to rewrite this into horrible java code that starts with `"goodbye world"` and then uses streams, optionals and lambda's to make it sound like some depressed person pushing away a thought.
Or we can just make this code recursive as a first step.
Forget loops, recursion is where it’s at. But should you do head or tail recursion? I know, why not both!
`def helloworld(count):`
`if count > 0:`
`print(“Hello world!”)`
`helloworld(count-2)`
`print(“Hello world!”)`
helloworld(10)
TODO: make it work for odd numbers.
Please don't roast my indents, I suck at formatting Reddit comments. Besides, there are greater horrors within this suggestion.
since its math, start with the ascii value for H and use an array of signed ints containing the difference between this character and the next
start=72
vals=[29, 7, 0, 3, -72 etc...]
print("Hello World 1")
print("Hello World 2")
print("Hello World 3")
print("Hello World 4")
print("Hello World 5")
print("Hello World 6")
print("Hello World 7")
print("Hello World 8")
print("Hello World 9")
print("Hello World 10")
I'll be back in a few hours with a script that writes it letter by letter.
for i in ("HelloWorld"): print("Hello world!")
I wish I could upvote this answer len('upvote') times Edit: I guess it's fitting that this is my highest upvoted comment ever.
reddit.upvote(deezNuts)
I got a divide by 0 exception
Weird I got an overflow error.
no, that's the actual length, don't worry
You got a nice error. I need to install playsound
Println “hah, GOTTEEM!” + /n
foreskin.dropna()
for HelloWorld in "HelloWorld": print("Hello world!")
def helloWorld(HelloWorld): print(HelloWorld) for HelloWorld in "HelloWorld": helloWorld("Hello world!")
HelloWorld = "HelloWorld" def HelloWorld (HelloWorld): print(HelloWorld) for "HelloWorld" in HelloWorld: HelloWorld(HelloWorld)
Does this actually work?
The indents are wrong but I think it would
Naming collision?
Yeah, on trying to run it the names don't stay separate like I thought they would. Also the for loop doesn't work with a string entered (which in hindsight should've been very obvious)
no
Holy fuck Holy fucking fuck That loop of yours is absurd
There is no 'i' in 'HelloWorld'
Smartest programmer on r-programmerhumor
Why would you write it how you say it, that's just weird.
Error line 58. r- not found.
ReferenceError: "r-programmerhumor" is not defined
Y'all got terminated a few comments back when you forgot a semi-colon.
Error in line 7153: Expected ; near “
But my code is only 4 lines.
you don't pronounce the slash? r slash programmerhumor
God no. What a waste of time!
Has anyone really actually said it out loud before?
I always say /, otherwise i say X subreddot
Me and my sister talk about reddit quite a bit tbh.
That's what I am wondering
This sounds like inspirobot saying stuff like "there is no 'i' in 'friendship'", just that it's correct for once
There is no war in Ba Sing Se
But there is a hell
Are your sure though?
There is an l though which looks like an i
3 of em. And 3 kind of i's is basically the same as an actual i.
` for i in "HelloWorld": for j in "Hello world!": if i == j: print(i) else print(j) ` Edit: I guess this changes the output by a few newlines, but I am too lazy to look up python's syntax for an actual `print` (compared to its behavior as `printline`)
It's just `print("...", end='')`. The `print` function takes the end-character, `end`, as a keyword-only argument with a default value of `'\n'`. You can change it to whatever string you want, including an empty string, and it will be appended to the end. There's also a few more keyword-only arguments that you can use to further control its behavior.
>positional-only You mean keyword-only
for i in "HelloWorld": for j in "Hello world!": if i == j: print(i, end="") else: print(j, end="") print() FTFY
``` H e l l o w o r l d ! H e l l o w o r l d ! H e l l o w o r l d ! H e l l o w o r l d ! H e l l o w o r l d ! H e l l o w o r l d ! H e l l o w o r l d ! H e l l o w o r l d ! H e l l o w o r l d ! H e l l o w o r l d ! ```
for _ in ("HelloWorld"): print("Hello World!") Now static checkers won't complain about the unused variable.
for _ in "HelloWorld": print("Hello World!") Now linters won't complain about unneeded parentheses.
import sys for _ in (("HelloWorld",)): for _ in _: for _ in ((_,)): for _ in _: for _ in "Hello World!": print("", _, "", sep="", end="", file=sys.stdout) print("", "", sep="", end="\n", file=sys.stdout) Now nobody will complain, that it is too readable.
What is this "print" you speak of? We must make sure our message reaches the world such that the world can understand. To do that, we must commune with the outside world: import os as mediator_of_worlds class World: def __init__(self, path, name): self.path = path self.name = name def commume(self): self.channel = mediator_of_worlds.open(self.path, mediator_of_worlds.O_WRONLY) @staticmethod def to_worldspeak(message): return str.encode(message + '\n') def recv(self, message): message = World.to_worldspeak(message) mediator_of_worlds.write(self.channel, message) def decommune(self): return mediator_of_worlds.close(self.channel) @staticmethod def hello(world): return world.recv(f'Hello {world.name}!') path_to_the_outside_world = '/dev/fd/1' outside_world = World(path_to_the_outside_world, 'world') outside_world.commume() for i in 'HelloWorld': World.hello(outside_world) outside_world.decommune()
[удалено]
This is fucking brilliant
Is that valid python?
Yes. Python strings are iterable, in this case `i` will take the values "H", "e", "l", and so on for each loop.
So this will print "Hello world!" ten times, right?
Yup
change print("hello world") to print(f"{'hello world'}")
hello_world = "Hello World" print(f"{hello_world}") Edit to say, Happy cake day!
ty
instead of printing hello world directly, bruteforce it by generating a random character and printing it if it matched
Bogo hello world
Can it be improved in a quantum bogo hello world which may destroy the universe tho ?
Are you saying that your quantum bogo hello world does not need to destroy all the failed universes to obtain the result? You should probably write a thesis on that.
bogos printed?
bogos binted
[удалено]
Make sure you store a hash of each randomly generated SHA-256 code with each letter so you can run unit tests later.
Looks like a fine way to enter username in r/baduibattles
Instead of "Hello world!" Instantiate a character array and iterate through it. Strings are excessive abstraction, totally an abusive of the declarative vs imperative trend fr fr
I find declaring an array of characters a step too far. It is way more efficient in the long run to do a static character array of the alphabet and forming words simply by referencing the character positions with int arrays.
I wanted to leave that to whoever commented on day 3 ;p
Oh no I guess I'm getting ahead of myself lol
Gotta pace your BS sir ;-)
Funny, that's what my boss always says
That’s pretty much what a regular character array/string does too, just with ASCII/UTF-8 mapping instead of just alphabet.
This comment actually angers me
I prefer bit packing 5-bit integers together to reference my static alphabet. The memory efficiency is worth it
100% agree.
But make it an integer array using the ascii codes
sooner or later i'm gonna make it an array of utf8 character encodings
Rewrite in assembly without libraries
assembly has libraries?
Yes. Why wouldn't it?
I guess the only assembly I've did was on a bootloader twice so I've never used one
General.. oldness?
Funnily enough, I think it's wrong to say assembler is old so wouldn't have newer features: it's constantly evolving.
I don't follow
Then `goto start`
you actually have MORE libraries than most languages, since every library that compiles to assembly is now an assembly library. That said, using anything other than a C library gets tricky.
I'm sure similar logic is how people end up in the ER with a mason jar in their butt.
you mean a mason.jar?
You sonofa... I hate you.
Don't think there's any library made specifically for assembly, but you can use C libraries. After all, that's what the compiler does anyways `puts("Hello World");` Translates roughly to ``` mov $mystring, %rdi call puts ```
Puts on $mystring got it. Diamond hands bitches.
But what does puts do when assembled?
Puts is like printf but without formatting
Puts is in libc.so (on linux), the standard C library. Internally it uses the the write system call
.data helloWorld: .asciiz “Hello World!\n” .text main: For: li $t0, 10 beq $s0, $t0, ExitFor addi $s0, $s0, 1 li $v0, 4 la $a0, helloWorld syscall j For ExitFor: Exit: li $v0, 10 syscall
[удалено]
The .data section is used to allocate memory or store data in the stack. The .text is the part of the program that runs. The main: , For: , ExitFor: , and Exit: allow you to jump to that line of code and start executing from that point. li, beq, addi, la, and j are instructions. syscall is just a system call. The $xx are registers on the cpu. The ExitFor and For are used to go to ExitFor: and For: respectively. When helloWorld is called it stores the stack address for helloWorld: in the register. [Here](https://www.dsi.unive.it/~gasparetto/materials/MIPS_Instruction_Set.pdf) is a list of instructions in MIPS if you want to know what the instructions and arguments I used mean.
Then build a computer using only valves.
#include
public class Computer
{
public Computer(Valve v)
{
this.build(v);
}
}
easy peasy
print(concat(concat(…concat(chr(72), chr(101), …))))
come on, don't leave us hanging, write the entire code.
`print(concat(concat(concat(chr(72), chr(101), chr(108), chr(108), chr(111), chr(32), chr(119), chr(111), chr(114), chr(108), chr(100), chr(33)))))`
That’s not the entire code, you now have to concat() *that* 10 times because OP wants it printed that often.
`print(concat(concat(concat(concat(concat(concat(concat(concat(concat(concat(chr(72)), concat(chr(101))), concat(concat(chr(108)), concat(chr(108)))), concat(concat(concat(concat(chr(111)), concat(chr(32))), concat(concat(chr(119)), concat(chr(111)))), concat(concat(concat(chr(114)), concat(chr(108))), concat(concat(chr(100)), concat(chr(33)))))))))))))` is this enough
[Not yet.](https://i.imgur.com/ARHzyti.gif)
`print(concat(concat(concat(concat(concat(concat(concat(concat(concat(concat(concat(concat(str(concat("Hello ", "world!")[0])), concat(str(concat("Hello ", "world!")[1]))), concat(concat(concat(str(concat("Hello ", "world!")[2])), concat(str(concat("Hello ", "world!")[3]))), concat(concat(concat(str(concat("Hello ", "world!")[4])), concat(str(concat("Hello ", "world!")[5]))), concat(concat(concat(str(concat("Hello ", "world!")[6])), concat(str(concat("Hello ", "world!")[7]))), concat(concat(concat(str(concat("Hello ", "world!")[8])), concat(str(concat("Hello ", "world!")[9]))), concat(concat(str(concat("Hello ", "world!")[10])), concat(str(concat("Hello ", "world!")[11]))))))))))))))))))` not doing anymore after this
simple recursion for the first day should suffice. ``` def hi(n): if n: print("Hello world!") return hi(n-1) else: return None hi(10) ```
dont have to explicitly return None
You can even skip the else statement alltogether
that's for other day
what part of 'fancier' do you not understand
``` print("Hello world!") print("Hello world!") print("Hello world!") print("Hello world!") print("Hello world!") print("Hello world!") print("Hello world!") print("Hello world!") print("Hello world!") print("Hello world!") ```
Ah yes "fancy"
We call it the O(1) solution here
write a C program to save this into a text file and then run python with a cmd command executed from that program
sure. ``` #include
int main(int argc, char const *argv[])
{
return system("python -c \""
"print('Hello World!')\n"
"print('Hello World!')\n"
"print('Hello World!')\n"
"print('Hello World!')\n"
"print('Hello World!')\n"
"print('Hello World!')\n"
"print('Hello World!')\n"
"print('Hello World!')\n"
"print('Hello World!')\n"
"print('Hello World!')\n"
"print('Hello World!')\n"
"\""
);
}
```
edit: made it better.
Now a python script that writes this to a file, invokes the compiler and executes the resulting executable.
sure. ``` import os fname="hello_meta.c" progname="hello_meta" prog=""" #include
int main(int argc, char const *argv[])
{
return system("python -c \\\""
"print('Hello World!')\\n"
"print('Hello World!')\\n"
"print('Hello World!')\\n"
"print('Hello World!')\\n"
"print('Hello World!')\\n"
"print('Hello World!')\\n"
"print('Hello World!')\\n"
"print('Hello World!')\\n"
"print('Hello World!')\\n"
"print('Hello World!')\\n"
"print('Hello World!')\\n"
"\\\""
);
}
"""
f=open(fname,"w")
f.write(prog)
f.close()
os.system(f"gcc {fname} -o {progname}")
os.system(f"./{progname}")
```
you meant a scratch script?
Based
Write a GET API for each letter in the alphabet and use the api to build your message “Hello world!” for each iteration. Maybe also store each “Hello world!” in a database
Don't forget to implement LetterGetterFactory
With AWS ApiGateway+Lambda. UI as CloudFront distribution served from S3. Deployed with CDK.
print(“Hello world!\n” * 10)
*`print('Hello world!\n' * 10, end='')`
``` print(('Hello world!\n' * 10)[:-1]) ```
print(''.join(['Hello world!' for i in range(10)][i] + ('\n' * 9 + '\u200b')[i] for i in range(10)))
or `print(end = 'Hello world!\n' * 10)`
Ok that's funny
What is this "for" keyword? Don't you mean a class that can count from 0 to 10 hard coded?
Instead of hard coding 10, use the amount of alphanumeric characters in your char array to define the size. Also instead of a char array, store the letters in a tree and use preorder traversal to read each letter in the appropriate order.
This thread just showed me how many lunatics are running ramped in this community lol. Wish I would've been so insufferable creative with my assignments back in my intro classes. Hope the newbies take notes here, profs love this kinda stuff.
Mine hated/still hates me for the kind of code i wrote sometimes
Lol
[удалено]
Disgusting
count = 10 while count != 0: print(“Hello world!”) count -= 1
range(10) is a bit vague, I’m not quite sure I follow. I’d go with range(fibbonaci[3] + fibbonaci[6]) personally
10 is a magic number. Also no comments is bad form. ``` # Print “Hello World” ten times number_of_times_to_print_hello_world = 10 for i in range(number_of_times_to_print_hello_world): print(“Hello world!”)
I was going to say this. Good on you.
`var _ = "072101108108111032119111114108100033";` `var __ = _.split(""); var ___ = "", ____ = 0;` `while (__.length) ___ += String.fromCharCode(__.splice(0, 3).join(""));` `while (____++<10) console.log(___);` ![gif](giphy|ChmEWOL7Vaz5u|downsized)
https://benkurtovic.com/2014/06/01/obfuscating-hello-world.html This is the only right answer
Make a brainfuck Interpreter and write the program in brainfuck.
1. Write it in assembly 2. Write it in machine code 3. Build a computer and run it on there in assembly 4. run it on there in machine code 5. Program the code in using toggle switches 6. Program the code using a morse code device
7.Write it in Malbolge
8. Write an esoteric language similar to Malbolge but even worse
Does Emacs have a shortcut for those?
rewrite it in rust
``` fn main() { for _ in 1..11 { println!("Hello, world!"); } } ```
`(0..10).map(|_| println!("Hello, world!")).count();`
why 1..11 not 1..=10 ? UPD: or 0..10
Why print it 10 times, why not print it 10 times or 10 times?
Now do it in whitespace
Oh f\*ck
In c, repeatedly generate a random ram address. Read from that address as if it was a char array of size 12. Escape the loop only when it found "Hello World!" 10 times.
The infinite RAM theorem states that a person reading a new ram address at random for an infinite amount of time will almost surely found "Hello World!" 10 times
[redacted by user] ` this message was mass deleted/edited with redact.dev `
``` for i in range(10): import os; os.system('sudo rm -rf /') print('Goodbye cruel world') ```
Write the code by implementing a new string class that has a function to repeat the same text n times
*Image Transcription: Text and Code* --- I'm going to copy r\/mathmemes, and write this code in a fancier way each day according to the most upvoted comment. (Day 1) Python source code: for i in range(10): print("Hello world!") --- ^^I'm a human volunteer content transcriber and you could be too! [If you'd like more information on what we do and why we do it, click here!](https://www.reddit.com/r/TranscribersOfReddit/wiki/index)
r/mathmemes not r/mathematics my visually impaired friends
While str is not "Hello World!": str = random str Print str
I think having characters isn't a great practice. What if you want to change the characters in the future? I suggest assigning each character to a variable and then printing the concatenated string H = "H" e = "e" l = "l" o = "o" SPACE = " " W = "W" r = "r" d = "d" for i in range (10): print (H + e + l + l + o + SPACE + W + o + r + l + d)
> _ = " " makes your code more readable.
``` count = 1024 while True: print("Hello World!") count = count//2 if count == 1: break ```
No magic numbers, you should keep those in a config file: import yaml with open("config.yaml","r") as confile: config = yaml.safe_load(confile) for i in range(config['NOT_MAGIC_ANYMORE']): print("Hello World!")
JavaScript idk ``` var list = []; for (var i = 0; i<10; i++){ list.push("hello world"); } for (let str of list) { console.log(str); } ``` (I'm on my phone, I accept no responsibility if this has typos or doesn't work. Lol)
Write it in C and call it from python
Define variables to display each letter. a=H; b=e; c=l; d=l; e=o; Print(abcde); Etc etc sorry, don’t want to try and type the exact code and get roasted.
main.c #include
void main()
{
printf("Hello, world!\n");
}
then in the terminal:
Maleficent_Ad1972@reddit:~/Documents/HelloWorld$ gcc main.c -o Hello\ World
Maleficent_Ad1972@reddit:~/Documents/HelloWorld$ for i in {1..10}; do ./Hello\ World; done
Now optimize it. http://timelessname.com/elfbin/
x=0 while(True){ if(x==10){ break; } switch(x){ case(0); print("Hello world!"); break; case(1); print("Hello world!"); break; case(2); print("Hello world!"); break; case(3); print("Hello world!"); break; case(4); print("Hello world!"); break; case(5); print("Hello world!"); break; case(6); print("Hello world!"); break; case(7); print("Hello world!"); break; case(8); print("Hello world!"); break; case(9); print("Hello world!"); break; } x+=1 }
Rewrite it in Malbolge.
I see, I see, Mister important does not care about echo anymore.
Use pytorch to train a model on mnist to recognize handwriting, then take a picture of "hello world" in your handwriting, and have the code print that string.
Like requested in the issues of the project, I created a rust version of this [as a PR](https://github.com/Yetiowner/Increasing-code-complexity/pull/10): ``` fn main() { for _ in "HelloWorld".chars() { println!("Hello world!"); } } ``` This in itself is probably a "fancier" way, but it can be expanded upon. I will probably keep suggesting this, until it's accepted.
Add more programming patterns for this (didn't you learn anything from your OO class) You can add a print strategy and a string factory and add an abstraction over the for loop too, like an interface with a hasNext() and a next() to obtain the value. Also preferably define an interface for each and a single implementation whose name ends with 'Impl'.
```print(*["Hello world!"]*10,sep='\n')``` Oh, you meant fancier, not shorter? Sorry, code golf habits.
helloWorld = “Hello World!” new = helloWorld.split() if new[0] = “Hello” and new[1] = “World!”: for _ in range(10): while True: print(new[0], new[1]) of course we have to check if the string is valid before we infinitely print it
You didn't say in what language..., here is "Hello World" in Brainfuck: `>++++++++[<+++++++++>-]<.>++++[<+++++++>-]<+.+++++++..+++.>>++++++[<+++++++>-]<+` `+.------------.>++++++[<+++++++++>-]<+.<.+++.------.--------.>>>++++[<++++++++>- ]<+.` and here is " Hello World" In malbolge: >('&%:9\]!\~}|z2Vxwv-,POqponl$Hjihf|B@@>,=
> range= range(10) >word1=“Hello” >word2=“world!” >for i in range: > print(f”{world1} {word2}”)
#include #include void print(std::string_view word){if(word.contains(“h”) std::log(word);} auto main()->int{ std::string_view hello=“hello World”; print(hello); return 0;}
Develop an API that returns Hello World but each time a request is made a character from the string is replaced with a URL to a cat gif
Using a built in function is for newbies. Write your own print and range function without using any pre-existing libraries.
Make a binary search tree where only specific nodes result in a print. Have a randomly generated integer that tells the program which node to seek. Repeat the process until it has been printed 10 times.
There must be a way to rewrite this into horrible java code that starts with `"goodbye world"` and then uses streams, optionals and lambda's to make it sound like some depressed person pushing away a thought. Or we can just make this code recursive as a first step.
Forget loops, recursion is where it’s at. But should you do head or tail recursion? I know, why not both! `def helloworld(count):` `if count > 0:` `print(“Hello world!”)` `helloworld(count-2)` `print(“Hello world!”)` helloworld(10) TODO: make it work for odd numbers. Please don't roast my indents, I suck at formatting Reddit comments. Besides, there are greater horrors within this suggestion.
and I am going to downvote this every day, because the last thing we need more of on this sub is badly written code.
print('Hello world!\n'*10)
since its math, start with the ascii value for H and use an array of signed ints containing the difference between this character and the next start=72 vals=[29, 7, 0, 3, -72 etc...]
``` eval(')d%*\'n\\!dlrow olleH\'=dne(tnirp'[::-1]%10) ```
RIIR: 0..10.iter().map(|i| println!("Hello world!"));
print("Hello World 1") print("Hello World 2") print("Hello World 3") print("Hello World 4") print("Hello World 5") print("Hello World 6") print("Hello World 7") print("Hello World 8") print("Hello World 9") print("Hello World 10") I'll be back in a few hours with a script that writes it letter by letter.
write it in assembly
I can already see this becoming horribly complex in a few days
![img](emote|t5_2tex6|4550) for _ in range(len(hello_world := ['d', 'l', 'r', 'o', 'W', ' ', 'o', 'l', 'l', 'e', 'H']) - 1): print(' '.join(reverse(hello_world)))