Question: 0 : r e d , 1 : b l u e , 2 : g r e e n 2 c o s t
: r e d : b l u e : g r e e n
c o s t s
# c o s t s : c o s t o f p a i n t i n g node c o l o r g r e e n
# t o t a l number o f c o m b i n a t i o n s : n u m b e r c o l o r s n u m b e r h o u s e s
# e n u m e r a t e d l i s t o f f e a s i b l e c o m b i n a t i o n s :
# : f e a s i b l e b e c a u s e a l l a d j a c e n t n o d e s h a v e d i f f e r e n t c o l o r
# : n o t f e a s i b l e b e c a u s e l a s t n o d e s h a v e same c o l o r
# H i n t : i t e r t o o l s p r o d u c t l i b r a r y f u n c t i o n g e n e r a t e s a l l c o m b i n a t i o n s
m i n c o s t e n u m b e s t c o l o r i n g e n u m m i n c o s t v e r t e x c o l o r i n g e n u m e r a t i o n c o s t s
# m i n c o s t e n u m : b e s t c o l o r i n g e n u m :
keeping this sample function call and expected inputsoutputs write the python code as a python script
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
