A story with picaxe code

newplumber

Senior Member
Not to add a garbage post but I was testing a different way of coding
of course it wouldn't be much use for you pros but since i figured
adding a ' key doesn't lengthen the code so why not use alot of them :)


Code:
'any PE simulator or picaxe chip
symbol frank      = b2
symbol fred       = b3
symbol fritz      = b4  
symbol Abby       = b5
symbol motel      = b6
symbol each_owe   = b7
symbol real_paid  = b8
 

start:
frank = 20 'each has a twenty dollar bill
fred  = 20 'each has a twenty dollar bill
fritz = 20 'each has a twenty dollar bill

   'frank,fred and fritz went hunting one day and got lost 
   'after many hours walking they came across a town with a motel
   'when reached the motel which they planned to stay for one night 
   'the front desk lady Abby said it was 30 dollars a night for 3 beds
   ' so how much did each guy pay ?
   each_owe = 30 / 3 ' ten dollars each
   frank =    frank - each_owe
   fred  =    fred  - each_owe
   fritz =    fritz - each_owe
   'then after they went to the room, the manager said I might know those 
   'guys so he told Abby to only charge 25 dollars for the night and bring back 
   'the change divided to each of them. As Abby was walking to the room 
   'she could not divide 5 ones into 3 ways so she keeped two and 
   'gave each a dollar back
   Abby = 2 
   frank = frank + 1 
   fred  = fred  + 1 
   fritz = fritz + 1 
   'so how much did the 3 guys really pay
   real_paid = frank+fred+fritz
   real_paid =   60 - real_paid  
   sertxd (#real_paid," amount of dollars the 3 guys paid",cr)
   pause 2000
   sertxd ("so ",#real_paid," dollars + the ",#Abby," Abby kepted = 29!..wheres the other dollar?",cr)
   pause 4000
end
I am probably behind times on this ... but it was a hard question to crack for me
 

premelec

Senior Member
Yes that's fun... many years ago I was coding Commodore computers in BASIC which had some peculiar characteristics and parsing - Some one in Transactor Magazine proposed "programmable prose" as statements like "FORK = FOOD TOOL" would run being part of a FOR NEXT statement - In this case reducing to FOR K = FO TO OL .... the parser looked for FOR and then the next letter as a variable then looked for = then TO .... Some fun code resulted... i guess we could write whole novels with the right choice of variable names... ;-0
 

techElder

Well-known member
There are some valuable lessons in there to learn.

Try upping the money for frank,fred and fritz to 254 each. ;)

Then when you'll get tired of editing much of the code and add some input and range variables here and there.

Then you'll learn more about displaying on a terminal and getting input from different hardware devices such as a switch, keyboard or terminal.

Pretty soon you'll have a program to fill up an 08M2!

That isn't a trivial program for learning purposes.
 

hippy

Technical Support
Staff member
I am probably behind times on this ... but it was a hard question to crack for me
It is one of the classic examples of misrepresenting how things actually are. The worst examples in real life I believe are where some use mathematical tricks to conclude one group is multiple times worse than some other group.
 

newplumber

Senior Member
Hi

@premelec yes it is fun but could be funner ..if i understood 200% more ..i write novels everytime i code ...in maybe rookie picaxable basic :)

@texas ...good thing...these chips are re programmable....other wise i would still be ordering more chips to perfect my code
"how to flash a led" ...and your right its not trivial learning but its (some big word goes here) kind of learning I think/hope

@ hippy ....and that is why we have the best forum that corrects the misrepresenting by you all.

@lbenson ...I knew you all are to smart to be stopped by the question ...I just put it here so in a few months
if i re read my post/code ...I might be stumped again :)

and thanks for reply
 
Top