Post Reply 
Programming puzzles: processing lists!
04-22-2017, 11:50 AM (This post was last modified: 04-22-2017 02:04 PM by pier4r.)
Post: #21
RE: Programming puzzles: processing lists!
I renew the request that someone with the HP prime starts to check / evaluate the solutions of Han and Didier. At the moment I have time just for the RPL.

Challenge 3 code, reusing one of the list operation programmed some time ago
https://app.assembla.com/spaces/various-...ms/general
Code:


    c3vaV1
    @given alist of length 100 of integers
    @ put floor(list_size/3) elements at the beginning
    
    @it seems correct
    @ avg 0.039 secs for 10 lists of 10 elements.
    @ avg 0.15 secs for 50 lists of 100 elements.
    \<<
      { } @resultList
      \->
      @input
      inputList
      @local
      resList
      \<<
        inputList
        inputList SIZE 3 / IP
        rotateListTail
      \>>
    \>>

    rotateListTail
  \<<
    
    0 @numElements
    \->
    @input
    listV
    numRotationsV
    @local var
    numElements
    \<<
      listV OBJ\-> 'numElements' STO
      
      1 numRotationsV
      START
        numElements ROLLD
      NEXT
      
      numElements \->LIST
    \>>
  \>>


VS davidM code of the previous post (nice code once again, but this time the operation was complicated)

Mine: @ avg 0.15 secs for 50 lists of 100 elements.
DavidM: @ avg 1.94 secs for 50 lists of 100 elements.

This time I got one back (although with an helper routine).

Side question: I am not able to save a list in a list, without using another variable.

I mean {1 2 3} {1 2 3} + returns {1 2 3 1 2 3}. What is the operation to return {1 2 3 {1 2 3} } ?

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming puzzles: processing lists! - pier4r - 04-22-2017 11:50 AM



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