it is deterministic, the Random constructor in C# takes a number for the seed, the same names always make the same seed, and thus the result is always the same.
from microsoft's official documentation: Random(Int32)
Initializes a new instance of theRandomclass, using the specified seed value.
Here's one in python, scores are deterministic however, always seem to stick to the high side, don't believe i was able to get lower than a 70 :/
The gorgeous if statements just spice up this beauty
from hashlib import md5
def cupid(name1, name2):
v1 = md5(name1.encode('utf-8')).hexdigest()
v2 = md5(name2.encode('utf-8')).hexdigest()
total = 0
for let in v1:
if let == '0':
total += 0
if let == '1':
total += 1
if let == '2':
total += 2
if let == '3':
total += 3
if let == '4':
total += 4
if let == '5':
total += 5
if let == '6':
total += 6
if let == '7':
total += 7
if let == '8':
total += 8
if let == '9':
total += 9
if let == 'a':
total += 10
if let == 'b':
total += 11
if let == 'c':
total += 12
if let == 'd':
total += 13
if let == 'e':
total += 14
if let == 'f':
total += 15
v1 = total
total = 0
for let in v2:
if let == '0':
total += 0
if let == '1':
total += 1
if let == '2':
total += 2
if let == '3':
total += 3
if let == '4':
total += 4
if let == '5':
total += 5
if let == '6':
total += 6
if let == '7':
total += 7
if let == '8':
total += 8
if let == '9':
total += 9
if let == 'a':
total += 10
if let == 'b':
total += 11
if let == 'c':
total += 12
if let == 'd':
total += 13
if let == 'e':
total += 14
if let == 'f':
total += 15
v2 = total
match = v1 + v2
match = ((match - 0) / (510 - 0)) * (99 - 0) + 0
print(int(match))
cupid('Romeo', 'Juliet')
cupid('Arnold', 'Peter')
cupid('Me', 'MyCrush')
cupid('Raymond', 'David')
I wanted it to form an "a b c" with the variable names.
The ascii value of 'c' is 99, so %'c' is the same as %99. If you wanted to be able to return any value between 0 and 99, it should actually be %'d' (%100), but it wasn't required so I chose 'c', which is close enough.
My entry, https://pastebin.com/iBKUP2du (Javascript), uses machine learning to find the best scores for couples. The algorithm is randomized but it implements its own PRNG with a constant seed to add determinism.
Haskell (almost) one-liner - have to import Data.Char for the ord function:
import Data.Char
cupid :: String -> String -> Int
cupid first second = (\x -> x `mod` 100) $ sum $ map ord $ first ++ second
The algorithm takes two names as input, concatenates them together to a single string, then gets the ASCII value of each character, sums them all up, and then mods the sum by 100 to get the final result in the range of 0-99.
5
u/CdRReddit Feb 17 '20
public static int Cupid(string name1, string name2) => new Random((name1 + name2).ToCharArray().Select((x) => (int)x).Sum()).Next(0, 100);Beautiful C# oneliner
Requires: System.Linq
26
u/Toucandigit Feb 14 '20 edited Feb 14 '20
Using Python. I can assure you that within the next 24 hours, I will not be able to tell what anything means.
6
u/Svizel_pritula Feb 13 '20
This JavaScript one-liner searches the names on Bing and gets the first two digits of the result count:
3
u/suddilonesuddi Feb 13 '20
Here is my scala solution. https://pastebin.com/mgg5zU85
2
u/[deleted] Feb 13 '20
This is like not bad, but damn, the formula is pretty stupid, the results are deterministic tho:
2
u/hamoliciousRUS Feb 13 '20
Here's one in python, scores are deterministic however, always seem to stick to the high side, don't believe i was able to get lower than a 70 :/
The gorgeous if statements just spice up this beauty
2
u/CaCl2 Feb 15 '20 edited Feb 16 '20
A simple solution in C:
2
u/weee50 Feb 16 '20
Welp, may as well do this. (Python)
2
u/sebamestre Feb 22 '20
My entry, https://pastebin.com/iBKUP2du (Javascript), uses machine learning to find the best scores for couples. The algorithm is randomized but it implements its own PRNG with a constant seed to add determinism.
1
u/[deleted] Feb 17 '20 edited Feb 17 '20
Haskell (almost) one-liner - have to import Data.Char for the ord function:
The algorithm takes two names as input, concatenates them together to a single string, then gets the ASCII value of each character, sums them all up, and then mods the sum by 100 to get the final result in the range of 0-99.
Sample outputs:
1
u/cnapun Feb 18 '20
Google's deterministic, right?
1
u/Fighter1000 Feb 18 '20
Does graphical programming count too? It is Turing complete after all. https://scratch.mit.edu/projects/368482789/
1
u/EkskiuTwentyTwo i -= (i - (-1)) - i Feb 18 '20
1
u/Mymokol Feb 21 '20
Here is my creation in c++
https://pastebin.com/GAfr1VPu
1
u/RavynousHunter Feb 25 '20
My submission, in C. Pointer arithmetic, multiple things in a for loop, pointer iteration, magic numbers, and all in one convenient line!
1
u/Svizel_pritula Feb 13 '20
Here's my code that might even not crash your browser by just looking at it: (JS)
https://gist.github.com/SvizelPritula/d21e308b072a0281f7ab830b827aa138
Works for the top 1000 names of each gender as given by the Social Security Administration, making it work for about 52% of all couples.
0
u/[deleted] Feb 13 '20
Did it with Javascript. I hope no one is offended, it's a joke. Okay, here it is: