Random computing foo
Oct. 24th, 2004 05:21 pmSamba is hard to set up. Especially when you're tripping over odd bugs in the Debian package thereof. At least it easily supports IP ACLs. But yay, house music server.
I coded up Ted's stupid solitaire game this morning. Shuffle the deck; then, deal four cards out. If all four cards are the same rank, remove them. Otherwise, if there are any duplicate ranks, move the card on the right on top of the card on the left. When there are no duplicates showing, deal four more cards. When you run out of the deck place the rightmost pile on top of the third pile on top of the second on top of the first, and flip over to be the deck again. Entirely deterministic and a waste of time.
I decided to code this up in my favorite functional language. I even got to use Maybe as a monad, which is actually pretty cool:
Returns Nothing if either function fails, or the result of the composite function call otherwise.
I was able to fit the logic for the game in about 200 lines of Haskell. Could be shorter.
I've had good luck installing OpenWRT on the Linksys WRT54G I bought a while ago. At this point I either need to configure IPSec or get IP-over-IP tunnelling on it, and figure out how to set up Shorewall, and then I can swap it in for donut. Scary.
I coded up Ted's stupid solitaire game this morning. Shuffle the deck; then, deal four cards out. If all four cards are the same rank, remove them. Otherwise, if there are any duplicate ranks, move the card on the right on top of the card on the left. When there are no duplicates showing, deal four more cards. When you run out of the deck place the rightmost pile on top of the third pile on top of the second on top of the first, and flip over to be the deck again. Entirely deterministic and a waste of time.
I decided to code this up in my favorite functional language. I even got to use Maybe as a monad, which is actually pretty cool:
doSomething :: a -> Maybe a
doSomethingElse :: a -> Maybe a
doBoth :: a -> Maybe a
doBoth x = do
y <- doSomething x
z <- doSomethingElse y
return z
Returns Nothing if either function fails, or the result of the composite function call otherwise.
I was able to fit the logic for the game in about 200 lines of Haskell. Could be shorter.
I've had good luck installing OpenWRT on the Linksys WRT54G I bought a while ago. At this point I either need to configure IPSec or get IP-over-IP tunnelling on it, and figure out how to set up Shorewall, and then I can swap it in for donut. Scary.