Hacker News new | past | comments | ask | show | jobs | submit login

Okay… please… someone implement ‘nand’ and write a script that does something simple using only it.



Sure! Here's an implementation of nand and a 2-bit adder that uses it: https://github.com/jewel/nand


Hah this is awesome!

I’m going to poke around and see how much it would take to stretch this into a basic Turing machine emulator.




Great find. People who like this might also like http://incredible.pm/ .

I don't know how I feel about the message "This is optimal!" displaying when you use one NAND gate to build an inverter at level 2. Level 1 forces you to build an NAND gate out of (1) an AND gate, plus (2) an inverter. It feels like it'd be more optimal to just reuse that inverter.

(And then level 3 is an AND gate, the other primitive† you started with...)

† Technically, you start with two primitives, implementing f(a, b) = a ∧ b and g(a,b) = ¬(b ⟶ a). You also get the ability to provide 0 and 1 as fixed inputs, thus ¬a ≡ g(a,1). What you lose after implementing the NAND gate is the ability to provide a fixed 1 input - instead, you are informed that you assume all gates automatically draw from this. Worst of all possible worlds.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: