Skip to content

Commit 9e32160

Browse files
committed
Love calculator
1 parent 061450f commit 9e32160

File tree

5 files changed

+83
-3
lines changed

5 files changed

+83
-3
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ If you have any questions, you can contact me by email morasiu2@gmail.com
1414
1. [06 RockPaperScizzors with AI](#06)
1515
1. [07 Project Euler (first10 problems)](#07)
1616
1. [08 Hangman (with online words)](#08)
17+
1. [09 Love Calculator](#09)
1718
-----
1819
## Bonus
1920
1. [Loading animation](#bonus1)
2021

2122
## Progress
2223
All - **100** <br>
23-
Done - **9** <br>
24-
Remain - **91** <br>
24+
Done - **10** <br>
25+
Remain - **90** <br>
2526

2627
* <a name="00">00</a> Name Generator - 29.01.2018 *Done* (`Python 3`) <br>
2728
![00](docs/00.png)
@@ -44,6 +45,7 @@ Remain - **91** <br>
4445
Words are from [FakeWords](https://fakena.me/random-english-words/one/), but these are real words. Trust me.
4546
Definitions are form [FreeDictionary](https://www.thefreedictionary.com/)
4647
![08](docs/08.png)
47-
48+
* <a name="09">09</a> Love Calculator - 27.02.2018 *Done* (`C#`)</br>
49+
![09](docs/09.png)
4850
## Bonus
4951
* <a name="bonus1">Bonus 1</a> Loading animation in console 24.02.2018 *Done* (`C#`) ![Bonus 1](docs/bonus1.gif)
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
class LoveCalculator{
6+
static void Main(string[] args){
7+
Console.ForegroundColor = ConsoleColor.Green;
8+
Console.WriteLine("<-----------Love Calculator----------->");
9+
Console.WriteLine("Created by Morasiu (morasiu2@gmail.com)");
10+
11+
Calculate();
12+
13+
Console.ReadKey();
14+
}
15+
16+
static void Calculate(){
17+
//Step 1. Take the letters of the word LOVES, and then find out how many of each letter are in both of the names.
18+
//Step 2. place each of these numbers beside the other.
19+
//Step 3. start adding each pair of numbers together, to generate the next number, you will continue to do this until there are only two numbers left.
20+
//For example. If the names where Duchess and Latro you would find, L=1 O=1 V=0 E=1 S=2. 11012 -> (1+1,1+0,0+1,1+2) -> 2113 -> 324 -> 56
21+
22+
List<int> count = new List<int>(); //Always 5 on start because of five letter in "loves"
23+
//First name
24+
Console.Write("First name: ");
25+
string firstName = Console.ReadLine().ToLower();
26+
//Second name
27+
Console.Write("Second name: ");
28+
string secondName = Console.ReadLine().ToLower();
29+
30+
count = Enumerable.Zip(CountLetters(firstName), CountLetters(secondName), (a, b) => a + b).ToList();
31+
string sum = "";
32+
33+
foreach(int i in count){
34+
sum += i.ToString();
35+
}
36+
Console.WriteLine("Love percent: " + SumNumbers(sum) + " ♥");
37+
}
38+
39+
static string SumNumbers(string num){
40+
//Recursive time!
41+
string sum = num;
42+
string tmpSum = "";
43+
if(num.Length == 2)
44+
return num;
45+
else {
46+
for(int i = 0; i < sum.Length - 1; i++){
47+
int iSum = (int)(sum[i] - '0') + (int)(sum[i+1] - '0');
48+
if (iSum > 10){
49+
iSum = (int)(iSum.ToString()[0] - '0') + (int)(iSum.ToString()[1] - '0');
50+
}
51+
tmpSum += iSum.ToString();
52+
}
53+
return SumNumbers(tmpSum);
54+
}
55+
}
56+
57+
58+
static int[] CountLetters(string name){
59+
int[] count = new int[5];
60+
string loves = "loves";
61+
foreach(char l in name){
62+
for(int i = 0; i < loves.Length; i++){
63+
if(l == loves[i]){
64+
count[i]++;
65+
break;
66+
}
67+
}
68+
}
69+
return count;
70+
}
71+
}
4.5 KB
Binary file not shown.

docs/09.png

5.71 KB
Loading

docs/LoveCalculator.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Love Calculator
2+
## How it works
3+
* Step 1. Take the letters of the word LOVES, and then find out how many of each letter are in both of the names.
4+
* Step 2. place each of these numbers beside the other.
5+
* Step 3. start adding each pair of numbers together, to generate the next number, you will continue to do this until there are only two numbers left.
6+
7+
For example. If the names where Duchess and Latro you would find, L=1 O=1 V=0 E=1 S=2. 11012 -> (1+1,1+0,0+1,1+2) -> 2113 -> 324 -> 56

0 commit comments

Comments
 (0)