Skip to main content
Commonmark migration
Source Link

#05AB1E, 9 bytes

05AB1E, 9 bytes

7%É31αsΘ-

Same formula as @Adám's APL (Dyalog Unicode) answer, which I've also partially used in this earlier answer of mine.

Try it online.

Explanation:

7%         # Take the (implicit) input-integer modulo-7
  É        # Check whether it is odd (short for modulo-2)
   31α     # Take the absolute difference with 31
      s    # Swap to take the (implicit) input-integer again
       Θ   # 05AB1E truthify; 1 if n==1; 0 otherwise
        -  # And subtract this from the earlier number
           # (after which the result is output implicitly)

#05AB1E, 9 bytes

7%É31αsΘ-

Same formula as @Adám's APL (Dyalog Unicode) answer, which I've also partially used in this earlier answer of mine.

Try it online.

Explanation:

7%         # Take the (implicit) input-integer modulo-7
  É        # Check whether it is odd (short for modulo-2)
   31α     # Take the absolute difference with 31
      s    # Swap to take the (implicit) input-integer again
       Θ   # 05AB1E truthify; 1 if n==1; 0 otherwise
        -  # And subtract this from the earlier number
           # (after which the result is output implicitly)

05AB1E, 9 bytes

7%É31αsΘ-

Same formula as @Adám's APL (Dyalog Unicode) answer, which I've also partially used in this earlier answer of mine.

Try it online.

Explanation:

7%         # Take the (implicit) input-integer modulo-7
  É        # Check whether it is odd (short for modulo-2)
   31α     # Take the absolute difference with 31
      s    # Swap to take the (implicit) input-integer again
       Θ   # 05AB1E truthify; 1 if n==1; 0 otherwise
        -  # And subtract this from the earlier number
           # (after which the result is output implicitly)
Source Link
Kevin Cruijssen
  • 131.5k
  • 13
  • 144
  • 384

#05AB1E, 9 bytes

7%É31αsΘ-

Same formula as @Adám's APL (Dyalog Unicode) answer, which I've also partially used in this earlier answer of mine.

Try it online.

Explanation:

7%         # Take the (implicit) input-integer modulo-7
  É        # Check whether it is odd (short for modulo-2)
   31α     # Take the absolute difference with 31
      s    # Swap to take the (implicit) input-integer again
       Θ   # 05AB1E truthify; 1 if n==1; 0 otherwise
        -  # And subtract this from the earlier number
           # (after which the result is output implicitly)