TypeScript and crossing the river


carl_javascript.jpg


Have you ever heard of that puzzle where a farmer wants to cross a  river with a fox, a goose, and a bag of beans? He has a boat, but he can  only fit himself in the boat plus at most one of the three items he  bought: the fox, the goose, or the bag of beans. (Don't ask me why he  bought a fox. I have no idea. Probably an impulse purchase.)

The fox really wants to eat the goose, and will at the first opportunity when it's left alone with it. Similarly, the goose is eyeing the bag of beans, and will  gobble it up if unsupervised, even though it has promised to give up  beans for lent. If anyone eats anything, the farmer loses and you don't  solve the puzzle. The goal is to take all three items across the river  unscathed.

It's a cute puzzle, and there are two solutions — neither is too hard  to find. But one day I thought, hey, why not write a program that searches  for a solution? You feed it the rules of the puzzle, and it just comes  up with a way to take the items across. Like magic! You can input  various other puzzles too, and it'll solve them too.

This talk is the story of how I wrote that program in modern  JavaScript, and how halfway through it I realized it would be so much  better if I switched to using TypeScript.

    Event info

    Presenter:
    Carl Mäsak
    Location: Foo Cafe, Stora Varvsgatan 6a, 211 19 Malmö
    Price: 0 SEK
    Date: 24 May
    Time: 17:30 - 20:00

    Contact us for details

    +46 40 61 70 720
    info@edument.se