MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1y5vntt/technicallycorrect/19tcraxn211s0/?context=3
r/ProgrammerHumor • u/Apprehensive_Bit7392 • 5d ago
51 comments sorted by
View all comments
Show parent comment
2
fuck it, branchless version
package grid import "core:fmt" WIDTH, HEIGHT :: 10, 9 main :: proc() { lhs, rhs := 0b1100000000, 0b0000000011 x := 0b1000000001 // 513 for row in 0..<HEIGHT { for i := uint(0); i < WIDTH; i += 1 { // ascii ' '+3 == '#' c := ' ' + 3 * rune((x | 513) & (1<<i) > 0 || x == 513) fmt.print(c) } fmt.println() // ~ is xor in odin x ~= (lhs ~ rhs) lhs >>= 1 + uint(lhs == 96) rhs <<= 1 + uint(rhs == 24) } }
View all comments
Show parent comment
2
u/etoastie 2d ago
fuck it, branchless version