Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
f=lambda g:len({*sum(g,())})==2*len<2*len(g)and g or max(f(g-{k})for k in g)or g
Try it online!Try it online!
Takes input as set. Recursively removes one item until there are no duplicate vertices. It then returns the set with the most items.
f=lambda g:len({*sum(g,())})==2*len(g)and g or max(f(g-{k})for k in g)
Try it online!
f=lambda g:len({*sum(g,())})<2*len(g)and max(f(g-{k})for k in g)or g
f=lambda g:len({j for i in *sum(g for j in i,())})==len==2*len(g)*2andand g or max(f(g-{k})for k in g)
f=lambda g:len({j for i in g for j in i})==len(g)*2and g or max(f(g-{k})for k in g)