Welcome to my personal website. I use this space to share some of my thoughts and software that I write in my free time. Sometimes I also publish photos. If you want to get in touch please use LinkedIn or Mastodon.
A subset of a list with the elements {a,b,c} is {a,b}. The task is to find all possible subsets. Sets in programming languages are usually not ordered. Therefore, the set {a,b,c} is equivalent to {b,c,a}.
The idea for the solution is a nested for-loop that iterates over the results again and again, starting with one empty ([]) result.
Solution
The code to solve this problem is listed here.
Example
Assuming that the input is [1,2,3]. The execution steps look as follows:
About the author
Friedrich Ewald is an experienced Software Engineer with a Master's degree in Computer Science. He started this website in late 2015, mostly as a digital business card. He is interested in Go, Python, Ruby, SQL- and NoSQL-databases, machine learning and AI and is experienced in building scalable, distributed systems and micro-services at multiple larger and smaller companies.