Skip to main content
Commonmark migration
Source Link

#Japt, 22 bytes

Japt, 22 bytes

Takes input as a 2D-array of integers for the space dimensions and a 1D-array of integers for the years. Outputs 2 for space only, 1 for time only, 3 for both and 0 for neither.

yâ mÊeÉ Ñ+!Jõ kVmgKi¹Ê

Try it

                           :Implicit input of 2D-array U=space and array V=time
y                          :Transpose U
 â                         :Deduplicate columns
   m                       :Map
    Ê                      :  Lengths
     e                     :All truthy (not 0) when
      É                    :  1 is subtracted
        Ñ                  :Multiply by 2
           J               :-1
            õ              :Range [-1,1]
              k            :Remove all the elements present in
               Vm          :  Map V
                 g         :    Signs of difference with
                  Ki       :    The current year
                    ¹      :End removal
                     Ê     :Length
         +!                :Negate and add first result

#Japt, 22 bytes

Takes input as a 2D-array of integers for the space dimensions and a 1D-array of integers for the years. Outputs 2 for space only, 1 for time only, 3 for both and 0 for neither.

yâ mÊeÉ Ñ+!Jõ kVmgKi¹Ê

Try it

                           :Implicit input of 2D-array U=space and array V=time
y                          :Transpose U
 â                         :Deduplicate columns
   m                       :Map
    Ê                      :  Lengths
     e                     :All truthy (not 0) when
      É                    :  1 is subtracted
        Ñ                  :Multiply by 2
           J               :-1
            õ              :Range [-1,1]
              k            :Remove all the elements present in
               Vm          :  Map V
                 g         :    Signs of difference with
                  Ki       :    The current year
                    ¹      :End removal
                     Ê     :Length
         +!                :Negate and add first result

Japt, 22 bytes

Takes input as a 2D-array of integers for the space dimensions and a 1D-array of integers for the years. Outputs 2 for space only, 1 for time only, 3 for both and 0 for neither.

yâ mÊeÉ Ñ+!Jõ kVmgKi¹Ê

Try it

                           :Implicit input of 2D-array U=space and array V=time
y                          :Transpose U
 â                         :Deduplicate columns
   m                       :Map
    Ê                      :  Lengths
     e                     :All truthy (not 0) when
      É                    :  1 is subtracted
        Ñ                  :Multiply by 2
           J               :-1
            õ              :Range [-1,1]
              k            :Remove all the elements present in
               Vm          :  Map V
                 g         :    Signs of difference with
                  Ki       :    The current year
                    ¹      :End removal
                     Ê     :Length
         +!                :Negate and add first result
added 855 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94

#Japt, 22 bytes

Takes input as a 2D-array of integers for the space dimensions and a 1D-array of integers for the years. Outputs 2 for space only, 1 for time only, 3 for both and 0 for neither.

e_ÊÉÃÑ+mÊeÉ Ñ+!Jõ kVmgKi¹Ê

Try itTry it

                           :Implicit input of 2D-array U=space and array V=time
y                          :Transpose U
 â                         :Deduplicate columns
   m                       :Map
    Ê                      :  Lengths
     e                     :All truthy (not 0) when
      É                    :  1 is subtracted
        Ñ                  :Multiply by 2
           J               :-1
            õ              :Range [-1,1]
              k            :Remove all the elements present in
               Vm          :  Map V
                 g         :    Signs of difference with
                  Ki       :    The current year
                    ¹      :End removal
                     Ê     :Length
         +!                :Negate and add first result

#Japt, 22 bytes

Takes input as a 2D-array of integers for the space dimensions and a 1D-array of integers for the years. Outputs 2 for space only, 1 for time only, 3 for both and 0 for neither.

e_ÊÉÃÑ+!Jõ kVmgKi¹Ê

Try it

#Japt, 22 bytes

Takes input as a 2D-array of integers for the space dimensions and a 1D-array of integers for the years. Outputs 2 for space only, 1 for time only, 3 for both and 0 for neither.

mÊeÉ Ñ+!Jõ kVmgKi¹Ê

Try it

                           :Implicit input of 2D-array U=space and array V=time
y                          :Transpose U
 â                         :Deduplicate columns
   m                       :Map
    Ê                      :  Lengths
     e                     :All truthy (not 0) when
      É                    :  1 is subtracted
        Ñ                  :Multiply by 2
           J               :-1
            õ              :Range [-1,1]
              k            :Remove all the elements present in
               Vm          :  Map V
                 g         :    Signs of difference with
                  Ki       :    The current year
                    ¹      :End removal
                     Ê     :Length
         +!                :Negate and add first result
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94

#Japt, 22 bytes

Takes input as a 2D-array of integers for the space dimensions and a 1D-array of integers for the years. Outputs 2 for space only, 1 for time only, 3 for both and 0 for neither.

yâ e_ÊÉÃÑ+!Jõ kVmgKi¹Ê

Try it