Post Reply 
math in today's comics
04-30-2017, 02:18 PM
Post: #1
math in today's comics
cool
Find all posts by this user
Quote this message in a reply
04-30-2017, 03:46 PM
Post: #2
RE: math in today's comics
(04-30-2017 02:18 PM)Don Shepherd Wrote:  cool

Thanks for sharing Don, it is cool. Two with no machines, one with a 48GX, one with a 17BII, and one with the RPN program on my 71B. A very good reason to grab a few machines on a Sunday morning.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
04-30-2017, 04:54 PM (This post was last modified: 04-30-2017 04:59 PM by BobVA.)
Post: #3
RE: math in today's comics
And a surprising reminder to me that the HP-25 doesn't have a factorial key. Good thing I didn't get into any bar bets on that fact!
Find all posts by this user
Quote this message in a reply
04-30-2017, 04:58 PM
Post: #4
RE: math in today's comics
(04-30-2017 03:46 PM)rprosperi Wrote:  
(04-30-2017 02:18 PM)Don Shepherd Wrote:  cool
RPN program on my 71B

Don't you mean BASIC?
Find all posts by this user
Quote this message in a reply
04-30-2017, 05:13 PM (This post was last modified: 04-30-2017 05:17 PM by pier4r.)
Post: #5
RE: math in today's comics
Don, your list of "started threads" is a gold mine of puzzles useful as programming challenges. I will read and solve the ones that I think I can solve, one day or another. Thanks for sharing.

Anyway I included the test partially as #16 challenge for processing list. My solution is not fast (or better, in the best case is very fast, in the worst, is eternal) but I like it.

For the factorial, a sharp 506w will do it.

Code:

# userRPL
  shuffleListHelp
"input:
L2: a list
L1: numbers of shuffles (affecting single elements)

output:
L1: shuffled list

remarks:
to work properly the number of shuffles should not be low,
like the number of elements should do it"
  
  shuffleList
  @ TODO: consider something like this http://www.hpmuseum.org/forum/thread-2889.html
  @       the point is that one receives a list, it is not creating it from the start.
  @ TODO: consider analyze the results to suggest a proper number of shuffles or to
  @       implement a better algorithm.
  \<<
    @program that receives a list in input, and shuffles the elements
    @returning the shuffled list in output on the stack
    
    @arguments on the stack.
    @ 2: list
    @ 1: number of random elements to shuffle around
    
    0
    \->
    @external inputs
    inputList
    noShuffles
    @local var
    numEl
    \<<
      @explode the list on the stack
      inputList OBJ\->
      @save the num of elements
      'numEl' STO
      
      @roll randomily the elements in the list
      1 noShuffles
      START
        numEl RAND * 1 + IP
        ROLL
      NEXT
      
      @build the list back
      numEl
      \->LIST
    \>>
  \>>

c16vaV1
    \<<
      { 0 8 8 2 }  @mult117
      { 1 3 4 }    @primeN
      { 6 4 0 9 }  @intCubed
      0 @iterations
      0 @stoFlags
      \->
      mult117
      primeN
      intCubed
      iterations
      stoFlags
      \<<
        RCLF 'stoFlags' STO
        @-3 SF
      
        @ multiple117
        @ I could compute multiples of 117 until I get the right digits
        @ but I need to convert a number in digits then.
        @ so let's try with permutations. I could write a function
        @ to return all the permutations of a list, but so far I put it
        @ in the todo. So we do random permutations (shuffle) of a list.
        @ it will eventually hit the mark.
        WHILE
          mult117 { 1000 100 10 1 } *
          \GSLIST
          117 MOD 0 \=/
        REPEAT
          mult117 8 shuffleList
          'mult117' STO
          1 'iterations' STO+
        END
        
        iterations
        mult117    
        
        0 'iterations' STO
        WHILE
          primeN { 100 10 1 } *
          \GSLIST
          ISPRIME? NOT
        REPEAT
          primeN 8 shuffleList
          'primeN' STO
          1 'iterations' STO+
        END
        
        iterations
        primeN
        
        0 'iterations' STO
        WHILE
          intCubed { 1000 100 10 1 } *
          \GSLIST
          3 XROOT
            @now we have the cube root of the value
          FP 0 \=/
            @continue until the cube root is not returning an integer.
        REPEAT
          intCubed 8 shuffleList
          'intCubed' STO
          1 'iterations' STO+
        END
        
        iterations
        intCubed
        
        stoFlags STOF
      \>>
    \>>


Code:


@spoilers











2808 117 MOD 0 ==
431 isprime?
4096 3 XROOT

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
04-30-2017, 07:48 PM
Post: #6
RE: math in today's comics
(04-30-2017 04:58 PM)Don Shepherd Wrote:  
(04-30-2017 03:46 PM)rprosperi Wrote:  RPN program on my 71B

Don't you mean BASIC?

No, there's a "BIN" (for binary, written in assembler) RPN Calculator program created back in the day by Chris Capaner, that provides a full-featured 4-level RPN for the 71B. It did not include and programming, but otherwise implemented most of the 71B built-in "math functions" which includes stuff like factorial, trig, R<>P, HR<>HMS, with full 71B precision, etc. but does not support Matrices or some of the other more advanced 71B stuff (e.g. NAN and IEEE stuff). It came with an overlay with about 40 function/key assignments, and it retained the full stack (plus LAST and STO/RCL) between sessions, and also provided keywords to let a BASIC program retrieve the X, Y, Z, and T values.

It was intended to provide a way (and successfully accomplished) for RPN-trained users to 'just do interactive calculations' on the 71B. The cute built-in CALC mode was an attempt at that, and while it did have advantages over normal AOS, it couldn't compare with RPN. It's because of this program that I was able to wean off the 41C and onto the 71B as my primary machine.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
04-30-2017, 09:07 PM
Post: #7
RE: math in today's comics
(04-30-2017 07:48 PM)rprosperi Wrote:  
(04-30-2017 04:58 PM)Don Shepherd Wrote:  Don't you mean BASIC?

No, there's a "BIN" (for binary, written in assembler) RPN Calculator program created back in the day by Chris Capaner, that provides a full-featured 4-level RPN for the 71B. It did not include and programming, but otherwise implemented most of the 71B built-in "math functions" which includes stuff like factorial, trig, R<>P, HR<>HMS, with full 71B precision, etc. but does not support Matrices or some of the other more advanced 71B stuff (e.g. NAN and IEEE stuff). It came with an overlay with about 40 function/key assignments, and it retained the full stack (plus LAST and STO/RCL) between sessions, and also provided keywords to let a BASIC program retrieve the X, Y, Z, and T values.

It was intended to provide a way (and successfully accomplished) for RPN-trained users to 'just do interactive calculations' on the 71B. The cute built-in CALC mode was an attempt at that, and while it did have advantages over normal AOS, it couldn't compare with RPN. It's because of this program that I was able to wean off the 41C and onto the 71B as my primary machine.

Oh, I had not heard about that, but I guess I'm not surprised that someone did that. Being a BASIC nut, I acquired a 71b a few years ago. It was a great calculator, but I could never get used to its 2 or 3-line display. When I program, I want to see several lines at once, and I found this display too limiting to be useful to me. I much prefer the 8-line display of the Tandy 102 BASIC system.
Find all posts by this user
Quote this message in a reply
05-01-2017, 02:31 AM
Post: #8
RE: math in today's comics
(04-30-2017 09:07 PM)Don Shepherd Wrote:  It was a great calculator, but I could never get used to its 2 or 3-line display. When I program, I want to see several lines at once, and I found this display too limiting to be useful to me. I much prefer the 8-line display of the Tandy 102 BASIC system.

Your memory is far too generous, the 71B has only 1-line of 22 characters. I agree better machines of that type have come along, but one never forgets his first love.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
05-01-2017, 12:43 PM
Post: #9
RE: math in today's comics
(05-01-2017 02:31 AM)rprosperi Wrote:  Your memory is far too generous, the 71B has only 1-line of 22 characters. I agree better machines of that type have come along, but one never forgets his first love.
Ah yes, a peek at the museum would have refreshed my memory.

First love. I was lucky, I married mine 43 years ago and we are both enjoying our new first grandchild now.

Calculator-wise, the first one I remember was a Chadwick "Magic Brain" that had a stylus you inserted and pulled the numbers down to add or up to subtract. I was amazed at how that worked. Then there was a Hasbro toy mechanical calculator that worked similarly as I recall. My first electronic was the Victor MEC 2, a beautiful but costly machine that unfortunately died when I left it sitting on the AC charger without the charger being plugged in, I think; that incident taught me to read manuals.
Find all posts by this user
Quote this message in a reply
Post Reply 




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