Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Solving puzzles with hypothesis (edoput.it)
39 points by Jtsummers on Nov 19, 2022 | hide | past | favorite | 6 comments


Hypothesis is really a neat library. You can use it to implement stateful testing, which allows you to cover some of the more complex problems that might normally require something like TLA+.

I saw a solution to the water jug problem from the movie Die Hard 3 written in TLA+ and ported it to Hypothesis [0]. It was surprisingly straightforward and easy to read.

[0]: https://nchammas.com/writing/how-not-to-die-hard-with-hypoth...


I don't understand what benefit the hypothesis library gives here? Why can't you just generate values without hypothesis and call the test function with your values "manually"?


The cool thing is that hypothesis tries to build minimal examples that make your test fail.


The magic is in the "strategies"? How does it do that? And does it have a memory between test runs?



By the way, if anyone is captivated by the concept of the game being talked about at the top of this post, check out Zachtronics games. They’re all about programming to solve puzzles.




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

Search: