Skip to main content
Commonmark migration
Source Link

#05AB1E, 11 9 8 bytes

05AB1E, 11 9 8 bytes

Ñε¨àDd<+ 

-3 bytes thanks to @Emigna, changing ©d1-®+ to Dd<+ and €¨€à to ε¨à.

Only my second 05AB1E answer, so can definitely be golfed.

Try it online.

Explanation:

Ñ # Divisors of each item in the input-list (including itself) # [1,2,10,3] → [[1],[1,2],[1,2,5,10],[1,2,3]] ε # For each: ¨ # Remove last item (so it's now excluding itself) # [[1],[1,2],[1,2,5,10],[1,2,3]] → [[],[1],[1,2,5],[1,2]] à # And get the max # [[],[1],[1,2,5],[1,2]] → ['',1,5,2] D # Duplicate the list d # Is it a number (1 if it's a number, 0 otherwise) # ['',1,5,2] → [0,1,1,1] < # Subtract 1 # [0,1,1,1] → [-1,0,0,0] + # Add both lists together # ['',1,5,2] and [-1,0,0,0] → ['-1',1,5,2] 

#05AB1E, 11 9 8 bytes

Ñε¨àDd<+ 

-3 bytes thanks to @Emigna, changing ©d1-®+ to Dd<+ and €¨€à to ε¨à.

Only my second 05AB1E answer, so can definitely be golfed.

Try it online.

Explanation:

Ñ # Divisors of each item in the input-list (including itself) # [1,2,10,3] → [[1],[1,2],[1,2,5,10],[1,2,3]] ε # For each: ¨ # Remove last item (so it's now excluding itself) # [[1],[1,2],[1,2,5,10],[1,2,3]] → [[],[1],[1,2,5],[1,2]] à # And get the max # [[],[1],[1,2,5],[1,2]] → ['',1,5,2] D # Duplicate the list d # Is it a number (1 if it's a number, 0 otherwise) # ['',1,5,2] → [0,1,1,1] < # Subtract 1 # [0,1,1,1] → [-1,0,0,0] + # Add both lists together # ['',1,5,2] and [-1,0,0,0] → ['-1',1,5,2] 

05AB1E, 11 9 8 bytes

Ñε¨àDd<+ 

-3 bytes thanks to @Emigna, changing ©d1-®+ to Dd<+ and €¨€à to ε¨à.

Only my second 05AB1E answer, so can definitely be golfed.

Try it online.

Explanation:

Ñ # Divisors of each item in the input-list (including itself) # [1,2,10,3] → [[1],[1,2],[1,2,5,10],[1,2,3]] ε # For each: ¨ # Remove last item (so it's now excluding itself) # [[1],[1,2],[1,2,5,10],[1,2,3]] → [[],[1],[1,2,5],[1,2]] à # And get the max # [[],[1],[1,2,5],[1,2]] → ['',1,5,2] D # Duplicate the list d # Is it a number (1 if it's a number, 0 otherwise) # ['',1,5,2] → [0,1,1,1] < # Subtract 1 # [0,1,1,1] → [-1,0,0,0] + # Add both lists together # ['',1,5,2] and [-1,0,0,0] → ['-1',1,5,2] 
deleted 193 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

#05AB1E, 11 9 9 8 bytes

Ñ€¨€àDd<+Ñε¨àDd<+ 

-23 bytes thanks to @Emigna, changing ©d1-®+ to Dd<+ and €¨€à to ε¨à.

Only my second 05AB1E answer, so can definitely be golfed. I'm having trouble converting '' to -1.. Ñ€¨€à (5 bytes) already gives the largest prime factors and 1 for primes, but '' for 0/1.so can definitely be golfed.

Try it online.Try it online.

Explanation:

Ñ  # Divisors of each item in the input-list (including itself)   # [1,2,310,10]3] → [[1],[1,2],[1,2,3]5,10],[1,2,5,10]]3]] €¨ε # For €acheach: ¨  # Remove last item (so it's now excluding itself)   #  [[1],[1,2],[1,2,3]5,10],[1,2,5,10]]3]] → [[],[1],[1,2]2,[15],2[1,5]]2]] €àà # For €ach:And Getget the max   #  [[],[1],[1,2]2,[15],2[1,5]]2]] → ['',1,25,5]2]   D # Duplicate the list   d # Is it a number (1 if it's a number, 0 otherwise)   # ['',1,25,5]2] → [0,1,1,1]   < # Subtract 1   # [0,1,1,1] → [-1,0,0,0]   + # Add both lists together   # ['',1,25,5]2] and [-1,0,0,0] → ['-1',1,25,5]2] 

#05AB1E, 11 9 bytes

Ñ€¨€àDd<+ 

-2 bytes thanks to @Emigna, changing ©d1-®+ to Dd<+.

Only my second 05AB1E answer, so can definitely be golfed. I'm having trouble converting '' to -1.. Ñ€¨€à (5 bytes) already gives the largest prime factors and 1 for primes, but '' for 0/1..

Try it online.

Explanation:

Ñ  # Divisors of each item in the input-list (including itself)   # [1,2,3,10] → [[1],[1,2],[1,2,3],[1,2,5,10]] €¨ # For €ach: Remove last item (so it's now excluding itself)   # [[1],[1,2],[1,2,3],[1,2,5,10]] → [[],[1],[1,2],[1,2,5]] €à # For €ach: Get max   # [[],[1],[1,2],[1,2,5]] → ['',1,2,5]   D # Duplicate the list   d # Is it a number (1 if it's a number, 0 otherwise)   # ['',1,2,5] → [0,1,1,1]   < # Subtract 1   # [0,1,1,1] → [-1,0,0,0]   + # Add both lists together   # ['',1,2,5] and [-1,0,0,0] → ['-1',1,2,5] 

#05AB1E, 11 9 8 bytes

Ñε¨àDd<+ 

-3 bytes thanks to @Emigna, changing ©d1-®+ to Dd<+ and €¨€à to ε¨à.

Only my second 05AB1E answer, so can definitely be golfed.

Try it online.

Explanation:

Ñ # Divisors of each item in the input-list (including itself) # [1,2,10,3] → [[1],[1,2],[1,2,5,10],[1,2,3]] ε # For each: ¨  # Remove last item (so it's now excluding itself) #  [[1],[1,2],[1,2,5,10],[1,2,3]] → [[],[1],[1,2,5],[1,2]] à # And get the max #  [[],[1],[1,2,5],[1,2]] → ['',1,5,2] D # Duplicate the list d # Is it a number (1 if it's a number, 0 otherwise) # ['',1,5,2] → [0,1,1,1] < # Subtract 1 # [0,1,1,1] → [-1,0,0,0] + # Add both lists together # ['',1,5,2] and [-1,0,0,0] → ['-1',1,5,2] 
deleted 132 characters in body
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394

#05AB1E, 1211 9 bytes

Ñ€¨€à©d1-®+ïÑ€¨€àDd<+ 

-2 bytes thanks to @Emigna, changing ©d1-®+ to Dd<+.

Only my second 05AB1E answer, so can definitely be golfed. I'm having trouble converting '' to -1.. Ñ€¨€à (5 bytes) already gives the largest prime factors and 1 for primes, but '' for 0/1..

Try it online.Try it online.

Explanation:

Ñ  # Divisors of each item in the input-list (including itself)   # [1,2,3,10] → [[1],[1,2],[1,2,3],[1,2,5,10]] €¨  # For €ach: Remove last item (so it's now excluding itself)   # [[1],[1,2],[1,2,3],[1,2,5,10]] → [[],[1],[1,2],[1,2,5]] €à  # For €ach: Get max   # [[],[1],[1,2],[1,2,5]] → ['',1,2,5]   ©  D # SaveDuplicate the current list in the registry d  # Is it a number (1 if it's a number, 0 otherwise)   # ['',1,2,5] → [0,1,1,1]   1- < # Subtract 1   # [0,1,1,1] → [-1,0,0,0] ® # Retrieve the saved list from the registry   + # Add both lists together   # ['',1,2,5] &and [-1,0,0,0] → ['-1',1,2,5]  ï # Cast to integer # ['-1',1,2,5] → [-1,1,2,5] 

#05AB1E, 12 bytes

Ñ€¨€à©d1-®+ï 

Only my second 05AB1E answer, so can definitely be golfed. I'm having trouble converting '' to -1.. Ñ€¨€à (5 bytes) already gives the largest prime factors and 1 for primes, but '' for 0/1..

Try it online.

Explanation:

Ñ  # Divisors of each item in the input-list (including itself)   # [1,2,3,10] → [[1],[1,2],[1,2,3],[1,2,5,10]] €¨  # For €ach: Remove last item (so it's now excluding itself)   # [[1],[1,2],[1,2,3],[1,2,5,10]] → [[],[1],[1,2],[1,2,5]] €à  # For €ach: Get max   # [[],[1],[1,2],[1,2,5]] → ['',1,2,5]   ©  # Save the current list in the registry d  # Is it a number (1 if it's a number, 0 otherwise)   # ['',1,2,5] → [0,1,1,1]   1- # Subtract 1   # [0,1,1,1] → [-1,0,0,0] ® # Retrieve the saved list from the registry   + # Add both lists together   # ['',1,2,5] & [-1,0,0,0] → ['-1',1,2,5]  ï # Cast to integer # ['-1',1,2,5] → [-1,1,2,5] 

#05AB1E, 11 9 bytes

Ñ€¨€àDd<+ 

-2 bytes thanks to @Emigna, changing ©d1-®+ to Dd<+.

Only my second 05AB1E answer, so can definitely be golfed. I'm having trouble converting '' to -1.. Ñ€¨€à (5 bytes) already gives the largest prime factors and 1 for primes, but '' for 0/1..

Try it online.

Explanation:

Ñ # Divisors of each item in the input-list (including itself) # [1,2,3,10] → [[1],[1,2],[1,2,3],[1,2,5,10]] €¨ # For €ach: Remove last item (so it's now excluding itself) # [[1],[1,2],[1,2,3],[1,2,5,10]] → [[],[1],[1,2],[1,2,5]] €à # For €ach: Get max # [[],[1],[1,2],[1,2,5]] → ['',1,2,5] D # Duplicate the list d # Is it a number (1 if it's a number, 0 otherwise) # ['',1,2,5] → [0,1,1,1] < # Subtract 1 # [0,1,1,1] → [-1,0,0,0] + # Add both lists together # ['',1,2,5] and [-1,0,0,0] → ['-1',1,2,5] 
Added python highlighting for the comment
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394
Loading
Post Undeleted by Kevin Cruijssen
Finally fixed..
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394
Loading
Post Deleted by Kevin Cruijssen
Source Link
Kevin Cruijssen
  • 136.3k
  • 14
  • 155
  • 394
Loading