![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
OK, this one is pretty easy - but it makes you think and it's a nice break from the day.
Write a program that takes in 3 values: distance(eg. miles), efficiency(eg. miles/gallon), and current fuel(eg. gallons). Your program must give a response (in English) stating whether or not the person has enough fuel to make it on this trip. Now the catch: you cannot use conditionals in your code (if, switch, etc) - no decision logic whatsoever. Post your solutions, it will be interesting to see what people come up with. (I have solved this and I will post my code after there are some correct responses)
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand." - B. Russell http://web.bryant.edu/~srk2 |
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
Not sure if this is correct, but here you go... a PHP command line program attached to avoid spoilers.
__________________
|
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
You want to make the the response a "yes" or "no" type of English response - no numbers.
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand." - B. Russell http://web.bryant.edu/~srk2 |
|
|
|
|
|
#4 |
|
Hobbyist Programmer
Join Date: Apr 2004
Location: Texas
Posts: 106
Rep Power: 5
![]() |
entry .... hope I did the right thing ... been a bad week for me ... it's perl btw
__________________
[ [ SykkN alloc ] initWithThePowerTo: destroyYouAll ]; /* Don't make me use it! */ |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
You are using decision logic there with the regular expressions (looking for the - sign). No conditional expressions whatsoever allowed! Only mathematical computations and outputting strings.
I'll give a hint... make the output something like: You will make it. You will not make it.
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand." - B. Russell http://web.bryant.edu/~srk2 |
|
|
|
|
|
#6 |
|
Hobbyist Programmer
Join Date: Apr 2004
Location: Texas
Posts: 106
Rep Power: 5
![]() |
post yours ...
__________________
[ [ SykkN alloc ] initWithThePowerTo: destroyYouAll ]; /* Don't make me use it! */ |
|
|
|
|
|
#7 |
|
Hobbyist Programmer
|
I'm not quite sure how you would go about writing this without useing at least one conditional. How do you choose the output??
![]() |
|
|
|
|
|
#8 |
|
Hobbyist Programmer
Join Date: May 2005
Location: Indiana
Posts: 130
Rep Power: 4
![]() |
Have not had time to work this out, perhaps later tonight.
But there may be something in the fact that in logic these two statemens are logically equivalent: P -> Q (P implies Q, i.e. conditional) P' | Q ((not P) or Q) Hmmm ... maybe i am on a tangent but i'll think about that! |
|
|
|
|
|
#9 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
here you go... (C++)
it's very evil.
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand." - B. Russell http://web.bryant.edu/~srk2 |
|
|
|
|
|
#10 |
|
Hobbyist Programmer
Join Date: Apr 2004
Location: Texas
Posts: 106
Rep Power: 5
![]() |
shenanigans
__________________
[ [ SykkN alloc ] initWithThePowerTo: destroyYouAll ]; /* Don't make me use it! */ |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|