Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tommay/clock_equations
Figure out the simple equations that can be made from the time on a digital clock
https://github.com/tommay/clock_equations
Last synced: about 6 hours ago
JSON representation
Figure out the simple equations that can be made from the time on a digital clock
- Host: GitHub
- URL: https://github.com/tommay/clock_equations
- Owner: tommay
- License: mit
- Created: 2014-11-09T21:44:22.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-26T06:40:09.000Z (over 9 years ago)
- Last Synced: 2023-04-19T16:52:47.917Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 305 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
clock_equations
===============Figure out the simple equations that can be made from the time on a digital clock
My 9-year old daughter Chloe and I like to look at the digital clock
sometimes and make equations out of the numbers. For example,
12:02 could be 1*2+0 = 2, and 12:03 could be 1+2 = 0+3.I thought it would be fun to code up a program to find all the "clock
eauations". There are two parts: generating the equations, and
evaluating their truth value. Generating the equations done one
of two ways:- clock.rb uses a sequence of `.lazy` enumerators to generate the times,
build all possible equations from the numbers of each tine, and filter
the valid equations.- enum_clock.rb uses explicit enumerators of various kinds, mostly to see
how things weould come out if I coded them up;
- Enumerator
- Standard Ruby Enumerator
- FiberEnumerator
- Enumerator using Fiber (fiber_enumerator.rb). This is
straightforward.
- CallccEnumerator
- Enumerator using bare callcc (callcc_enumerator.rb). This one
is not particularly nice or well-done. - CoroutineEnumerator
- Enumerator that encapsulates the callcc usage into a
Coroutine class. This one is pretty good.
(coroutine_enumerator.rb, coroutine.rb)
The `Enumerator` class can be set by editing enum_clock.rb and setting
variable `UseEnumerator` to the proper class (ugh).
The equations' truth values are determined using a recursive descent
expression evaluator.