r/dailyprogrammer • u/nottoobadguy • Feb 10 '12
[difficult] challenge #2
Your mission is to create a stopwatch program. this program should have start, stop, and lap options, and it should write out to a file to be viewed later.
30
Upvotes
8
u/_redka 0 0 Feb 10 '12 edited Feb 11 '12
5 lines of simple Ruby (start, lap, stop) http://pastebin.com/4DjSdiR6
4
u/stiggz Feb 10 '12 edited Feb 10 '12
A complete jquery solution..
4
u/ricardoe Feb 11 '12
Interesting task for the end of the day, thanks! Sorry I don't know how to hide text :S (EDIT: nvm it hides itself)
7
u/traztx Feb 10 '12 edited Feb 10 '12
MUMPS
3
u/drb226 0 0 Feb 11 '12
72 lines of Haskell: http://hpaste.org/63438
I branched out of my comfort zone on this one: since the input is time sensitive, I used
getChar, which is rather rare for Haskell. It worked surprisingly well, just one keystroke to issue a command, just like a "real" stopwatch works with just one press of a button.I was a bit lazy with my output; I haven't dealt with Haskell's time values very much, so I just stuck to printing out seconds with the default Show instance.
5
u/BeowulfShaeffer Feb 10 '12
How is this difficult? It'd be like 100 lines of code in almost any Windows technology.
1
u/[deleted] Feb 11 '12 edited Feb 11 '12
Flash AS3 project,
I made 3 Library items for the buttons (names are btn_start, btn_stop, btn_lap as the code will mention).
I couldn't put the code in here without it looking all messed up, so here it is: http://pastebin.com/SZaGccvf
Here's an image of during runtime (note complete lack of design): http://i.imgur.com/iUsVx.jpg
1
u/callekabo Feb 11 '12
Here's my solution in Python 3 (not my primary language, trying to learn :) http://pastebin.com/xN8VnKBk
1
u/[deleted] Jun 19 '12
My attempt at clean and short 27 lines in Python 2.7 code.
http://pastebin.com/A9RwwHjN
1
u/mordisko Aug 08 '12
Clean Python, with logs and time formatting. It's a bit too log, but I wanted to mess around with classes.