Author Topic: (Challenge - Advanced)  (Read 8019 times)

0 Members and 1 Guest are viewing this topic.

whdjr

  • Guest
(Challenge - Advanced)
« on: January 27, 2005, 08:52:35 AM »
This is an advanced challenge (or at least I thought it was).  Please allow 4 hours from the time of this post before submitting your answers.  You may post a comment saying you're finished or you may post a question, but no answers until the buzzer sounds.

Challenge:  
Turn a supplied point list (assume it is an even length) into a 2d point list.  
Ex. '(1 2 3 4 5 6 7 8 9 10) would become '((1 2) (3 4) (5 6) (7 8) (9 10)).  
An application for this would be to take a point list from a lightweight polyline and turn it into a 2d list of coordinates.

Please respect this forum by not posting an answer until the allotted time has expired.

SMadsen

  • Guest
(Challenge - Advanced)
« Reply #1 on: January 27, 2005, 09:10:11 AM »
What does the buzzer sound like?

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
(Challenge - Advanced)
« Reply #2 on: January 27, 2005, 09:23:56 AM »
Hey, this sounds familiar. Hey Stig werent you and i working somthing like this at one time? (By that i mean, didnt i ask you for code and when you gave me some i claimed it as my own.)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SMadsen

  • Guest
(Challenge - Advanced)
« Reply #3 on: January 27, 2005, 09:34:30 AM »
Quote from: Se7en
.. and when you gave me some i claimed it as my own.
Probably, .. you always do!  :lol:  :lol:

whdjr

  • Guest
(Challenge - Advanced)
« Reply #4 on: January 27, 2005, 09:47:24 AM »
Quote from: SMadsen
What does the buzzer sound like?

I can't do it now because everyone will think the challenge is over.

Quote from: Se7en
Hey Stig werent you and i working somthing like this at one time?

Ok you two are not allowed to post your answers because you confessed to already looking at the answers.  
MARK!  STIG AND SE7EN ARE CHEATERS!:P

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
(Challenge - Advanced)
« Reply #5 on: January 27, 2005, 10:18:21 AM »
Well Stig and i (read: Stig) may have already figured this out (read: i claimed it as my own.) but i just created my very own. (Just now) the one we worked on was a little more complicated then this. It was for picking points and creating a list on the fly... but anyways
I have mine ready.

Total of 5 lines of code. (Its meats your criteria exactly.)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Jeff_M

  • King Gator
  • Posts: 4088
  • C3D user & customizer
Re: (Challenge - Advanced)
« Reply #6 on: January 27, 2005, 11:01:49 AM »
Quote from: whdjr
You may post a comment saying you're finished or you may post a question, but no answers until the buzzer sounds.

I have mine that will accept a list returned from LWPlines or 3dPlines..... :D

whdjr

  • Guest
Re: (Challenge - Advanced)
« Reply #7 on: January 27, 2005, 11:13:24 AM »
Quote from: Jeff_M
Quote from: whdjr
You may post a comment saying you're finished or you may post a question, but no answers until the buzzer sounds.

I have mine that will accept a list returned from LWPlines or 3dPlines..... :D


That means you didn't follow directions. :?





Show Off!  :wink:

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
(Challenge - Advanced)
« Reply #8 on: January 27, 2005, 11:14:32 AM »
Hey, no way Jeff. Thats cheeting! You have to meet the criteria not the application!?

I demand a recount!!

:P
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Jeff_M

  • King Gator
  • Posts: 4088
  • C3D user & customizer
Re: (Challenge - Advanced)
« Reply #9 on: January 27, 2005, 11:28:45 AM »
Quote from: whdjr

That means you didn't follow directions. :?

Show Off!  :wink:

Wait, the directions stated:
Quote from: whdjr
Turn a supplied point list (assume it is an even length) into a 2d point list.

So if mine takes a list and converts it to a 2d point, then it's just as requested.....it's just that mine can ALSO do 3d.... :D

whdjr

  • Guest
(Challenge - Advanced)
« Reply #10 on: January 27, 2005, 11:32:18 AM »
So what are using to determine if an even numbered list is 2d or 3d?

whdjr

  • Guest
(Challenge - Advanced)
« Reply #11 on: January 27, 2005, 11:50:18 AM »
I have to go to an AIA luncheon, so if I fall asleep and don't get back in time you guys go ahead and post your code when the buzzer hits 4 hours.

SMadsen

  • Guest
(Challenge - Advanced)
« Reply #12 on: January 27, 2005, 01:00:06 PM »
Gotta catch a train and I think the buzzer went (?) .. so:

Code: [Select]
(defun pairup (lst)
  (cond ((null lst) nil)
        ((cons (list (car lst) (cadr lst)) (pairup (cddr lst))))
  )
)


(setq alst '(1 2 3 4 5 6 7 8 9 10))
(pairup alst) -> ((1 2) (3 4) (5 6) (7 8 ) (9 10))

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
(Challenge - Advanced)
« Reply #13 on: January 27, 2005, 01:02:11 PM »
Ahh recursion. I went the direct route.

Code: [Select]
;;; Command: (setq alst '(1 2 3 4 5 6 7 8 9 0))
;;; (1 2 3 4 5 6 7 8 9 0)
;;;
;;; Command: (lstoftwo alst)
;;; ((1 2) (3 4) (5 6) (7 8) (9 0))
;;;
;;; Command: (setq alst '(1 2 3 4 5 6 7 8 9))
;;; (1 2 3 4 5 6 7 8 9)
;;;
;;; Command: (lstoftwo alst)
;;; ((1 2) (3 4) (5 6) (7 8) (9 nil))
(defun lstoftwo (x / nlst)
  (while (> (length x) 0)
     (setq nlst (cons (list (car x) (cadr x)) nlst))
       (setq x (cddr x))) (reverse nlst) )
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

whdjr

  • Guest
(Challenge - Advanced)
« Reply #14 on: January 27, 2005, 02:01:49 PM »
Very Good.

I also went the recursive route.

Code: [Select]
(defun lst->2dlst (lst / a b)
  (setq a (list (car lst) (cadr lst)))
  (if (setq b (cddr lst))
    (append (list a) (lst->2dlst b))
    (list a)
  )
)