Skip to main content
added 39 characters in body
Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 34
  • 90

Jelly, 1819 bytes

,!P€E
SṗLçÐfµḢḟ1ȯ1SṗLçÐfµḢḟ1ȯ1F

Try it online!Try it online!

Quick and dirty. Very slow, even the 23!2!3!2! test case is a stretch. I/O as lists of integers.

Explanation

,!P€E    Helper link. Arguments: attempt, original
,        Make the array [attempt, original].
         Example: [[1,1,1,4], [2,3,2,0]]
 !       Take the factorial of each item.
         Example: [[1,1,1,24], [2,6,2,1]]
  P€     Take the product of each sublist.
         Example: [24, 24]
    E    Check if the values are equal.

SṗLçÐfµḢḟ1ȯ1 SṗLçÐfµḢḟ1ȯ1F   Main link. Arguments: original
S               Find the sum S of the integers in the input.
  L             Find the number N of integers in the input.
 ṗ              Generate all lists containing N integers from 1 to S.
   çÐf          Take the lists whose factorial-product is the same as the original.
       Ḣ        Take the first match. This is the one with the most ones.
        ḟ1      Remove any ones.
          ȯ1    If there were only ones, return a listone withinstead.
            F   Turn into a onelist insteadif needed.

Jelly, 18 bytes

,!P€E
SṗLçÐfµḢḟ1ȯ1

Try it online!

Quick and dirty. Very slow, even the 23!2!3!2! test case is a stretch. I/O as lists of integers.

Explanation

,!P€E    Helper link. Arguments: attempt, original
,        Make the array [attempt, original].
         Example: [[1,1,1,4], [2,3,2,0]]
 !       Take the factorial of each item.
         Example: [[1,1,1,24], [2,6,2,1]]
  P€     Take the product of each sublist.
         Example: [24, 24]
    E    Check if the values are equal.

SṗLçÐfµḢḟ1ȯ1    Main link. Arguments: original
S               Find the sum S of the integers in the input.
  L             Find the number N of integers in the input.
 ṗ              Generate all lists containing N integers from 1 to S.
   çÐf          Take the lists whose factorial-product is the same as the original.
       Ḣ        Take the first match. This is the one with the most ones.
        ḟ1      Remove any ones.
          ȯ1    If there were only ones, return a list with a one instead.

Jelly, 19 bytes

,!P€E
SṗLçÐfµḢḟ1ȯ1F

Try it online!

Quick and dirty. Very slow, even the 23!2!3!2! test case is a stretch. I/O as lists of integers.

Explanation

,!P€E    Helper link. Arguments: attempt, original
,        Make the array [attempt, original].
         Example: [[1,1,1,4], [2,3,2,0]]
 !       Take the factorial of each item.
         Example: [[1,1,1,24], [2,6,2,1]]
  P€     Take the product of each sublist.
         Example: [24, 24]
    E    Check if the values are equal.

SṗLçÐfµḢḟ1ȯ1F   Main link. Arguments: original
S               Find the sum S of the integers in the input.
  L             Find the number N of integers in the input.
 ṗ              Generate all lists containing N integers from 1 to S.
   çÐf          Take the lists whose factorial-product is the same as the original.
       Ḣ        Take the first match. This is the one with the most ones.
        ḟ1      Remove any ones.
          ȯ1    If there were only ones, return a one instead.
            F   Turn into a list if needed.
deleted 46 characters in body
Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 34
  • 90

Jelly, 18 bytes

,!P€E
SṗLçÐfµḢḟ1ȯ1

Try it online!

Extremely quickQuick and dirty. Also veryVery slow, even the 23!2!3!2! test case is a stretch. I/O as lists of integers.

Explanation coming when done golfing.

Explanation

,!P€E    Helper link. Arguments: attempt, original
,        Make the array [attempt, original].
         Example: [[1,1,1,4], [2,3,2,0]]
 !       Take the factorial of each item.
         Example: [[1,1,1,24], [2,6,2,1]]
  P€     Take the product of each sublist.
         Example: [24, 24]
    E    Check if the values are equal.

SṗLçÐfµḢḟ1ȯ1    Main link. Arguments: original
S               Find the sum S of the integers in the input.
  L             Find the number N of integers in the input.
 ṗ              Generate all lists containing N integers from 1 to S.
   çÐf          Take the lists whose factorial-product is the same as the original.
       Ḣ        Take the first match. This is the one with the most ones.
        ḟ1      Remove any ones.
          ȯ1    If there were only ones, return a list with a one instead.

Jelly, 18 bytes

,!P€E
SṗLçÐfµḢḟ1ȯ1

Try it online!

Extremely quick and dirty. Also very slow, even the 23!2!3!2! test case is a stretch. I/O as lists of integers.

Explanation coming when done golfing.

Jelly, 18 bytes

,!P€E
SṗLçÐfµḢḟ1ȯ1

Try it online!

Quick and dirty. Very slow, even the 23!2!3!2! test case is a stretch. I/O as lists of integers.

Explanation

,!P€E    Helper link. Arguments: attempt, original
,        Make the array [attempt, original].
         Example: [[1,1,1,4], [2,3,2,0]]
 !       Take the factorial of each item.
         Example: [[1,1,1,24], [2,6,2,1]]
  P€     Take the product of each sublist.
         Example: [24, 24]
    E    Check if the values are equal.

SṗLçÐfµḢḟ1ȯ1    Main link. Arguments: original
S               Find the sum S of the integers in the input.
  L             Find the number N of integers in the input.
 ṗ              Generate all lists containing N integers from 1 to S.
   çÐf          Take the lists whose factorial-product is the same as the original.
       Ḣ        Take the first match. This is the one with the most ones.
        ḟ1      Remove any ones.
          ȯ1    If there were only ones, return a list with a one instead.
deleted 46 characters in body
Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 34
  • 90

Jelly, 30 2818 bytes

,!P€E
Ṗṣ”!VµSṗLçÐfµḢḟ1ȯ1;€”!SṗLçÐfµḢḟ1ȯ1

Try it online!Try it online!

Extremely quick and dirty. Also very slow, even the 23!2!3!2! test case is a stretch. I/O as lists of integers.

Explanation coming when done golfing.

Jelly, 30 28 bytes

,!P€E
Ṗṣ”!VµSṗLçÐfµḢḟ1ȯ1;€”!

Try it online!

Extremely quick and dirty. Also very slow, even the 23!2!3!2! test case is a stretch.

Explanation coming when done golfing.

Jelly, 18 bytes

,!P€E
SṗLçÐfµḢḟ1ȯ1

Try it online!

Extremely quick and dirty. Also very slow, even the 23!2!3!2! test case is a stretch. I/O as lists of integers.

Explanation coming when done golfing.

Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 34
  • 90
Loading