Skip to main content
added explanation
Source Link
wastl
  • 3.9k
  • 14
  • 33

Stax, 14 13 bytes

ü±p╞Ö*«òτ♀╣â▀

Run and debug it

Explanation (unpacked):

m|fc%c{vsH1?}U? Full program, implicit input-parsing
m               Map
 |fc%c            Get factorisation and length of it (0 and 1 yield [])
      {     } ?   If length != 0:
       v            Decrement
           ?        If still != 0:
        sH            Last element of factorisation
           ?        Else:
          1           Push 1
              ?   Else:
             U      Push -1

Pseudocode inside map:

f = factorisation(i)
l = length(f)
if l:
    if --l:
        return f[-1]
    else:
        return 1
else:
    return -1

Stax, 14 13 bytes

ü±p╞Ö*«òτ♀╣â▀

Run and debug it

Stax, 14 13 bytes

ü±p╞Ö*«òτ♀╣â▀

Run and debug it

Explanation (unpacked):

m|fc%c{vsH1?}U? Full program, implicit input-parsing
m               Map
 |fc%c            Get factorisation and length of it (0 and 1 yield [])
      {     } ?   If length != 0:
       v            Decrement
           ?        If still != 0:
        sH            Last element of factorisation
           ?        Else:
          1           Push 1
              ?   Else:
             U      Push -1

Pseudocode inside map:

f = factorisation(i)
l = length(f)
if l:
    if --l:
        return f[-1]
    else:
        return 1
else:
    return -1
improved score
Source Link
wastl
  • 3.9k
  • 14
  • 33

Stax, 1414 13 bytes

Ç╗♦πgHø╚!ìs_├⌡ü±p╞Ö*«òτ♀╣â▀

Run and debug itRun and debug it

Stax, 14 bytes

Ç╗♦πgHø╚!ìs_├⌡

Run and debug it

Stax, 14 13 bytes

ü±p╞Ö*«òτ♀╣â▀

Run and debug it

Source Link
wastl
  • 3.9k
  • 14
  • 33

Stax, 14 bytes

Ç╗♦πgHø╚!ìs_├⌡

Run and debug it