last day (15 days later) » 

7:56 AM
Hi, Hadi J!
 
Hi
 
mate, can you help me one problem.
I have done all coding stuffs.
it is just failing scenarios.
 
sure
 
Mate, I am sharing you my code now
 
I can't see your images
 
8:09 AM
A second mate
I am uploading image on web
 
I saw
OK
it's better
 
you got images?
@HadiJ , you got questions?
 
yeah, I'm reading
 
when you are done reading, tell me. i will share my code.
 
OK
I read it. can you share?
 
8:20 AM
yes
import java.io.IOException;
import java.util.*;

public class CandidateCode {
static int km = 0;
private final int V;
private final List<List<Integer>> adj;

public CandidateCode(int V) {
this.V = V;
adj = new ArrayList<>(V);

for (int i = 0; i < V; i++)
adj.add(new LinkedList<>());
}

//class 6
// Driver code
public static void main(String[] args) throws IOException {
List<Integer> lengthofCycles = new ArrayList<>();
List<Integer> mincycle = new ArrayList<>();
Scanner sc = new Scanner(System.in);
sample input:
4 5
1 2 2 10
2 3 4 400
3 4 8 100
4 3 2 5
3 1 1 1000
the output is obvious as in question, the code works fine :)
The problem comes when, there is multiple cycles with same length.
Example:
5 7
1 2 10 21
2 3 9 16
3 1 8 15
3 4 6 13
4 3 5 21
4 5 7 12
5 4 4 8
for this the cycle will be 4 3 4 with difference between hare and tortoise as : (13+21)-(6+5)
tHE ABOVE OUTPUT IS ALSO CORRECT TILL NOW.
Now come another input
5 7
1 2 10 21
2 3 9 16
3 1 8 15
3 4 6 13
4 3 5 21
4 5 7 23
5 4 4 48
The output should be 2 60
but the output is coming as 2 23, because the code is not looking the second cycle which should be answer.
Please help.
 
OK
 
I will surely give you a tip of 10 USD in any of cryptocurrency you say. TRON, ETHEREUM , BTC , LTC to help me out.
It is just a gesture from my side.
first input line is nodes and forest
Did you understood the question mate?
 
yeah
I know
 
Please help.
 
for last inputs why 2 23 it shouldn't be 2 25?
 
8:33 AM
yes yes, 2 25
sorry, mistake
 
OK
let me read your code
 
okay :)
 
what was your solution ? can you explain in brief?
 
I found the cycles first.
I then calculate the legth of each cycles.
Then i took the cycle with minimum length
Then i calculated the hareTime-tortoiseTime
the problem i think is that iwhen i am taking the minimum number of cycles, then i am taking only one and thus i am failing the scenario
see thsi:
for (int i = 0; i < cycles.size(); i++) {
List cycle = (List) cycles.get(i);
lengthofCycles.add(cycle.size());
}
 
yeah
 
8:42 AM
this just calculated the number of elements in each cycle and save them.
Now the fool thing that i am doins is that i am taking the cycle which has minimum no of elements
int min = Collections.min(lengthofCycles);
with my code int min = Collections.min(lengthofCycles); there can be only one minimum element, so i am thus missing the other minimum of same length.
please fix my code.
 
OK
 
I am failing all test cases except default.
 
8:55 AM
i am thinking to replace this :
int min = Collections.min(lengthofCycles);
with this:
int [] minimum = new int [lengthofCycles.size()];
minimum = lengthofCycles.stream().mapToInt(i->i).toArray();
This will keep all length of cycles, i will sort this in increasing order.
 
9:13 AM
2->3->1->2 25
3->4->3 23
4->5->4 60

I think output should be 3 23, you should sort based on length of cycles and sum of margins
 
Yes, yes.
2 , 23
3-4-3
makes just 2 length cycle
 
Aha
where you sum cycle margin?
 
No where.
This is just what i have done till now, i am very confused now, by thinking the scearios that can occur.
 
Try to declare a class that represent cycle length and total margin. class CycleData{ int len; int totalMargin; }
 
@HadiJ , please fix it for me. I am literally burning my head. :(
Please.
I also got the idea to declare the class to suit my solution, but now i am helpless :(
 
9:26 AM
so tell me where place I can compute total margin for each cycle ?
 
Total cycles is done, i have used the standard code for finding the number of cycles in graph.
List cycles = ecs.getElementaryCycles();
This cycles, have all the cycle in graph given as input, with debus point you can see it.
 
10:21 AM
mate :(
 
10:38 AM
@HadiJ , HELP mate.
 
i'm doing
wait please
 
10:51 AM
sorry why you say it should be 2 60?
 
5 7
1 2 10 21
2 3 9 16
3 1 8 15
3 4 6 13
4 3 5 21
4 5 7 23
5 4 4 48
 
but 2 23 is correct
2->3->1->2 25
3->4->3 23
4->5->4 60
 
no no
2 60 is ciorrect
see for path 3-4-3
the difference is (6+5)-(13+31)
and for path 4-5-4
the difference is (23+48)-(7+4) = 60
the 60 one is highest difference, so it must be answer.
The tortoise wanna make a lesson for hare to win with the maximum margin, so that hare wont challange him ever in life again.
so 4-5-4 path should be chosen in answer.
 
11:13 AM
import java.io.IOException;
import java.util.*;

public class CandidateCode {
static int km = 0;
private final int V;
private final List<List<Integer>> adj;

public CandidateCode(int V) {
this.V = V;
adj = new ArrayList<>(V);

for (int i = 0; i < V; i++)
adj.add(new LinkedList<>());
}

//class 6
// Driver code
public static void main(String[] args) throws IOException {
List<Integer> lengthofCycles = new ArrayList<>();
List<Integer> mincycle = new ArrayList<>();
Map<String,Integer> tortoiseTimeMap = new HashMap<>();
I added some changes
but you can do it better
 
Testing
 
import java.io.IOException;
import java.util.*;

public class CandidateCode {
static int km = 0;
private final int V;
private final List<List<Integer>> adj;

public CandidateCode(int V) {
this.V = V;
adj = new ArrayList<>(V);

for (int i = 0; i < V; i++)
adj.add(new LinkedList<>());
}

//class 6
// Driver code
public static void main(String[] args) throws IOException {
List<Integer> lengthofCycles = new ArrayList<>();
List<Integer> mincycle = new ArrayList<>();
Map<String,Integer> tortoiseTimeMap = new HashMap<>();
 
It works fine at my end for the test cases that i have in my mind.
I am now putting it in online portal, fingers crossed, hope it goes ok.
thanks, i would like more more favour from you.
please send your BTc or Tron wallet
i will send a gesture of 10 usd :)
dont think it as some money transfer, it is just my heart which says for you.
Ahh.. it is failing the initial case itself
4 5
1 2 2 10
2 3 4 400
3 4 8 100
4 3 2 5
3 1 1 1000
 
please test last one that I sent
I tested it, works fine
 
a second
It passed one test case.
 
11:30 AM
Ah
sorry
 
No worries.
i will figure out rest, on what test cases i am failing.
thanks for your help mate.
Send me the address where to send funds. You deserve it.
 
Can I ask a question?
 
yes, please
 
oh no, never mind
Do you know me?
 
ask, what you wanna ask.
 
11:33 AM
do you know me?
 
yes, i know you. I have seen you answering many java-8 question. Infact i see your answers and learn from them,
 
but I mean why do you choose me?
 
You are best in giving solutions, I have seen your answers. You go in depth to give the solution not just ideas. There are many java-8 solvers and they mostly say do this, do that. No one goes in depth and explain stuffs like you do. i am sure you have learnt all from scratch and you dont have attitude.
I prefer people who dont have attitude, i am very down to earth person, and prefer of same kind like me.
That is why i chose you.
 
thanks bro
 
I am waiting for you address to send some gifts.
Tron address?
 
11:39 AM
actually I don't have them that you said also I didn't solve it
 
Which country you are from brother?
 
Iran
 
Ahh.. good good. I am from India.
Dont go with my SO profile, it is just to make it difficult for some people to track me.
You are a good problem solver, i am very happy to talk to you. You and some more people here are inspiration for me. :)
 
Thanks, its your kind
can you help me ?
 
yes
Pleae tell
please
 
11:50 AM
unfortunately I'm not good in English skills, if it's possible we can have conversation sometimes
to improve speaking skill
 
I would love to talk to you.
Sure.
Add me on whatsapp , i would be fortunate to have friend from Iran.
+91-8109609818
BTW, i am a pro cryptocurrency trader. I am not much old just 24 yrs only but i have expereince in trading of 5 years
I have been trading bitcoins, and many crypto currencies since my 2 nd year of engineering.
 

last day (15 days later) »