+ 154
[ASSIGNMENT] who has to pay?
In a class there are 20 students. For a coffee they have to pay 1$ They lend this dollar sometimes to some other student but each student not more than one time. At the end of semester, the students want to clear their debts: If a lend to b and b lend to c and c lend to a, nobody has to pay. But if additionally d lend to c, c has to pay 1$ to d Challenge: create a random situation of who lend money to whom. Let change dollars as little as possible. Example a->b b->c c->a d->b only b has to pay to d. ---- a->b b->c c may pay to a --- a->b b->c d->c c has to pay to a and to d Hint: create a linked list and remove all circles.
95 Answers
+ 90
This is a copy of the original code. I accidentally deleted the original code 😭 (with all comments and upvotes 😲, sorry guys 🙁). Luckily I had a copy that I now set as a replacement.
https://code.sololearn.com/cIMnVez3omez/?ref=app
+ 47
Congratulations for the challenge of the day 👍😉
+ 35
congrats 4 COTD
//mine try will come later , have 2 sleep & work() now
+ 27
@Oma Falk
Congrats on the COTD! Deserved! 👏👏👏
+ 26
@ Oma Falk, you are welcome, you have a lot of work with your challenge, that happens 👍😉
+ 25
I'm sorry I was exposed this way and that my codes are taking others and challenging !!
All of you see that my code is stolen and exposes me to a negative influence.
+ 24
Good values are 17 lends for 20 people
+ 22
https://code.sololearn.com/cFI8AC8ClCfB/?ref=app
I will finish it
Tomorrow™
Edit: I think I'm done. Doesn't follow challenge description fully, but I'd rather spend time learning SWT than refactoring this.
+ 20
Thankfully, they have example 😢 😵
+ 20
@Mohamed Abusuhail. S
Why did you take my code ???
+ 18
@fish thank you.... didnt tecognize, before you told me (-;
+ 16
It throws a timeout error in Code Playground but it seems to work in Visual Studio.
Update: I am trying to fix and optimise this code.
Update 2: It's finally working as expected.
https://code.sololearn.com/c8OmbAJHEORo
+ 16
@Malik thank you !
+ 15
Congratulations!!
+ 12
Verizon
+ 11
@arun first case a->c
2nd case e->b since
e->f f->a a->b
+ 11
+ 11
too much garbage in this thread!
People you may just post an answer (whit a code)!
I downvoted this mine comment as many useless comments! keep it tidy please!