Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "riddle random"
-
Coding won over my first girlfriend!
My senior year of high school I taught myself C++ and thought it was the coolest thing (lol). So I wrote a stupidly simple program that would ask your name and output a random riddle. But if the name was hers it was a riddle in which case the answer was "a date". Looking back, even if she was on my robotics team it was the nerdiest thing.
We dated for 8 months and broke up as friends. But to this day it provides a great story as I pursue software development.4 -
Riddle:
Alice and bob want to communicate a secret message, lets say it is an integer.
We will call this msg0.
You are Chuck, an interloper trying to spy on them and decode the message.
For keys, alice chooses a random integer w, another for x, and another for y. she also calculates a fourth variable, x+y = z
Bob follows the same procedure.
Suppose the numbers are too large to bruteforce.
Their exchange looks like this.
At step 1, alice calculates the following:
msg1 = alice.z+alice.w+msg0
she sends this message over the internet to bob.
the value of msg1 is 20838
then for our second step of the process, bob calculates msg2 = bob.z+bob.w+msg1
msg2 equals 32521
he then sends msg2 to alice, and again, you intercept and observe.
at step three, alice recieves bob's message, and calculates the following: msg3 = msg2-(alice.x+alice.w+msg0)
msg3 equals 19249. Alice sends this to bob.
bob calculates msg4 = msg3-(bob.x+bob.w)
msg4 equals 11000.
he sends msg4 to alice
at this stage, alice calculates ms5.
msg5 = (msg4-(alice.y)+msg0.
alice sends this to bob.
bob recieves this final message and calculates
the sixth and final message, which is the original hidden msg0 alice wanted to send:
msg6 = msg5-bob.y
What is the secret message?
I'll give anyone who solves it without bruteforcing, a free cookie.18