Skip to main content
update code in accordance with explanation
Source Link
Adám
  • 31.1k
  • 3
  • 124
  • 287

APL (Dyalog Unicode), 2525 24 bytesSBCS

-1 thanks to Bubbler.

'dark'⊃'dark' 'light'⊃⍨2|+'light'⌽⍨+/⎕UCS⍞

Try it online!

 get text from stdin

⎕UCS convert to Universal Character Set code points

+/ sum

'dark' 'light'⌽⍨ use that to cyclically rotate the list of strings

 pick the first

APL (Dyalog Unicode), 25 bytesSBCS

-1 thanks to Bubbler.

'dark' 'light'⊃⍨2|+/⎕UCS⍞

Try it online!

 get text from stdin

⎕UCS convert to Universal Character Set code points

+/ sum

'dark' 'light'⌽⍨ use that to cyclically rotate the list of strings

 pick the first

APL (Dyalog Unicode), 25 24 bytesSBCS

-1 thanks to Bubbler.

⊃'dark' 'light'⌽⍨+/⎕UCS⍞

Try it online!

 get text from stdin

⎕UCS convert to Universal Character Set code points

+/ sum

'dark' 'light'⌽⍨ use that to cyclically rotate the list of strings

 pick the first

-1
Source Link
Adám
  • 31.1k
  • 3
  • 124
  • 287

APL (Dyalog Unicode), 25 bytesSBCS

  

Requires ⎕IO←0 (zero-indexing)1 thanks to Bubbler.

  
'dark' 'light'⊃⍨2|+/⎕UCS⍞

Try it online!Try it online!

 get text from stdin

⎕UCS convert to Universal Character Set code points

+/ sum

2| 2-mod

'dark' 'light'⊃⍨'light'⌽⍨ use that to pick fromcyclically rotate the list of strings

 pick the first

APL (Dyalog Unicode), 25 bytesSBCS

 

Requires ⎕IO←0 (zero-indexing).

 
'dark' 'light'⊃⍨2|+/⎕UCS⍞

Try it online!

 get text from stdin

⎕UCS convert to Universal Character Set code points

+/ sum

2| 2-mod

'dark' 'light'⊃⍨ use that to pick from the list of strings

APL (Dyalog Unicode), 25 bytesSBCS

 

-1 thanks to Bubbler.

 
'dark' 'light'⊃⍨2|+/⎕UCS⍞

Try it online!

 get text from stdin

⎕UCS convert to Universal Character Set code points

+/ sum

'dark' 'light'⌽⍨ use that to cyclically rotate the list of strings

 pick the first

Source Link
Adám
  • 31.1k
  • 3
  • 124
  • 287

APL (Dyalog Unicode), 25 bytesSBCS

Requires ⎕IO←0 (zero-indexing).

'dark' 'light'⊃⍨2|+/⎕UCS⍞

Try it online!

 get text from stdin

⎕UCS convert to Universal Character Set code points

+/ sum

2| 2-mod

'dark' 'light'⊃⍨ use that to pick from the list of strings