Post Reply 
HP49-HP50 : when {list of repeated solutions} —> {list with no rep. sol}
12-21-2022, 05:03 PM
Post: #4
RE: HP49-HP50 : when {list of repeated solutions} —> {list with no rep. sol}
Here's another solution using SORT and STREAM. You have to use it after converting the list items to strings because you can't sort a list of arrays. This should be faster O(n*log(n)) than Werner's (O(n2))when the input is large.

Half the code is devoted to converting the results from individual items on the stack back into a list. Maybe there's an easier way that's still fast.

Code:
« DEPTH  → D
  «
  SORT
  « DUP2 IF == THEN DROP END »
  STREAM
  DEPTH D - 1. + →LIST
  »
»
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP49-HP50 : when {list of repeated solutions} —> {list with no rep. sol} - David Hayden - 12-21-2022 05:03 PM



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