| Bytes | Lang | Time | Link |
|---|---|---|---|
| 046 | AWK | 250701T002826Z | xrs |
| 069 | JavaScript Node.js | 250630T020929Z | Steve Be |
| 053 | Swift 6 | 250629T142153Z | macOSist |
| 6462 | Commodore 64 Basic 62 Bytes | 250629T072217Z | davehx |
| 079 | Common Lisp | 250608T012054Z | Mark Ree |
| nan | AArch64 machine code Linux elf64littleaarch64 | 250605T133208Z | 鳴神裁四点一号 |
| 055 | Forth | 250608T014509Z | Mark Ree |
| 011 | Vyxal 3 | 250606T112728Z | Themooni |
| nan | Commodore 64 Assembler | 250605T191730Z | Jani Joe |
| 065 | Sinclair Spectrum BASIC | 250605T140209Z | Pobulous |
| 041 | Janet | 250605T090941Z | Adam |
| 080 | ZX81 BASIC | 250604T211848Z | Luis Pie |
| nan | 240502T155251Z | Shaun Be | |
| nan | Perl 5 p | 240501T142203Z | Xcali |
| 034 | Zsh | 240501T134400Z | GammaFun |
| nan | 230104T224540Z | bigyihsu | |
| 131 | Rust | 240501T130119Z | Dornteuf |
| 009 | Thunno 2 B | 230607T075017Z | The Thon |
| 109 | Scala 3 | 230603T064330Z | 138 Aspe |
| 032 | Rattle | 220219T000040Z | d01 |
| 013 | Nibbles | 230108T191610Z | whqwert |
| 3635 | x8616 machine code | 220218T145611Z | 640KB |
| 042 | Raku | 230108T201721Z | Mark Ree |
| 031 | jq Rr | 230106T135355Z | pmf |
| 029 | Ly | 230105T064553Z | cnamejj |
| nan | 230104T161830Z | The Thon | |
| 031 | Haskell + hgl | 230104T154449Z | Wheat Wi |
| 025 | K ngn/k | 221012T125021Z | oeuf |
| nan | Fig | 221012T121213Z | Seggan |
| 138 | Acc!! | 220218T185618Z | DLosc |
| 035 | Factor + math.unicode | 220218T171205Z | chunes |
| 080 | Shue | 220218T170849Z | AnttiP |
| 011 | Vyxal | 220218T153700Z | Seggan |
| 043 | Julia 1.0 | 220218T143705Z | MarcMush |
| 037 | J | 220218T131349Z | sinvec |
| 021 | PlatyPar | 151218T234055Z | Cyoce |
| 016 | K oK | 171114T142945Z | Adá |
| 040 | Python 3 | 200524T185715Z | user9403 |
| 011 | Stax | 200607T062945Z | user9206 |
| 011 | 05AB1E | 200607T045109Z | user9206 |
| 024 | APL Dyalog Unicode | 181224T184713Z | Adá |
| 012 | Keg | 200524T073451Z | lyxal |
| 042 | C# Visual C# Interactive Compiler | 151115T153309Z | Yytsi |
| 025 | Runic Enchantments | 181225T000701Z | Draco18s |
| 045 | Kotlin | 181224T192226Z | snail_ |
| 063 | F# Mono | 181224T175120Z | dana |
| 013 | 05AB1E legacy | 181224T105053Z | krinisto |
| 016 | Japt | 180601T044411Z | Bubbler |
| 057 | Chip | 171207T213217Z | Phlarx |
| 011 | Jelly | 171114T174739Z | Erik the |
| 038 | QBIC | 171114T173037Z | steenber |
| 063 | Tcl | 171005T205155Z | sergiol |
| 042 | Labyrinth | 151114T101309Z | Martin E |
| 178 | Java | 170330T152049Z | user6333 |
| 078 | AHK | 170330T140519Z | Engineer |
| 066 | SmileBASIC | 170126T221828Z | 12Me21 |
| 026 | ><> Fish | 161115T113712Z | Teal pel |
| 126 | Batch | 151118T003644Z | Neil |
| 045 | JavaScript ES6 | 151113T233653Z | Downgoat |
| 045 | PowerShell | 151116T152801Z | AdmBorkB |
| 053 | Lua | 151219T000536Z | Cyv |
| 020 | MATL | 151218T212923Z | flawr |
| 036 | Bash + coreutils | 151113T230521Z | Digital |
| 124 | Java | 151113T225738Z | SuperJed |
| 022 | Japt | 151113T234808Z | ETHprodu |
| 019 | Seriously | 151113T222419Z | user4594 |
| 015 | GS2 | 151113T224844Z | Dennis |
| 040 | Bash | 151118T005112Z | Neil |
| 056 | JavaScript ES6 | 151115T225745Z | Cyoce |
| 080 | Prolog | 151117T150130Z | Emigna |
| 069 | Bash | 151117T145744Z | Tyzoid |
| 025 | Burlesque | 151117T115120Z | mroman |
| 086 | Marbelous | 151117T073241Z | Sparr |
| 063 | Clojure | 151117T045020Z | dmh |
| 207 | Batch | 151115T224118Z | Conor O& |
| 056 | Haskell | 151114T044349Z | ankh-mor |
| 090 | Common Lisp | 151116T221653Z | Joshua T |
| 040 | PHP | 151114T000504Z | insertus |
| 100 | Go | 151116T150836Z | Kristoff |
| 075 | Python 2 | 151116T142316Z | Zac Crit |
| 021 | Vitsy | 151115T142245Z | Addison |
| 017 | O | 151116T031657Z | jado |
| 049 | C | 151114T023811Z | xsot |
| 163 | R | 151114T225836Z | syntonic |
| 127 | Beam | 151115T231855Z | MickyT |
| nan | CMD.EXE | 151114T011939Z | Neil |
| 021 | GolfScript | 151115T220331Z | Ilmari K |
| 132 | Brainfuck | 151115T162358Z | Sp3000 |
| 018 | CJam | 151113T221623Z | Peter Ta |
| 066 | Brian & Chuck | 151115T122014Z | Sp3000 |
| 046 | C | 151115T152639Z | lynn |
| 027 | Perl | 151115T043841Z | Dennis |
| 049 | Scala | 151115T124057Z | V.G. |
| 065 | R | 151115T065453Z | Alex A. |
| 031 | ><> | 151115T040322Z | Sp3000 |
| 031 | Befunge93 | 151113T234227Z | El'e |
| 2634 | 𝔼𝕊𝕄𝕚𝕟 | 151114T024915Z | Mama Fun |
| 059 | SpecBAS | 151114T145459Z | Brian |
| 025 | Mouse | 151114T064201Z | Alex A. |
| 056 | ShapeScript | 151114T031153Z | Dennis |
| 022 | Gol><> | 151114T031009Z | Sp3000 |
| nan | BotEngine | 151113T235404Z | SuperJed |
| 055 | C | 151113T231145Z | user4594 |
| 066 | TIBASIC | 151114T010435Z | lirtosia |
| 091 | ShadyAsFuck | 151114T003221Z | flawr |
| 036 | Ruby | 151113T235753Z | daniero |
| 235 | Turing Machine Code | 151114T000926Z | SuperJed |
| 032 | Hexagony | 151113T232706Z | Martin E |
| 023 | TeaScript | 151113T233232Z | Downgoat |
| 024 | Minkolang 0.12 | 151113T232537Z | El'e |
| 038 | Python 2 | 151113T222859Z | izzyg |
| 025 | Microscript | 151113T231337Z | SuperJed |
| 037 | sed | 151113T223451Z | Digital |
| 051 | Matlab | 151113T230259Z | flawr |
| 045 | Python 2 | 151113T221705Z | user4594 |
| 018 | Pyth | 151113T222534Z | izzyg |
AWK, 46 bytes
@load"ordchr";$0=(ord($1)+$2)%2?"light":"dark"
@load"ordchr"; # char lib
$0= # set output
(ord($1) # ascii code for first char
+$2) # plus second char #
%2? # even or odd
"light":"dark" # text to output
JavaScript (Node.js), 69 bytes using STDIN and STDOUT
process.stdin.on('data',([f,r])=>console.log((f^r)&1?'light':'dark'))
Swift 6, 53 bytes
print(Int(readLine()!,radix:35)!%2>0 ?"dark":"light")
Try it on... Compiler Explorer (because SwiftFiddle doesn't support stdin).
Commodore 64 Basic : 62 Bytes
Taking the ascii value of the left and right character from the input, adding them, ANDing with 1, then an if statement with an END to prevent both responses showing
Common Lisp, 82 80 79 bytes
(princ(nth(mod(apply #'+(map 'list #'char-code(read-line)))2)'("dark""light")))
Common Lisp, 76 bytes
If we loosen the requirements to permit uppercase output instead of requiring lowercase, we can use symbols instead of strings and save three bytes:
(princ(nth(mod(apply #'+(map 'list #'char-code(read-line)))2)'(dark light)))
AArch64 machine code (Linux) (elf64-littleaarch64), .text: 60 + .data: 10 = 70 bytes
Full program in assembly. Assembled and linked with GNU Binutils.
$ objdump -dsh 00
00: file format elf64-littleaarch64
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 0000003c 00000000004000b0 00000000004000b0 000000b0 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 0000000a 00000000004100ec 00000000004100ec 000000ec 2**0
CONTENTS, ALLOC, LOAD, DATA
Contents of section .text:
4000b0 e1030091 420080d2 e80780d2 010000d4 ....B...........
4000c0 29004079 2a210833 2b010a4a 6b010012 ).@y*!.3+..Jk...
4000d0 6b011e33 200080d2 a1000810 21000b8b k..3 .......!...
4000e0 a20080d2 080880d2 010000d4 ............
Contents of section .data:
4100ec 6461726b 006c6967 6874 dark.light
Disassembly of section .text:
00000000004000b0 <_start>:
4000b0: 910003e1 mov x1, sp
4000b4: d2800042 mov x2, #0x2 // #2
4000b8: d28007e8 mov x8, #0x3f // #63
4000bc: d4000001 svc #0x0
4000c0: 79400029 ldrh w9, [x1]
4000c4: 3308212a bfxil w10, w9, #8, #1
4000c8: 4a0a012b eor w11, w9, w10
4000cc: 1200016b and w11, w11, #0x1
4000d0: 331e016b bfi w11, w11, #2, #1
4000d4: d2800020 mov x0, #0x1 // #1
4000d8: 100800a1 adr x1, 4100ec <_start+0x1003c>
4000dc: 8b0b0021 add x1, x1, x11
4000e0: d28000a2 mov x2, #0x5 // #5
4000e4: d2800808 mov x8, #0x40 // #64
4000e8: d4000001 svc #0x0
Original source
.text
.globl _start
_start:
// read()
// Implicit mov x0,0
mov x1,sp
mov x2,2
mov x8,63
svc 0
// w11 := (input[0]^input[1])&1
ldrh w9,[x1] // Get input characters as uint16_t
bfxil w10,w9,8,1 // Get bottom one bit of first character to store to w10
eor w11,w9,w10 // Take xor
and w11,w11,1
// w11 *= 5
bfi w11,w11,2,1 // w11 |= w11<<2
// write()
mov x0,1
adr x1,.L.msg
add x1,x1,x11 // This loads either "dark\0" or "light"
mov x2,5
mov x8,64
svc 0
// Unclean exit
.data
.L.msg:
.ascii "dark\0light"
Demo in Termux
$ as -o 00.o 00.s && ld -o 00 00.o
$ for x in b1 g6 d4; do echo "($x)"; echo "$x" | ./00; echo; done
(b1)
lightIllegal instruction
(g6)
lightIllegal instruction
(d4)
darkIllegal instruction
$
History
-8 bytes by removing mov x0,0 and swapping dark and light to remove add w11,w11,1
-2 bytes by storing input to [sp] so I need not using .bss section
Vyxal 3, 11 bytes
O∑⍢"≓ʎℂ+”½i
v3 port of seggan's answer
O∑⍢"≓ʎℂ+”½i
⍢ # parity of
∑ # summed
O # codepoints
i # index into
"≓ʎℂ+” # compressed string "darklight"
½ # split in 2 halves
💎
Created with the help of Luminespire.
<script type="vyxal3">
O∑⍢"≓ʎℂ+”½i
</script>
<script>
args=[["b1"],["g6"],["d4"]]
</script>
<script src="https://themoonisacheese.github.io/snippeterpreter/snippet.js" type="module"/>
Commodore 64 Assembler, 33 Bytes (6502/KickAssembler)
Explanation
This code uses several tricks to reduce its footprint:
- Located into a short block of free memory just below $0300, so that the last two bytes of the file can overwrite the BASIC warm start pointer address at $0300-$0301. This allows us to autostart our program every time KERNAL wants to jump to BASIC warm start routine (i.e. every time after the user has entered a line in BASIC screen), while letting KERNAL/BASIC to still handle the keyboard input.
- Code reads the input from zero page addresses $45 and $46 instead of the keyboard buffer in $0200->. This saves two bytes.
- For interpreting the result, we're using the odd/even method like many others. PETSCII codes for characters A-H are $41-$48, for numbers 1-8 $31-$38. Thus we can determine if the result is odd or even simply by XORing the two inputs together and checking if the least significant bit is 1 (odd, light) or 0 (even, dark) by rotating it into the Carry flag. Reading the input values, XORing them and pushing the result to Carry takes just five bytes in total.
- Instead of writing our own code for printing the result string on screen, we take advantage of BASIC warm start routine into which we'd need to go after our code anyway, and which would usually, after checking and printing an error if any, print the string
READY.. We just set the string pointers in registers A and Y to point to our own result string, and enter the BASIC warm start routine from just after where the pointer toREADY.would have been set. As a nice side bonus, this also skips printing the error message which would always happen asA1etc. are not valid BASIC commands. - After loading the 'light' string pointer to A, instead of jumping (3 bytes) or branching (2 bytes) over the setup of 'dark' string pointer we add a single byte
$2c. This is the code for theBIT absolutecommand, and thelda #<darkbecomes the 16bit address in the BIT command, effectively skipping the lda. This is very commonly used in e.g. Commodore's own KERNAL, and in this occasion saves 1-2 bytes.
Code
* = $0302-33
.encoding "petscii_upper"
dark: .te "DARK" ; .by 0 // Messages to print instead of 'READY.'
light: .te "LIGHT" ; .by 0 // Messages must be null terminated.
start: jsr $a644 // Perform NEW without exit on error. BASIC warm start crashes if
// this is not done after loading our interjecting code.
lda $45 // Load 1st char to A.
eor $46 // EOR it with 2nd char.
ror // Roll LSB (i.e. if result was ODD or EVEN) into Carry.
bcc godark // If C is clear (i.e. result was EVEN), square is dark.
lda #<light // Otherwise load light text pointer lo byte to A.
.by $2c // 'BIT abs' to skip loading dark text pointer lo byte.
godark: lda #<dark // Load dark text pointer lo byte to A.
ldy #$02 // Load text pointers hi byte to Y.
jmp $a478 // We're done. Continue to BASIC warm start, but skip error checking
// and print our result instead of READY.
.wo start // Put our routine's start address to $0300-$0301. When KERNAL does
// 'JMP ($0300)', it'll jump to our code instead of BASIC warm start.
Size Breakdown
- 5 bytes for determining if the square is light or dark.
- 9 bytes for setting up the message pointer according to result above.
- 8 bytes of KERNAL/BASIC related overhead (injecting the code before jump to BASIC warm start, executing NEW, jump to warm start).
- 11 bytes of data (LIGHT and DARK result strings).
Bonus
Instead of printing out the word LIGHT or DARK based on the result, this code changes the screen border colour to white or black. While not a valid answer for the challenge, it still clearly indicates the colour, and takes just 17 bytes, so I thought I'll share it in case someone finds it interesting.
* = $0302-17
start: jsr $a644
lda $45
eor $46
and #$01
sta $d020
jmp $a474
.wo start
Sinclair Spectrum BASIC, 65 bytes
65 bytes in RAM - 23755-23819
10 LET z= INT EXP SGN PI : INPUT s$: LET c= CODE s$+ CODE s$(Z):
LET c=c/Z= INT (c/Z): PRINT "dark" AND c;"light" AND NOT c
SGN PI = 1 - using 2 bytes of RAM instead of 7
INT EXP SGN PI = 2 - usign 4 bytes RAM instead of 7, assigned to variable as used twice.
Keywords use one byte, all spaces are part of keywords
Janet, 41 bytes
(prin(["dark""light"](%(sum(getline))2)))
Interestingly, (sum(getline)) cannot be replaced with (+;(getline)) because strings cannot be spliced.
ZX81 BASIC, 80 chars
10 INPUT A$
20 LET B$="DARK LIGHT"
30 LET N=(CODE A$(1)+CODE A$(2)-1)/2
40 LET N=5*((N-INT(N))>0)
50 PRINT B$(N+1 TO 5+N)
ZX81 BASIC is tokenized, so each keyword count as 1 and the spaces between line numbers and keywords are generated, so it doesn't count as chars.
You can only write one BASIC statement for each line. It works on 1k ZX81!
Commodore BASIC
In order to solve this problem, I started with a simple and non-minimised listing, which should better explain some of the logic involved (and my thinking too), which looked like this:
100 dim a$(7, 7), s$(1), b$
110 let s$(0)="dark"
120 let s$(1)="light"
130 for x=0 to 7
140 for y=0 to 7
150 let a$(x,y)=s$(yand1)
160 next y
170 let b$=s$(0)
180 let s$(0)=s$(1)
190 let s$(1)=b$
200 next x
210 input b$
220 on -(len(b$)<>2) goto 210
230 print a$(asc(left$(b$, 1))-65, val(right$(b$, 1))-1)
As one may have guessed, I've set up a two dimensional zero indexed string array with DARK and LIGHT mapping to a standard Chess board.
The listing then takes a string input into the B$ variable, and if the string length is 2 it checks the first character of B$ for the value of the character minus 65, and the second character, and the second character of B$ as its numeric value from 1 - 8 inclusive, minus one to match the zero indexed matrix. It will then output to the screen either DARK or LIGHT. A golfed solution without the boundary check of the input would therefore be:
Solution 1, ~138 BASIC Bytes
0s$(0)="dark":s$(1)="light":forx=0to7:fory=0to7:a$(x,y)=s$(yand1):next:b$=s$(0)
1s$(0)=s$(1):s$(1)=b$:next:inputb$:?a$(asc(left$(b$,1))-65,val(right$(b$,1))-1)
And after all of this I thought of a better way of completing this task, which I will update later (also update with the byte count and screen shot). Note that to enter this into real hardware, some BASIC keyword abbreviations may be needed on the Commodore C64 or 40 columns CBM/PET.
Zsh, 34 bytes
a=(light dark)
<<<$a[1+19#`<&0`%2]
This is a port of Neil's Bash answer, and is actually a good showcase of why Zsh tends to golf better than Bash, even when a lot of its advanced features aren't used.
- Zsh saves 2 bytes by using
<<<instead ofecho - Zsh saves 4 bytes by using
`<&0`instead ofread x;andx - Zsh saves 2 bytes by not needing
{}. - Zsh loses 2 bytes because arrays start at
1, so1+is needed.
Go, 97 bytes
package main
import."os"
func main(){o:="light"
if(Args[1][0]+Args[1][1])%2<1{o="dark"}
print(o)}
-3 byte improvement over @Kristoffer Sall-Storgaard's answer.
Takes input from command-line arguments. Prints to STDERR.
With more flexible IO format, 42 bytes
func(s string)int{return int(s[0]+s[1])%2}
- Use a function instead of a full program
- Return a value instead of printing
- Return an int (1 for "light", 0 for "dark") instead of a string
Rust, 131 bytes
fn main(){let b=std::io::stdin().lines().next().unwrap().unwrap().into_bytes();print!("{}",if(b[0]^b[1])%2<1{"dark"}else{"light"})}
Thunno 2 B, 9 bytes
S‘ɲ⁺/^‘½İ
Explanation
S‘ɲ⁺/^‘½İ # Implicit input, converted to ordinals by B flag
S # Sum the list of ordinals of the input
‘ɲ⁺/^‘ # Push dictionary compressed string "lightdark"
½ # Halve it to get ["light", "dark"]
İ # 1-based modularly index the sum into this list
# Implicit output
Scala 3, 109 bytes
Golfed version. Attempt this online!
val Q=Integer.parseInt(scala.io.StdIn.readLine,35)%2
println("ldiagrhkt".grouped(2).map(_.apply(Q)).mkString)
Ungolfed version. Attempt this online!
import java.lang.Integer
import scala.io.StdIn
object Main {
def main(args: Array[String]): Unit = {
val input = StdIn.readLine()
val index = Integer.parseInt(input, 35) % 2
val s = "ldiagrhkt"
println(s.zipWithIndex.collect{ case (c, i) if i % 2 == index => c }.mkString)
}
}
Rattle, 32 bytes
dark&light&\|!I<gI0nr`gI1R1+\%b`
Explanation
This essentially just takes the sum of the number and the ASCII value of the letter, sees if it's even or odd, and outputs "dark" or "light" accordingly.
Nibbles, 15 14 13 bytes
=+.@o$%`D-21~8fd905cff4e
Explanation
@ - input
. o$ - as codepoints
+ - sum
= %`D-21~8fd905cff4e - index in compressed list ["light", "dark"] (wrapped)
-2 bytes thanks to Dominic van Essen
x86-16 machine code, IBM PC DOS, 36 35 bytes
00000000: b408 cd21 8ad0 cd21 32c2 ba1e 01d0 e873 ...!...!2......s
00000010: 02b2 18b4 09cd 21c3 6c69 6768 7424 6461 ......!.light$da
00000020: 726b 24 rk$
Listing:
B4 08 MOV AH, 8 ; DOS read char from STDIN
CD 21 INT 21H ; first char in AL
8A D0 MOV DL, AL ; move to DL
CD 21 INT 21H ; second char in AL
32 C2 XOR AL, DL ; XOR ASCII values to get low bit
BA 011F MOV DX, OFFSET D ; default to "dark" string
D0 E8 SHR AL, 1 ; put low bit into CF
73 03 JNC TO_STDOUT ; if 1, output "dark"
B2 18 MOV DL, LOW OFFSET L ; otherwise, "light"
TO_STDOUT:
B4 09 MOV AH, 9 ; DOS write string to STDOUT
CD 21 INT 21H ; DX written to STDOUT
C3 RET ; return to DOS
L DB 'light$'
D DB 'dark$'
Just does a simple XOR on the ASCII values of the two chars and the lowest order bit determines which string to output.
Standalone executable DOS program (since STDIN/STDOUT is a requirement).
-1 byte thx to @l4m2!
Ly, 29 bytes
ir2%+2%[p"light"&o;]p"dark"&o
This just does module math on the column number to pick a light/dark squares. The even/odd-ness of the row shifts the calculations.
ir - read 2 digit code in as codepoints, reverse stack
2% - even or odd row?
+ - add as offset to column
2% - even or odd?
[p ]p - code block run if odd
"light"&o; - print "light" and exit
"dark"&o - print "dark"
Thunno B, \$17 \log_{256}(96) \approx\$ 14 bytes
S"ldiagrhkt"ZlsAH
S"ldiagrhkt"ZlsAH # Implicit input. The B flag gets the ordinals of each character in the input.
S # Sum the ordinals
"ldiagrhkt" # String "ldiagrhkt"
Zl # Uninterleaved to get ['light', 'dark']
sAH # Index into this list (1-based, modular)
# Implicit output
Haskell + hgl, 31 bytes
main=io$(Wr"dark light"!)<mF Or
Explanation
All in all we sum the code points and select the correct color based on its value mod 2.
Orconverts a character to its codepointmF Orfolds along a string to sum up the codepointsWrsplits the string"dark light"along spaces.!indexes the string wrapping around if the index is greater than 1.ioconverts a function into a complete programmain=sets the main and is required by Haskell for complete programs
Reflection
hgl is not good for complete programs. It has the 5 byte penalty forced by a main declaration, and requires some type glue, in this case io, to work. 8 bytes here are devoted to making this a complete program.
This challenge also has stringent io which contributes a lot to the size of the program.
With that in mind the actual logic here is 5-6 bytes which is alright.
Some reflections:
- hgl has no string compression. Obviously, since it can't have dedicated syntax, it wouldn't be as effective as other golfing languages, and it would also be a large undertaking to implement it. But it potentially could have saved in this challenge.
- There's an argument to be had that
Wrshould be 1 byte. If you want to make lists of strings,Wr"..."is usually the way to go. (!)does not seem to have a prefix variant. It wouldn't help here, even if it were 1 byte, but it should probably exist with a 2-byte name.
K (ngn/k), 25 bytes
{$[2!+/x;"light";"dark"]}
Simple if statement.
Explanation:
{$[2!+/x;"light";"dark"]} Main function. Takes x as input
$[ ] If
+/x Sum of ASCII charcodes of x
! Modulo by
2 2
; If the result is 1 (i.e. an odd number)
"light" Return string "light"
;"dark" Else, return string "dark"
Fig, \$11\log_{256}(96)\approx\$ 9.054 bytes
iHD,[jn("OS
iHD,[jn("OS
S # Sum charcodes
O # Is odd?
i # Use that as the index for...
D,[jn(" # The compressed string "darklight"
H # Halved, yielding ["dark", "light"]
Acc!!, 138 bytes
N+N
Count i while _%2 {
Write 108
Write 105
Write 103
Write 104
Write 116
0
}
Count i while _ {
Write 100
Write 97
Write 114
Write 107
0
}
Pseudocode
Read two characters, add their codepoints, and store the result in the accumulator
While the accumulator value is odd:
Write l, i, g, h, t
Set the accumulator to 0
While the accumulator value is nonzero:
Write d, a, r, k
Set the accumulator to 0
Shue, 80 bytes
light
dark
bb=
b=light
=dark
a=
c=
d=b
e=
f=b
g=
h=b
1=
2=b
3=
4=b
5=
6=b
7=
8=b
Pretty sure this is optimal. The empty string represents even letters/integers and a "b" represents odd letters/integers.
Vyxal, 11 bytes
C∑₂`⟇ǎ↔β`½i
Explanation:
C∑₂`⟇ǎ↔β`½i ; takes the coordinate
C ; character values of the input
∑ ; sum of char values
₂ ; is even?
`⟇ǎ↔β` ; compressed string "lightdark"
½ ; split in half (yielding ["light", "dark"])
i ; index into
J, 48 40 37 bytes
>@{&('dark';'light')@{:@#:@+/@(a.&i.)
− 8 bytes by replacing (-2&*@<.@%&2) with {:@#:
− 3 bytes by removing @>:
PlatyPar, 21 bytes
X,u#^2%?"dark"\"light
Explanation
X,u#^ ## charcode of the letter XOR the number
2%? \ ## if it is odd
"dark" ## output "dark"
"light ## else output "light
K (oK), 16 bytes
`dark`light 2!+/
+/ sum the (code points of the) argument
2! mod-2
`dark`light select that from this list of symbols
Python 3, 40 bytes
print('ldiagrhkt'[int(input(),35)%2::2])
Stax, 11 bytes
ĺÉ╨φr°mißâ
Explanation
|+ Sum the codepoints of the input string
`ASbEx!"` Compressed string "dark light"
j Split on spaces. ["dark","light"]
@ Fetch at the corresponding index (modular)
05AB1E, 11 bytes
Port of Dennis's GS2 answer.
“–°‡Ž“#IÇOè
Explanation
“–°‡Ž“ Compressed string "dark light"
# Split on spaces
I Take an input
Ç Codepoints
O Sum
è Modular index into the original list
APL (Dyalog Unicode), 25 24 bytesSBCS
-1 thanks to Bubbler.
⊃'dark' 'light'⌽⍨+/⎕UCS⍞
⍞ 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
C# (Visual C# Interactive Compiler) - 122 42
Write((Read()+Read())%2<1?"dark":"light");
- Reads from STDIN
- Format is simply a1
Thanks to @dana for the change from C# to the current one & golfing a ton of bytes! :)
Runic Enchantments, 25 bytes
iu+2%1(8*?"light"@"dark"@
How it works
> implicit entry
i read string from input
u break the string into characters
+ add them together
2% modulo 2
1( compare with 1
8* multiply the result (true -> 8, false -> 0)
? pop x, if x is truthy, skip x characters
"light"@ output light if false
"dark"@ ouput dark if true
05AB1E (legacy), 13 bytes
“–°‡Ž“#I35öÈè
Here is a golf with your own language :)
Explanation
“–°‡Ž“ : compressed: "dark light"
# : split by space
è: select the 0th or 1st element based on {
I35ö : take the input and convert it to int from base 35
È : 1 if even else 0
}
Japt, 16 bytes
`äKrk`qe g~Uxc
How it works
`äKrk`qe g~Uxc
`äKrk` Compressed literal for "lightedark"
qe Split with "e"
g Take the element at the index (wrapping)...
U Input array of chars
xc Sum the chars' charcodes
~ Take bitwise not, in order to swap parity
The string array compression trick did quite a job here.
Chip, 57 bytes
*gS!~s
fA.Z\ZZZvt
cZ}x< eab
>--^/vZZvZZvt
ZZZd ddac ce
ab
XOR's the low bit of each input (like most if not all other answers) to make the decision. Outputs dabh`, bitwise-OR'd with hhe`t for light or ``pc for dark. (Dark also exits one byte early).
QBIC, 38 bytes
~(asc(;)+!_sA,-1|!)%2|?@Light`\?@Dark
Explanation
~( IF
asc( ) the ascii value of
; the input string (of the input "b1" only the first char is evaluated by asc())
+ _s , | plus a substring of
A A$ (the input, this was assigned to A$ by ;)
-1 taking only the first char from the right
! ! and cast this to num
)%2 MODULO 2 (is non-zero, implicit)
|?@Light` THEN PRINT the literal "Light"
\?@Dark ELSE PRINT "Dark" (no terminating ` is needed at EOF)
Labyrinth, 48 46 45 42 bytes
Thanks to Sp3000 for saving two bytes.
-,"
#
%0:::8.5.3.4.116.@
1
00.97.114.107.@
Explanation
The beginning of the code is a funny dead end. Remember that Labyrinth assumes an infinite number of zeroes when it requires operands at the bottom of the stack. The code starts one the - going right, which tries to subtract two numbers, so the stack becomes:
[ ... 0 ]
Then , reads the first character, a say:
[ ... 0 97 ]
The " is a no-op, but this is also a dead-end so the instruction pointer turns around and starts going to the left. Then ` reads the other character, 2 say:
[ ... 0 97 50 ]
This time, - subtracts those two numbers:
[ ... 0 47 ]
The IP now follows the bend of the "corridor". The # gets the stack depth, ignoring the implicit zeroes, which conveniently happens to be 2:
[ ... 0 47 2 ]
And % computes the modulo:
[ ... 0 1 ]
At this point, the IP is at a junction. If the top of the stack is zero, it will move straight ahead, where 100.97.114.107.@ prints dark. But if the top of the stack is non-zero (specifically, 1), it will move to the right, where 0:::8.5.3.4.116.@ prints light (note that we can omit the leading 1, because there is already a 1 on the stack, and we can save on the repeated 10 in 108, 105, 103, 104 by making a few copies of the 10 when we first get there).
Java, 178 bytes
interface z{static void main(String[]a){int b=a[0].charAt(0)-'a',c=a[0].charAt(1)-'0';if(b%2==0&&c%2!=0||b%2!=0&&c%2==0)System.out.print("dark");else System.out.print("light");}}
Takes input as first argument.
Ungolfed:
interface z {
static void main(String[]a) {
int b = a[0].charAt(0) - 'a', // Convert value from a to value from 0...7
c = a[0].charAt(1) - '0'; // Get number
if (b % 2 == 0 && c % 2 != 0 || // If b is divisible by 2 and c is divisible by 2 or
b % 2 != 0 && c % 2 == 0) // b is not divisible and c is divisible
System.out.print("dark"); // output dark
else System.out.print("light"); // else output light
}
}
AHK, 78 bytes
a=%1%
If Mod(Asc(a)+Asc(SubStr(a,2)),2)=1
s=light
Else
s=dark
FileAppend,%s%,*
AHK uses 1 as the name for the first parameter so you have to assign to a different name before you use it in functions. Otherwise, it'll think you mean the value 1 and not the variable named 1. Also, the only way to report to STDOUT is by using FileAppend with * as the file name.
SmileBASIC, 66 bytes
INPUT L$N=INSTR(@bdfh,L$)<0!=VAL(POP(L$))MOD 2?"light"*N;"dark"*!N
explanation:
INSTR(@bdfh,L$)<0 'Checks if L$ is b,d,f,h. @bdfh is a label, equivalent to the string "@bdfh"
!= 'used as a logical XOR, which SB doesn't have.
VAL(POP(L$))MOD 2 'Checks if the row is odd. Also removes the second character of L$,
'which makes the first check shorter since SB evaluates right to left.
?"light"*N;"dark"*!N 'this turned out to be shorter than using IF/THEN/ELSE.
><> Fish 26 bytes
d"darkthgil"ii+2%?!rooooo;
A spin on the already posted fish code by sp3000.
It uses the same based checking with mod but with a few changes.
Using 1 line allows us to save 6 bytes (1 for the new line, 2 for directional instructions and 3 for the jump instructions)
Lose 1 byte to placing a [CR] onto the stack but it allows us to use 5 prints on both answers.
Lose 1 byte to reversing the stack [r] when needed for an answer.
Lastly putting both answers on the stack in 1 string allows us to save 2 bytes not having to use ["] twice.
Batch, 147 127 126 bytes
@set/pi=
@set/aj=%i:~1%%%2
@goto %i:~,1%
:a
:c
:e
:g
@set/aj=1-j
:b
:d
:f
:h
@if %j%==0 (echo dark)else echo light
Uses goto as a form of switch to increment the row number on alternate columns.
Edit: Saved 15 bytes by reducing the column modulo two up front and then using 1-j to flip between dark and light on alternate columns. Saved 2 bytes by removing some unnecessary ()s. Saved 3 4 bytes by removing some unnecessary spaces.
JavaScript (ES6), 45 bytes
alert(parseInt(prompt(),35)%2?"dark":"light")
PowerShell, 52 46 45 bytes
("dark","light")[(+($a="$input")[0]+$a[1])%2]
Pretty ugly due to how we have to parse the STDIN input (which, in PowerShell, is weird). The special variable $input is present only if items get piped in, we encapsulate that into a string, and save it into $a. Then, we use the same math trick as other answers to calculate out whether the input is even or odd, and use that to index into our "dark" or "light" output array.
Edit -- saved 6 bytes by using + to cast $a[0] instead of [int]. Saved an additional byte by changing where $a is created by using a code block.
Lua, 53 Bytes
l,n=(...):byte(1,2)print(l%2==n%2 and"dark"or"light")
Pretty simple, takes command line input through ... and assigns variables l and n to the first and second byte of the input and then checks the ASCII value of each. If both are even or both are odd, the square is dark, else the square is light.
MATL, 20 bytes
js2\?'light'}'dark']
Explanation
j % input string
s % sum
2 % push 2
\ % mod(sum(inputstring),2)
? % if this value is 1
'light' % return 'light'
} % else
'dark' % return 'dark'
] % end
Bash + coreutils, 34 36
Using the same base conversion technique as other answers, but I chose base 19. I think it should work for any odd base between 19 and 35.
x=(light dark)
echo ${x[19#`cat`%2]}
Java, 157 127 124 bytes
interface L{static void main(String[]a){System.out.print(new java.util.Scanner(System.in).nextInt(35)%2>0?"dark":"light");}}
Japt, 23 22 bytes
Japt is a shortened version of JavaScript. Interpreter
Un19 %2?"dark":"light"
How it works
// Implicit: U = input string
Un19 // Convert U from a base 19 number to decimal.
%2 // Take its modulo by 2.
?"dark" // If this is 1, return "dark".
:"light" // Else, return "light".
// Implicit: output last expression
Using the new version 0.1.3 (released Nov 22), this becomes 17 bytes, shorter than all but GS2:
Un19 %2?`»rk:¦ght
Or, alternatively, a magic formula: (26 bytes)
Un19 %2*22189769+437108 sH
Un19 %2 // Convert input to base 19 and modulo by 2.
*22189769+437108 // Where the magic happens (top secret)
sH // Convert to a base 32 string.
Seriously, 19 bytes
"dark""light"2,O+%I
Takes input like "a1"
Try it online (you will have to manually enter the input; the permalinks don't like quotes)
GS2, 17 15 bytes
de♦dark•light♠5
The source code uses the CP437 encoding. Try it online!
Verification
$ xxd -r -ps <<< 6465046461726b076c696768740635 > chess.gs2
$ wc -c chess.gs2
15 chess.gs2
$ gs2 chess.gs2 <<< b1
light
How it works
d Add the code points of the input characters.
e Compute the sum's parity.
♦ Begin a string literal.
dark
• String separator.
light
♠ End the string literal; push as an array of strings.
5 Select the element that corresponds to the parity.
Bash, 40 bytes
read x;y=(light dark);echo ${y[19#$x%2]}
Not using any coreutils.
JavaScript ES6, 59 56
s=prompt()
alert((s.charCodeAt()^s[1])%2?"light":"dark")
Extracts the number and the ASCII code of the letter, adds them and checks if even/odd. This can accept input in the form a1 and A1
3 bytes saved thanks to Neil!
Prolog, 80 bytes
p:-read(X),string_codes(X,[A,B]),Y is(A+B)mod 2,(Y=0->write(dark);write(light)).
Try it online here
Bash, 69 Bytes
sed 's/^./(&+/;s/$/)%2/'|tr [a-h] [1-8]|bc|sed s/1/light/\;s/0/dark/
Probably could be optimized a bit more.
- The first
sedformats the input to be from the forma5to(a+5)%2 trtakes the letters a-h and converts them to 1-8 respectivelybcperforms the addition and modulo- the final
sedthen takes the result and formats it as a string.
Burlesque, 25 bytes
)**++"dark light"wdcyj!!Q
One-to-one translation from the 56 bytes Haskell solution to this challenge:
)**++ -- sum . map fromEnum
"dark light"wdcy -- cycle["dark","light"]
j -- swap
!! -- same as Haskell !!
Marbelous, 86 bytes
..00
..]]//
&0/\]]//
..&0//
..//
^0
=0&1
&2\/
\/
'l'i'g'h't'd'a'r'k
&1&1&1&1&1&2&2&2&2
]]// loops wait for two bytes of input, then add them together and use ^0 and =0 to check the LSB and drop "light" or "dark" to stdout.
Clojure, 63 bytes
(pr (['light 'dark] (mod (Integer/parseInt (read-line) 35) 2)))
- We read in a line from stdin with (read-line)
- Then parse the string into an integer value in base 35 using a call to a JVM method
- Taking mod of the result 2 tells us if it is even or odd
- Use the result returned from the modulo function as an index to the sequence and print it
I save a worthy 2 bytes by quoting out "light" and "dark" with a single quote so that Clojure takes it as a literal, as opposed to wrapping each word in a pair of quotation marks. I also save a few bytes by using pr rather than println.
Batch, 248 223 207 bytes
Because Batch lacks disjunctional conditionals. -18 bytes thanks to @dohaqatar7, and more due to his idea.
@ECHO OFF
SET S=SET
%S%/P I=
%S%L=%I:~0,1%
%S%I=IF %L%==
%S%N=%I:~-1%
%S%A= %S%L=
%I%a%A%0
%I%b%A%1
%I%c%A%0
%I%d%A%1
%I%e%A%0
%I%f%A%1
%I%g%A%0
%I%h%A%1
%S%/A R=N%%2
IF %R%%L% (ECHO light) ELSE (ECHO dark)
Haskell, 61 56 Bytes
-5 bytes thanks to Mauris
As always, Haskell's interact function comes through with some byte saving on a challenge with IO.
The program assumes that a STDIN consists of only the row and the column, anything else can throw off the results; although, a trailing newline will not effect the outcome.
main=interact$(cycle["dark","light"]!!).sum.map fromEnum
Common Lisp, 90 bytes
Not a winner, but makes nice use of ability to read in base 18 and then do arithmetic with that number.
(let((*read-base* 18))(if(evenp(multiple-value-call'logxor(floor(read)18)))"light""dark"))
PHP, 40 42 bytes
PHP is doing OK this time:
<?=intval(fgets(STDIN),35)%2?dark:light;
Edits
- Saved 2 bytes by using
<?=instead ofecho. Thanks to Martijn.
Go, 100 bytes
package main;import."os";func main(){t:=Args[1];k,d:=t[0]+t[1],"light";if k%2==0{d="dark"};print(d)}
Ungolfed:
package main
import . "os" // Import os defines into current namespace
func main() {
t := Args[1] // Grab the first argument
// Define k as the sum of the 2
// first characters of the first argument, then define d as "light"
k, d := t[0]+t[1], "light"
// The sum aligns up nicely with the color of the square
if k%2 == 0 {
d = "dark"
}
print(d)
}
Python 2 - 75 bytes
import sys
l,n=sys.stdin.read()
print 'light'if ord(l)&1^int(n)&1 else'dark'
Vitsy, 23 22 21 Bytes
Thanks to @El'endiaStarman for shaving off a byte!
New Method (using fancy stack mechanics):
"krad"&"thgil"z+2M(?Z
Explanation:
"krad"&"thgil"z+2M(?Z
"krad" Push "dark" (backwards) to the stack.
& Generate a new stack.
"thgil" Push "light" (backwards) to the stack.
z Grab all input as string.
+ Add up the input's ASCII values.
2M Modulate by 2.
( If the result is not zero, do the next item.
? Rotate over a stack.
Z Output everything in the current stack.
Original Method (using fancy line-specific execution mechanics):
z+2M1+mZ "krad" "thgil"
How it works:
z+2M1+mZ
z Grab all input as string.
+ Add it together.
2M Modulo by 2.
1+ Add 1
m Go to the line specified by the top item of the stack - if it's one,
it'll push "light" to the stack. If 2, "dark".
Z Output everything in the stack.
C, 49 bytes
main(c){gets(&c);puts(c+c/256&1?"light":"dark");}
R, 163 bytes
Thanks to Alex A. for helping me with this answer.
n<-toupper(unlist(strsplit(scan(,""),"")));cat(matrix(rep(c(rep(c("light","dark"),4),rep(c("dark","light"),4)),4),8,8,dimname=(list(8:1,LETTERS[1:8])))[n[2],n[1]])
Example usage
1: b1
2:
Read 1 item
light
1: d4
2:
Read 1 item
dark
There's surely a better way to do this. I just made a matrix filled with the string "light" or "dark" to match the chessboard and then used subscripts taken from the input to return the color of the square.
Beam, 127 bytes
rSr>`+v
^ )
n(`)nS<
>L'''''>`+++++)S>`+++)@---@'''>`+++++)++@-------@H
>L'''''>`+++)S>`++++++)+++@---@--@+@'''>`++++)@H
An explanation
Light blue - read a character from input into beam, save the beam value into the store, read a character from input into beam.
Dark blue - Adds store to beam by decrementing store to 0 while incrementing the beam
Light green - An even odd testing construct. The loop will exit to the left if the beam is even or the right if odd.
Dark green - Outputs dark
Tan - Outputs light
CMD.EXE, 15 + 15 + 10 + 63 = 103 bytes
a1.cmd:
echo dark
exit
a2.cmd:
echo light
exit
Then create hard links for all the remaining 62 squares. Invoke using cmd /k echo off.
GolfScript, 21 bytes
{^}*~1&"lightdark"5/=
Explanation:
{^}* # XOR the bytes of the input together
~ # negate the result
1& # extract only the lowest bit (i.e. 0 or 1)
"lightdark"5/ # split the string "lightdark" into the array ["light" "dark"]
= # use the bit as an index into the array, returning "light"
# for 0 and "dark" for 1
Conveniently, since the ASCII codes of a Unix-style newline (LF = ASCII 10) and a space (ASCII 32) are even, this code can handle arbitrary spaces and linefeeds in its input. Both upper- and lowercase letters are also accepted, and the letter can be given before or after the number. Tabs or carriage returns, however, will throw it off.
Not unexpectedly, this program is quite similar to Peter Taylor's CJam entry. I didn't actually look at any of the other entries before I wrote this, though.
Brainfuck, 132 bytes
>,>,[<->-]<[->+<[->-]<[<]>]<++++++++++[->++++++++++<]>>[<++++++++.---.--.+.++++++++++++.>->+<]>-[<<.---.+++++++++++++++++.-------.<]
I tried coming up with my own mod 2 algorithm, which is the [->+<[->-]<[<]>].
CJam, 18 bytes
r:-)"lightdark"5/=
Dissection
r e# Read a token of input
:- e# Fold -, giving the difference between the two codepoints
) e# Increment, changing the parity so that a1 is odd
"lightdark"5/ e# Split the string to get an array ["light" "dark"]
= e# Index with wrapping, so even => "light" and odd => "dark"
Brian & Chuck, 66 bytes
,>,_{->-?+{-_?>}<?light{-_?>}>>?dark?
II{<?}<<<?{<{<<<?_>.>.>.>.>.
Probably still golfable, but I think I'd need another approach.
Explanation
,>, reads input into Chuck, replacing the two Is. Next is the following part of the code:
_{->-?
{<?
which decrements both input elements until the latter (i.e. the digit) reaches zero. This stops Brian's ? from passing control to Chuck, continuing on.
The next + increments the zeroed digit to a 1 so that following uses of { don't get caught on it. At this point, the first cell of Chuck's tape has the difference of the two code points, so now we need to take the code point modulo 2. This is done with the following parts:
A B C
{-_?>}<? {-_?>}>>? ?
}<<<?{<{<<<?
I've labelled the three parts on Brian's tape to make things easier to explain. The {- in parts A and B decrement the first cell on Chuck's tape, and the following ? checks if it's zero. If it's not, then control is passed, and we execute }<<<?. For part A, this moves us to part B. For part B, this moves us to part C, which immediately passes control and we execute {<{<<<?, sending us back to part A. Thus the effect is that we alternate between parts A and B, in a state machine-like way.
Now whether the first cell was zeroed while we were in part A or part B determines what we print. For A, we have:
?>}<?light
_ ?_>.>.>.>.>.
which executes >}< to position us on the last ? in Chuck's tape, and then runs >. five times to print "light".
On the other hand, for part B, we have:
?>}>>?dark?
_ _>.>.>.>.>.
which executes >}>> to position us on the first . in Chuck's tape, and then runs >. four times to print "dark".
C, 46 bytes
main(c){gets(&c);puts(c%37%2?"light":"dark");}
Expects an environment where ints are stored little-endian, and are at least two bytes.
Explanation
c is argc, so initially it contains 01 00 00 00. gets will read two chars, say a (0x61) and 1 (0x31), and store them in c, which is now
61 31 00 00
representing the number 0x3161, or 12641.
Essentially, in this problem, given c = x + 256*y, we want to compute (x + y) mod 2, and print a string accordingly. To do this, I could have written c % 255 % 2, as then
(x + 256 * y) % 255 % 2
= (x % 255 + y % 255) % 2 since 256 ≡ 1 (mod 255)
= (x + y) % 2 since 0 < x, y < 255
However, 37 also works:
(x + 256 * y) % 37 % 2
= (x % 37 - 3 * (y % 37)) % 2 since 256 ≡ -3 (mod 37)
x is in the range 49-57 inclusive (digits 1-8), so x % 37 == x - 37.
y is in the range 97-104 inclusive (lowercase a-h), so y % 37 == y - 74.
This means we can simplify to
= (x - 3 * y + 185) % 2
= (x + y + 1) % 2 since -3 ≡ 185 ≡ 1 (mod 2)
and simply flip the strings to correct for the parity.
Perl, 29 27 bytes
$_=/./&($'+ord)?light:dark
This code requires the -p switch, which I have counted as 1 byte.
Try it online on Ideone.
How it works
Because of the
-pswitch, Perl reads one line of input and stores it in$_././is a regular expression that matches one character. This has two implications:Since the match is successful,
/./returns 1.The post-match (second input character) is stored in
$'.
$'+ordadds the integer the second input character represents to the code point (ord) of the first character of the implicit variable$_.&takes the bitwise AND of the return value of/./and the sum$'+ord, returning 1 is the sum if odd, 0 if it is even.?light:darkreturns light if the previous expression returned 1 and dark otherwise.Finally
$_=assigns the result to$_, which Perl prints automatically, because of the-pswitch.
Scala, 65 53 49 bytes
It's quite clear without ungolfing.
print(Seq("dark","light")(readLine.sum.toInt%2))
R, 65 bytes
cat(c("dark","light")[1+sum(strtoi(charToRaw(scan(,"")),16))%%2])
Ungolfed:
# Get the ASCII codes from the input string
a <- strtoi(charToRaw(scan(, "")), 16L)
# Compute the sum modulo 2
s <- sum(a) %% 2
# Use the sum as an index for the output
cat(c("dark", "light")[s + 1])
Befunge-93, 39 37 33 31 bytes
All credit to Linus who suggested this 31-byte solution:
<>:#,_@ v%2-~~
"^"light"_"krad
Test it using this interpreter.
Explanation
< v%2-~~
The < at the beginning sends the instruction pointer to the left, where it wraps around to the right. It then reads in two characters from input as ASCII, subtracts them, and does a modulo by 2. As a and 1 are both odd (in terms of ASCII code), this works. The v redirects the instruction pointer downward...
"^"light"_"krad
...onto the _, which sends the instruction pointer to the left if the top of stack is 0 and to the right otherwise. The characters of "light" or "dark", respectively, are pushed onto the stack in reverse order. Both paths hit the ^ at the left, which sends the instruction pointer upward...
>:#,_@
...to the output segment. : duplicates the top of stack, # jumps over the , and onto the _, which sends the instruction pointer to the right if the top of stack is 0 and left otherwise. When the stack is empty, the top of stack (after :) is 0, so the instruction pointer hits the @ which stops execution. Otherwise, it hits the ,, which outputs the top of stack as a character, and then the # jumps it over the : and onto the >, which starts the process again.
SpecBAS - 59 bytes
My original version (before looking at any other answers) was 117 bytes and probably reflects the way I come at a problem. Then I saw everyone using base 19 or 35, which wouldn't have sprung to my mind at all.
So, with thanks to everyone else for getting this down to 59.
1 INPUT s$: PRINT IIF$(DECIMAL(s$,19) MOD 2,"Dark","Light")
Prints "Dark" if converted number mod 2 is 1/True and "Light" otherwise, using the inline if statement.
Mouse, 25 bytes
?'?'+2\["light"$]"dark"$
Explanation:
?'?' ~ Read two characters from STDIN and put their ASCII
~ codes on the stack
+2\ ~ Get the sum of the codes modulo 2
["light"$] ~ If the result is 1, print light to STDOUT and exit
"dark"$ ~ Print dark to STDOUT and exit
ShapeScript, 57 56 bytes
0'1+@"%c"2?862**+%$"%d"2?%~@'8*!#!+"dark"@"light"@'@'*!#
How it works
0 Push 0 (accumulator).
' Push a string that, when evaluated, does the following:
1+ Increment the accumulator.
@ Swap it with the input.
"%c" Push that formatting string.
2? Copy the accumulator.
862**+ Add 8 * 6 * 2 = 96 to it.
% Apply the string formatting: 1 ... 8 -> 'a' ... 'h'
$ Split the input at occurrences of that character.
"%d" Push that formatting string.
2? Copy the accumulator.
% Apply the string formatting: 1 ... 8 -> '1' ... '8'
~ Join the split input, using that character as separator.
@ Swap the result with the accumulator.
'
8* Repeat the string eight times.
! Evaluate.
# Discard the accumulator.
! Evaluate the modified input. Pushes two integers.
+ Add the integers.
"dark"@ Swap the sum with that string.
"light"@ Ditto.
'@'*! Repeat the at sign (swap) that many times and evaluate the result.
An odd number of swaps brings "dark" on the top of the stack.
# Discard the topmost string.
Gol><>, 22 bytes
ii+2%Q"thgil"H|"krad"H
Explanation
ii Read two chars
+2% Add code points mod 2
Q | If top of stack is truthy...
"thgil"H Push "light" and halt, outputting stack
"krad"H Push "dark" and halt, outputting stack
BotEngine, 165 14x11=154
v acegbdfh
>ISSSSSSSS
v<<<<>v<<P
vS1 vS2ke
vS3 vS4re
vS5 vS6ae
vS7 vS8de
> > ^
> > v
^S2 ^S1el
^S4 ^S3ei
^S6 P^S5eg
^S8 te^S7eh
^ <
Here it is with the different path segments highlighted:

(Any non-space characters not highlighted serve as arguments for the e and S instructions- each of these instructions uses the symbol to the left (relative to the bot's direction of travel) as its argument)
C, 55 bytes
s;main(){puts(strtol(gets(&s),0,19)&1?"light":"dark");}
Thanks DigitalTrauma for lots of golfing tips
TI-BASIC, 66 bytes
Tested on a TI-84+ calculator.
Input Str1
"light
If inString("bdfh",sub(Str1,1,1)) xor fPart(.5expr(sub(Str1,2,1
"dark
Ans
Here's a more interesting variation on the third line, which sadly is exactly the same size:
Input Str1
"dark
If variance(not(seq(inString("bdfh2468",sub(Str1,X,1)),X,1,2
"light
Ans
You'd think TI-BASIC would be decent at this challenge, since it involves modulo 2. It's not; these solutions seem to be the shortest possible.
We spend a lot of bytes to get both characters in the string, but what really costs is the thirteen two-byte lowercase letters.
ShadyAsFuck, 91 bytes / BrainFuck, 181 bytes
My first real BrainFuck program, thank Mego for the help and for pointing me to the algorithm archive. (That means I didn't really do it on my own, but copied some existing algorithms. Still an experience=)
NKnmWs3mzhe5aAh=heLLp5uR3WPPPPagPPPPsuYnRsuYgGWRzPPPPlMlk_PPPPPP4LS5uBYR2MkPPPPPPPP_MMMkLG]
This is of course the translation from my brainfuck answers:
,>,[<+>-]++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>[-]>>[-]++++++++++[>++++++++++<-]<[<+>>+<-]<[>+<-]+>>[>++++++++.---.--.+.++++++++++++.<<<->>[-]]<<[>>>.---.+++++++++++++++++.-------.<<<-]
Developed using this interpreter/debugger.
I stole two code snippets for divmod and if/else from here. (Thanks to @Mego!)
,>, read input
[<+>-] add
++< set second cell to 2
Now we have the cells config >sum 2 we now perform the divmod algorithm:
[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>
[-]>
The output of the divmod looks like this 0 d-n%d >n%d n/d but we zeroed the d-n%d and are zeroing the next cell too:
>[-]
Fill one cell up to the value 100 for easier outputting:
++++++++++[>++++++++++<-]<
Now the configuration is >cond 0 100 and for applying the if/else algorithm we need two temp variables, so we choose the configuration temp0 >c temp1 100
c[<temp0+>>temp1+<c-]<temp0[>c+<temp0-]+
>>temp1[
#>++++++++.---.--.+.++++++++++++.< outputs light
<<temp0-
>>temp1[-]]
<<temp0[
#>>>.---.+++++++++++++++++.-------.<<< outputs dark
temp0-]
Ruby, striked out 44 36 bytes
puts %w[light dark][gets.to_i(19)%2]
Turing Machine Code, 235 bytes
Using the rule table syntax defined here.
0 a _ r 1
0 c _ r 1
0 e _ r 1
0 g _ r 1
0 * _ r 2
1 2 _ r 3
1 4 _ r 3
1 6 _ r 3
1 8 _ r 3
2 1 _ r 3
2 3 _ r 3
2 5 _ r 3
2 7 _ r 3
* * _ r 4
3 _ l r A
A _ i r B
B _ g r C
C _ h r D
D _ t r halt
4 _ d r E
E _ a r F
F _ r r G
G _ k r halt
Hexagony, 34 32 bytes
,},";h;g;;d/;k;-'2{=%<i;\@;trl;a
Unfolded and with annotated execution paths:

Diagram generated with Timwi's amazing HexagonyColorer.
The purple path is the initial path which reads two characters, computes their difference and takes it modulo 2. The < then acts as a branch, where the dark grey path (result 1) prints dark and light grey path (result 0) prints light.
As for how I compute the difference and modulo, here is a diagram of the memory grid (with values taken for the input a1):

Diagram generated with Timwi's even more amazing Esoteric IDE (which has a visual debugger for Hexagony).
The memory pointer starts on the edge labelled row, where we read the character. } moves to the edge labelled col, where we read the digit. " moves to the edge labelled diff where - computes the difference of the two. ' moves to the unlabelled cell where we put the 2, and {= moves to the cell labelled mod where we compute the modulo with %.
This might be golfable by a few bytes by reusing some of the ;, but I doubt it can be golfed by much, certainly not down to side-length 3.
TeaScript, 23 bytes
®x,35)%2?"dark":"light"
Unfortunately the strings dark and light can't be compressed.
Minkolang 0.12, 28 24 bytes
on+2%t"dark"t"light"t$O.
Explanation
o Take character from input
n Take integer from input
+ Add
2% Modulo by 2
t t t Ternary; runs first half if top of stack is 0, second half otherwise
"dark" "light" Pushes the string "dark" or "light", depending.
$O. Output the whole stack as characters and stop.
Python 2, 41 38 bytes
print'ldiagrhkt'[int(input(),35)%2::2]
3 bytes thanks to Mego for string interlacing
Takes input like "g6". That's light and dark intertwined.
Microscript, 25 bytes
Because Microscript II really doesn't have much in terms of character manipulation yet.
2sI++%{"thgil"ah}"krad"ah
sed, 37
s/[1357aceg]//g
/^.$/{clight
q}
cdark
Explanation
s/[1357aceg]//g removes all odd-indexed coordinates. The resulting pattern buffer then has length of 1 for "light" or length of 0 or 2 for "dark". /^.$/ matches the 1-length patterns, changes the pattern to "light" and quits. Otherwise the pattern is changed to "dark".
Matlab, 51 bytes
I do not think this needs any explanation=)
a={'light','dark'};disp(a(2-mod(sum(input('')),2)))
Python 2, 45 bytes
print'dlairgkh t'[sum(map(ord,input()))%2::2]
Takes input like "a1". Try it online
Pyth, 18 bytes
@c2"lightdark"iz35
Interpret the input as a base 35 number, chop lightdark in half, print.



