Post Reply 
Programming puzzles: processing lists!
02-13-2019, 12:49 PM
Post: #268
RE: Programming puzzles: processing lists!
(02-12-2019 06:12 PM)pier4r Wrote:  Ok adapted the #44
...

Taking advantage of the fact that 1+2+3+...n is equivalent to \(\frac{n(n+1)}{2}\), the following could be used for #44 (uses ListExt):
Code:
Spoiler...










\<<
   @ get counts of repeated wins/losses
   LRPCT

   @ separate above results, add 2 to stack
   LIST\->

   @ swap W/L and count list positions
   ROT SWAP

   @ perform for each pair (count[n] and W/L)
   \<<
      IF THEN
         DUPDUP * + 2 /    @ W: sum(1..n) = n(n+1)/2
      ELSE
         DROP              @ L: drop the count
      END
   \>>
   DOLIST

   @ sum the result list
   LSUM
\>>

Adapting the above to accommodate the original (7+8+9...) scoring simply requires a slight adjustment.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming puzzles: processing lists! - DavidM - 02-13-2019 12:49 PM



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