-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.java
More file actions
94 lines (94 loc) · 2.43 KB
/
Copy pathindex.java
File metadata and controls
94 lines (94 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import java.util.*;
class Main
{
public static void main(String args[])
{
Scanner s = new Scanner(System.in);
String male = s.next();
String female = s.next();
ArrayList <Character> male_list = new ArrayList <> ();
ArrayList <Character> female_list = new ArrayList <> ();
for(int i = 0 ; i < male.length() ; i++)
{
char ch = male.charAt(i);
male_list.add(ch);
}
for(int i = 0 ; i < female.length() ; i++)
{
char ch = female.charAt(i);
female_list.add(ch);
}
for(int i = 0 ; i < male_list.size() ; i++)
{
for(int j = 0 ; j < female_list.size() ; j++)
{
char ch = male_list.get(i);
if(ch == female_list.get(j))
{
male_list.remove(i);
female_list.remove(j);
i--;
break;
}
}
}
int non_repeating_length = male_list.size() + female_list.size();
// System.out.print(non_repeating_length);
char ch = flames(non_repeating_length);
if(ch == 'f')
{
System.out.print("Friends");
}
else if(ch == 'l')
{
System.out.print("Love");
}
else if(ch == 'a')
{
System.out.print("Affection");
}
else if(ch == 'm')
{
System.out.print("Marriage");
}
else if(ch == 'e')
{
System.out.print("Enemy");
}
else
{
System.out.print("Sister");
}
}
public static char flames(int non_repeating_length)
{
ArrayList <Character> result = new ArrayList <> ();
result.add('f');
result.add('l');
result.add('a');
result.add('m');
result.add('e');
result.add('s');
int count = 1;
for(int i = 0 ; i < result.size() ; i++)
{
if(count == non_repeating_length)
{
result.remove(i);
i--;
count = 0;
}
if(i == (result.size() - 1))
{
i = 0;
i--;
}
count++;
if(result.size() == 1)
{
return result.get(0);
}
}
return '0';
}
}