Post Reply 
[VA] HP-71B Mini-challenge: Qualifying for a job
09-16-2022, 11:44 AM (This post was last modified: 09-16-2022 11:46 AM by J-F Garnier.)
Post: #15
RE: [VA] HP-71B Mini-challenge: Qualifying for a job
Indeed, our solutions are very close, not really a surprise to achieve the target set by Valentin.

So here is my 2-line, 90-byte solution:

10 DEF FNS(N) @ IF N>0 THEN FNS=FNS(N-1)+RND
20 END @ DEF FNG=FNS(8)-4 @ DEF FND=IP(1+RND*6) @ DEF FNZ=0 @ DEF FNO=1

The main gain is to realize that END can be used in place of END DEF on the HP-71B.

As C.Ret, I considered saving 2 bytes by using the condition "IF N" instead of "IF N>0" that is equivalent for positive integer values of the argument N, but can lead to a crash (infinite recursion) in case of incorrect arguments.

I can save one more byte by changing:
DEF FNG=FNS(8)-4
to
DEF FNG=FNS(8)+INX
using the INX constant = -4, a trick I already used in other challenges (experience counts in that matter :-)
But it's quite inelegant and I will stick to my 90-byte version.

I'm still puzzled by the goal of the FNZ and FNO trivial functions, I don't see any way to make them simpler.

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [VA] HP-71B Mini-challenge: Qualifying for a job - J-F Garnier - 09-16-2022 11:44 AM



User(s) browsing this thread: 1 Guest(s)