58
u/minimalniemand Jun 16 '20
when I was 6, I threw bags filled with dog poop on the neighbours balcony, so I say that's pretty amazing
24
666
u/mirandanielcz Jun 16 '20
input("nuber")
79
Jun 16 '20
Nuber -> Nude uber
39
u/shiroe314 Jun 16 '20
Boober-eats is apparently a thing. A strip club started doing an uber eats delivery service. So... its uber eats but with stripers.
5
319
u/Starkiller3590 Jun 16 '20
This moment when 6-year-old is coding better than yandere-dev
78
u/Dr_Insano_MD Jun 16 '20
Give Yandere-dev a break. He has to spend up to 10 hours per day reading emails! He has no time to code!
9
1
130
Jun 16 '20
[removed] — view removed comment
12
u/Laughing_Orange Jun 17 '20
I'm pretty sure the 6 year old didn't take 6 years to implement the first major feature.
88
u/EveningAioli Jun 16 '20
Looks like Yandere Dev's code.
21
Jun 16 '20
Had no idea who he is so i googled him.
„While making yandere simulator he was inspired by games like hitman....”
what lmao
69
u/luizpericolo Jun 16 '20
Now write a program that writes this program up to 1000000.
10
u/general_dubious Jun 16 '20
Easy, you just write the program up to that value and put it in a print statement.
2
u/ZILtoid1991 Jun 17 '20
Or use some language's meta programming features. D probably could do something like that with its
static foreachfeature, which I've used in the past to unroll short iterations to test whether it would be helpful in time critical stuff.
41
u/KJting98 Jun 16 '20
This reminds me of this Chinese joke about teaching kids how to write numbers. So it goes one is 一, two is 二, three is 三, kid decides 'that's easy pattern, I know what to do now' and falls asleep, wakes up to assignement of writing three-hundred and thirty-three, and writes 333 horizontal strokes.
15
15
u/JustMadMax Jun 16 '20
Ahhh, it brought me back memories when as I child I truly believed that someone somewhere has calculated every single mathematical expression by hand and put it in calculator's memory
8
u/Jussari Jun 17 '20
I thought that video games worked with the developers creating every possible frame by hand and coding "if frame #2462819 and player presses up, switch to frame #471995278" etc
4
1
u/MathSciElec Jun 16 '20
Oh, my. Now I wonder how much memory that would take, but it’s late... I’ll do the math tomorrow.
4
u/JustMadMax Jun 17 '20 edited Jun 17 '20
So I actually did the math.(using pen and paper of course)
Let's assume that we have an 8-digit calculator. To start off we have 108 integers. Then we have 9x107 x7 floating point numbers. 9x107 is because we don't want our least significant digit to be zero as this way we will have duplicates, e.g. 0007.89 = 007.890. And, assuming we have an eight-digit display, there are 7 places to put our decimal separator, so there comes our x7 part. So, in total we have 108 + 6.3x108 = 7.3x108 different numbers for the left side of equation. Lastly we need to count for the minus sign, which increases total numbers count by 2. Then we have 4 mathematical operations to choose from and other 14.6x108 numbers. This totals to around 8.4*1018 different expressions which is huuge number already.
Then we come to the question of storage. If we would want to store everything in text form, which you definitely should not do(but come on if you believe that every expression was precalculated, you definitely wouldn't know about number representation in computing), you would need to add an equals sign and allocate some space for the result, however this is where we encounter some problems, as the result of an expression may be longer than eight characters long. Actually, I couldn't find any calculator in my house to study their behaviour, so I'll assume that we need 8 characters as well. And the total is, assuming we use 1-byte characters, 26x8.4x1018 B = 218.4 EB while according to statista.com global data storage size is over 2000 EB now.
However if you were some kind of weirdo who knows how to store decimal numbers efficiently you would need 4+1+4+4 bytes per expression, assuming you calculator uses 4 bytes per decimal and 1 to store the operation sign. That would total to 13 bytes per expression, exactly two times less data than for raw text and it gets better the more digits your calculator can display.
Thanks for reading and hopefully you'll sleep tighter tonight)
EDIT: had to change asteriscks for x's for formatting reasons
0
3
12
8
u/luizpericolo Jun 16 '20
When I was learning to program we were assigned a task to print out any number provided (up to 10000) in written form.
That code was total rubbish. Then the teacher went on to explain the mod operator. Intro to programming was in Pascal.
1
6
11
u/005eelmarag Jun 16 '20
return num % 2 == 0 just in case someone else needed to know
Still impressive for 6 year old
10
u/CakeFromTheFuture Jun 16 '20
Lmao who would use such an unoptimized method when op posted the right way to do it
5
5
4
Jun 16 '20
Not overly atrocious at all for a 6 year old. One thing I realized is that there’s many ways to do things, and always someone that’ll find a way to do it better than you, though better doesn’t necessarily mean improved functionality, adaptability, or scope.
I highly doubt when we were six, we were thinking “Yeah, insert 1-10 into an array, then iterate through it while testing IsEven function against int data type, then use a switch condition to print string even or odd.”
4
10
u/Hi-I-am-Dad Jun 16 '20
return number & 1 ? "odd" : "even"
6
u/xdfreddie Jun 16 '20
&
is using a bitwise operator faster than using a modulo or remainder operator for this purpose?
12
u/Poddster Jun 16 '20
In most languages the compiler should convert both
& 1 == 0and% 2 == 0to the same thing. If it doesn't then you shouldn't really be using that language/compiler to make "fast" things.Well, assuming the number is an integer.
2
2
2
2
Jun 16 '20
To be fair, I dont think most 6 year olds know the kind of math related problem solving skills you need for this type of program. At least not in the United States.
2
2
2
2
u/geriBatai Jun 16 '20
As it happens, I have a six year old. Believe me, this code is absolutely fine.
2
2
1
1
1
1
1
Jun 16 '20
At 6 I was struggling to win against Gym Leader Whitney's Miltank in Pokemon Silver. Didn't even know wtf code was. That's impressive.
1
1
1
1
1
1
1
1
1
1
1
1
1
u/elizaangela Jun 28 '20
This actually hurts my soul to look at but hey, you were on the right track when you were 6, haha.
1
1
1
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Sep 08 '20
Image Transcription: Code
number = input("nuber")
if number == "0":
print("even")
if number == "1":
print("odd")
if number == "2":
print("even")
if number == "3":
print("odd")
if number == "4":
print("even")
if number == "5":
print("odd")
if number == "6":
print("even")
if number == "7":
print("odd")
if number == "8":
print("even")
if number == "9":
print("odd")
if number == "10":
print("even")
if number == "11":
print("odd")
if number == "12":
print("even")
if number == "13":
print("odd")
if number == "14":
print("even")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
0
Jun 17 '20
int count = 0;
for(int x = input; x > 0; x--)
Count++;
if(count % 2 == 0)
Return "Even";
Else
Return "Odd";
0
-1
u/MassiveFajiit Jun 17 '20 edited Jun 17 '20
for i in range(1000000):
str_num = str(i)
if i % 2 == 1:
print(f"if number == '{str_num}':\n\tprint('odd')")
else:
print(f"if number == '{str_num}':\n\tprint('even')")
0
Jun 16 '20
[deleted]
24
u/KxJlib Jun 16 '20
15
6
u/michaelboobley Jun 17 '20
You'll be great kid. The acid of our own mistakes washes away failures thatll make you great.
0
Jun 16 '20
[deleted]
51
3
Jun 16 '20
this isnt faster than % 2 == 0 right
4
u/1cec0ld Jun 16 '20
Well if the input is 0, it might be.
It has to do the modulo operation, THEN check equivalence. That's 2 steps, where number == 0 is just 1.
But then it keeps going, checking if the number is everything else below that. So it depends on what you mean by "faster"
Response time, or execution time?
1
0
Jun 16 '20
[deleted]
9
u/MathSciElec Jun 16 '20
Version 0.1: initial version. Release date: 12/05/2011.
Version 0.1, patch 26: numbers up to 200 are now supported. Release date: 12/06/2011.
Version 0.1.1: numbers up to 10000 are now supported. Minor bug fixes. Release date: 16/06/2012.
Version 0.2: all natural numbers are now supported. Release date: 01/01/(-1/12)
0
335
u/[deleted] Jun 16 '20
For a six year old that's not overly atrocious