+ 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.

29th Jan 2018, 4:56 PM
Oma Falk
Oma Falk - avatar
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
30th Jan 2018, 10:20 PM
LukArToDo
LukArToDo - avatar
29th Jan 2018, 8:11 PM
Oma Falk
Oma Falk - avatar
+ 47
Congratulations for the challenge of the day 👍😉
31st Jan 2018, 3:17 PM
tooselfish
tooselfish - avatar
+ 35
congrats 4 COTD //mine try will come later , have 2 sleep & work() now
31st Jan 2018, 4:06 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 27
@Oma Falk Congrats on the COTD! Deserved! 👏👏👏
31st Jan 2018, 3:47 PM
LukArToDo
LukArToDo - avatar
+ 26
@ Oma Falk, you are welcome, you have a lot of work with your challenge, that happens 👍😉
31st Jan 2018, 3:47 PM
tooselfish
tooselfish - avatar
+ 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.
31st Jan 2018, 10:05 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 24
Good values are 17 lends for 20 people
30th Jan 2018, 7:55 AM
Oma Falk
Oma Falk - avatar
+ 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.
29th Jan 2018, 8:10 PM
BlazingMagpie
BlazingMagpie - avatar
+ 20
Thankfully, they have example 😢 😵
31st Jan 2018, 3:03 PM
Tran Huu Dang
Tran Huu Dang - avatar
+ 20
@Mohamed Abusuhail. S Why did you take my code ???
31st Jan 2018, 9:48 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 18
@fish thank you.... didnt tecognize, before you told me (-;
31st Jan 2018, 3:46 PM
Oma Falk
Oma Falk - avatar
+ 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
30th Jan 2018, 3:30 PM
dim_knp
dim_knp - avatar
+ 16
@Malik thank you !
31st Jan 2018, 3:41 PM
Oma Falk
Oma Falk - avatar
+ 15
Congratulations!!
31st Jan 2018, 4:38 PM
Prop de Puppy
Prop de Puppy - avatar
+ 12
Verizon
31st Jan 2018, 3:44 PM
Super boy kz 2
Super boy kz 2 - avatar
+ 11
@arun first case a->c 2nd case e->b since e->f f->a a->b
30th Jan 2018, 6:26 PM
Oma Falk
Oma Falk - avatar
3rd Feb 2018, 3:51 PM
AZTECCO
AZTECCO - avatar
+ 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!
3rd Feb 2018, 9:22 PM
AZTECCO
AZTECCO - avatar