r/code • u/bbtta85 • Jul 29 '16
Help Please Please help! Need code to announce our pregnancy to my programmer boyfriend... <3
Hi all, my boyfriend is a Senior Software Engineer... I just found out that we are expecting, and I'd love to break the news to him with a block of code! Trouble is, I don't code... Would you all help me write a small block of code to let him know he's going to be a daddy? TIA!
1.3k
Upvotes
View all comments
Show parent comment
40
u/BACON8000 Sep 04 '16
It's not as complicated as it sounds to be honest. You just have to interpret it in your brain and it's quite simple, simple enough to write in a Costa Coffee carpark with a crying baby in the back of the car.
So, to begin with, brainfuck uses pointers and values. A pointer is like saying which particular value are we working with, and the value is the actual...you know...value of that particular pointer.
>and<move your "current pointer" up and down, or left and right, however you like to see it.+and-increment/decrement the value of that pointer (default is 0)..prints the current value out as ASCII.So, first I initialise the first pointer to 32, the ASCII for space (for later):
+++++++++++++++++++++++++++++++.Then I move to the next pointer
>and increment it right up to 105 (ASCII for "i") and print that out:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.After that, I switch back down to the space I prepped earlier,
<and increment it up to 39 for a comma, which I print,++++++++.before returning that back down to 32 for the space--------.I switch back to my other pointer
>and add four to the previous value for m, which I print++++..I switch to the other pointer which holds a space and print it, and move back to my other pointer, which is at m:
<.>.I then increment m to p and print
+++., then on to r and print++., then all the way back to e:-------------and print..So now we're at
i'm pre, next we need g,++., and then n,+++++++..Now we need
ant, so, back to a:-------------., forward to n:+++++++++++++.and finally, pop a t on the end:++++++.As you can see, if you know the alphabet and the ASCII table (http://www.asciitable.com/index/asciifull.gif) then you can write it on your phone while a baby cries and your girlfriend talks to you (blocked out) without much effort.