Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maxcnunes/elixir-user-reflexes
https://github.com/maxcnunes/elixir-user-reflexes
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/maxcnunes/elixir-user-reflexes
- Owner: maxcnunes
- Created: 2016-01-05T21:53:00.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-05T22:41:43.000Z (about 9 years ago)
- Last Synced: 2024-10-18T07:20:58.838Z (3 months ago)
- Language: Elixir
- Size: 3.91 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# user-reflexes
This week I was reading [Go weekly](http://golangweekly.com/issues/90) and there was a post [Go Concurrency versus C and pthreads](http://denis.papathanasiou.org/posts/2015.12.26.post.html) with the following programming challenge:
> Write a program to test user reflexes: when it runs, it waits a random amount of time between 1 and 10 seconds, and prints "GO!" as a prompt.
> It then expects the user to hit the enter key, and times how fast enter is pressed, in milliseconds.
> If the enter key is pressed before the "GO!" prompt appears, the program prints "FAIL".
In that post it was implemented in Go and C. Since I'm learning Elixir I decided to implement it as well.
## Running
```bash
mix deps.get
iex -S mix run
UserReflexes.run
```**Example**
```bash
➜ user_reflexes master ✓ iex -S mix run
Erlang/OTP 18 [erts-7.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]ExSync started.
Interactive Elixir (1.1.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> UserReflexes.run
Press ENTER in 3000 milliseconds
> 2
> 1
> 0FAILED: Answred before the GO time
Answred at -162 milliseconds
true
iex(2)>
```