const powerset = (arr: Array<number>) =>
        arr.reduce((a, v:number) => a.concat(a.map(r => r.concat(v))), [[]]);
      
      Typescript language logo

      Powerset

      Codiga's TypeScript Recipes

      Returns the powerset of a given array of numbers.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.