so, a big part of why I have qbasic on my computer is that I can use it ot solve simple np complete problems, like this one:
By the way, this comic is from xkcd.com. I suspect that if we know each other in real life, you'd enjoy the comic. The rest of you? I bet you'll enjoy it too.
here's the code:
CLS
ms=4.2
mf=2.15
ff=2.75
ss=3.35
hw=3.55
fs=5.8
d=0
FOR u = 0 to 7
FOR v = 0 to 7
FOR w = 0 to 7
FOR x = 0 to 7
FOR y = 0 to 7
FOR z = 0 to 7
price = z * fs + y * hw + x * ss + w * ff + v * mf + u * ms
IF price = 15.05 THEN PRINT u; v; w; x; y; z
d = d+1
NEXT z
NEXT y
NEXT x
NEXT w
NEXT v
NEXT u
PRINT d
END
So the expected output is:
0 1 0 0 2 1
0 7 0 0 0 0
262114
meaning that the two solutions are
1 mf, 2 hw, and 1 fs
and
7 mf
the actual output is
0 1 0 0 2 1
262114
I've fiddled with the program and I had it display price after each individual set of numbers... the output at 0 7 0 0 0 0?
0 7 0 0 0 0 15.05
The program should identify that as a win. No idea why it isn't.
I want to scream. And learn a new language. And get a different computer.
Edit 11:00 AM 7/10/2007
The talented and lovely
It is also possible that qb dislikes 7. I seem to remember that being a problem years ago for something or another.
Blog Archive
-
▼
2007
(111)
-
▼
July
(18)
- Malapropism junction what's your function?
- Part Two: Unblocked!
- Rule #1:If you open this you GOTTA take it. (yeah,...
- Just got back from Jessica and Daniel's wedding. I...
- I'm trying to find two Science Fiction short stori...
- Whew boy, special... A combination of people I kne...
- I now want a second Potterverse heptalogy.With the...
- Hee hee.So I need a word for a typo that goes on t...
- Harry Potter 7
- Yaknow what would have been great?A forum bot that...
- thirty one million five hundred fifty six thousand...
- So didn't post this yesterday, but Harry Potter 7 ...
- This guy pretty much nails the major problems of ...
- so, a big part of why I have qbasic on my computer...
- There is something special about not being able to...
- I got my own little MSN imbecile today!
- I am Homo sapiens sapiens descendant of H. erec...
- MIddle of the year reading list.
-
▼
July
(18)
About Me
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment