39
11
As a kid my sister showed me this little love calculation to see how much chance you have of getting in a successful relationship with your crush. All you need is 2 names and a piece of paper.
- John
- Jane
Then, you separate these names with the word Loves. You can either write this on one line or on new lines.
John
Loves
Jane
Then the calculating begins. You start off by counting how many times a character occurs from left to right and in case you use new lines also from top to bottom. Each character is counted once, So after counting the J of John you don't have to count them again when you start with Jane. The result of this example will be as follows:
J: 2 ([J]ohn | [J]ane)
O: 2 (J[o]hn | L[o]ves)
H: 1 (Jo[h]n)
N: 2 (Joh[n] | Ja[n]e)
__
L: 1 ([L]oves)
O: skipped
V: 1 (Lo[v]es)
E: 2 (Lov[e]s | Jan[e])
S: 1 (Love[s])
__
J: skipped
A: 1 (J[a]ne)
N: skipped
E: skipped
__
Final result: 2 2 1 2 1 1 2 1 1
The next step will be adding the digits working from the outside to the middle.
2 2 1 2 1 1 2 1 1 (2+1=3)
2 2 1 2 1 1 2 1 1 (2+1=3)
2 2 1 2 1 1 2 1 1 (1+2=3)
2 2 1 2 1 1 2 1 1 (2+1=3)
2 2 1 2 1 1 2 1 1 (1)
__
Result: 3 3 3 3 1
You will keep doing this until you have an integer left less or equal to 100.
3 3 3 3 1
4 6 3
76%
It can happen that the sum of 2 digits becomes ≥ 10, in this case the number will be split in 2 on the next row.
Example:
5 3 1 2 5 4 1 8
13 (Will be used as 1 3)
1 3 4 5 7
8 8 4 (8+4=12 used as 1 2)
1 2 8
92%
Requirements
- Your program should be able to accept any name with reasonable length (100 characters)
- [A..Z, a..z] characters are allowed.
- Case insensitive so A == a
Free for you to decide
- How to handle special characters (Ö, è, etc.)
- Include last names yes or no, spaces will be ignored
- Any language is allowed.
Winner will be determined by votes on the 28th 14th of February.
Happy coding
P.s. This is the first time I put something up here, if there is any way to improve it feel free to let me know =3
Edit: Changed end date to valentines day, thought that would be more appropriate for this challenge :)
Your example doesn't show what happens when an even number of numbers need to be added, or when you have a number with 2 digits. Better add those to clarify. – Kendall Frey – 2014-01-30T13:05:30.787
Do you add numbers or digits? E.g. what are the next two lines after
5 6 7
? – Howard – 2014-01-30T13:05:42.653@Howard Yeah, I'd really like to know. It's probably digits; adding numbers will start failing at around 60 or 70, and the OP expects 100. – cjfaure – 2014-01-30T13:35:44.240
@KendallFrey I dont understand your comment. What do you mean with an even number of numbers? in this example I ended with a single 1 (first row)which basicly means 1+0=1. With an even number you end up with 2 numbers so you will add those. 1+1=2. Does that answer your question? – Teun Pronk – 2014-01-30T13:48:06.063
1 1 2 3 5 8
becomes9 6 5
becomes14 6
becomes20
, am I correct? – Kendall Frey – 2014-01-30T13:56:21.857@Howard I added some more info on that matter. @KendallFrey Same info goes for this situation.
9 6 5
becomes indeed14 6
but14
will be used as1 4
making the total74
– Teun Pronk – 2014-01-30T13:59:27.660Your example has an error.
1 3 4 5 6
should be1 3 4 5 7
– Kendall Frey – 2014-01-30T14:12:43.687@KendallFrey Oops, lol thanks ^.^ – Teun Pronk – 2014-01-30T14:15:10.643
You forgot to fix all the numbers below it :) – Kendall Frey – 2014-01-30T14:15:54.980
facepalm xD – Teun Pronk – 2014-01-30T14:17:03.717
5<thinking volume="aloud">So calculation stops at 91%. Strange. I know quite many cases where continuing to 10% or even better 1% would give much more realistic score. With such a clearly commercial manipulation of the calculation I bet this is actually the one used by the SMS love calculator services.</thinking> – manatwork – 2014-01-30T14:22:44.987
@manatwork Lol, I see what you did there, regardless of how correct you are (which will be somewhere between the 99.99999% and 100%) I do believe people like to get (more or less) positive scores, dont you agree? :) although it would save a lot of money on divorces.. – Teun Pronk – 2014-01-30T14:25:02.277
8inb4 somebody posts code in the shape of a heart and wins popularity – Cruncher – 2014-01-30T15:04:43.527
Am I seriously the only one who thought this was bool false/1:true/2 for the string counters matching? The example matches my logic perfectly. – cjfaure – 2014-01-30T15:23:36.367
The n in John is not is the same column as the n in Jane. Is this a mistake, or how did you get 2 n's? – None – 2014-01-30T22:52:57.170
1@user2509848 the columns on the first few letters were a coincidence, and not a requirement. You just count the number of occurrences of the letter. – Danny – 2014-01-31T03:03:17.853
3Wonder how the results change if you convert the names (and "love") to their ASCII integer codes. For that matter, what happens if you replace "love" with "hate" -- you'd hope to get
1-love_result
:-) – Carl Witthoft – 2014-01-31T15:07:08.937@Danny Yes, I know. However, there are not 2 n's in the same column, so how could you count them twice? – None – 2014-01-31T17:01:59.310
@user2509848: The algorithm simply doesn’t care about columns. You count 2 n’s because there are 2 n’s, irrespective of what column they’re in. – Timwi – 2014-02-02T05:24:09.227
Oh, now I get it. – None – 2014-02-02T15:31:27.530