Author Topic: (Challange) Interpolate  (Read 5985 times)

0 Members and 1 Guest are viewing this topic.

JohnK

  • Administrator
  • Seagull
  • Posts: 10638
(Challange) Interpolate
« on: January 05, 2005, 10:09:27 AM »
This challange is to interpolate between two knows situations and return the third unknown value. For instance:

Key -- Value
--------------
20  --  2400
28  --  3200

Find the value for the key 24 and return it to me.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

whdjr

  • Guest
(Challange) Interpolate
« Reply #1 on: January 05, 2005, 10:19:41 AM »
24 = 2800

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(Challange) Interpolate
« Reply #2 on: January 05, 2005, 10:27:18 AM »
I got my answer ....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

JohnK

  • Administrator
  • Seagull
  • Posts: 10638
(Challange) Interpolate
« Reply #3 on: January 05, 2005, 10:36:57 AM »
So when do you think we can start posting our solutions? (What did we decide that one time we were talking about submitting lisp to these challanges.)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
(Challange) Interpolate
« Reply #4 on: January 05, 2005, 10:47:21 AM »
Well I'd give it a few hours any way.
TheSwamp.org  (serving the CAD community since 2003)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(Challange) Interpolate
« Reply #5 on: January 05, 2005, 10:49:41 AM »
dunno ... it is your thread ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

JohnK

  • Administrator
  • Seagull
  • Posts: 10638
(Challange) Interpolate
« Reply #6 on: January 05, 2005, 10:58:25 AM »
Okay, a few hours it is then.

Give 'er two hours.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

whdjr

  • Guest
(Challange) Interpolate
« Reply #7 on: January 05, 2005, 10:58:57 AM »
I thought we said it was up to the original poster of the question.
Hence no directions so I didn't hold back.

whdjr

  • Guest
(Challange) Interpolate
« Reply #8 on: January 05, 2005, 10:59:52 AM »
I guess I was too early AND too late.

JohnK

  • Administrator
  • Seagull
  • Posts: 10638
(Challange) Interpolate
« Reply #9 on: January 05, 2005, 11:02:09 AM »
lol ...No your lisp. You can post the answer. The  answer is not that hard to achieve.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SMadsen

  • Guest
(Challange) Interpolate
« Reply #10 on: January 05, 2005, 11:58:13 AM »
So, you want a linear or a weighed interpolation? What if the values looked like this?

20 -- 2400
28 -- 3200
30 -- 3205

JohnK

  • Administrator
  • Seagull
  • Posts: 10638
(Challange) Interpolate
« Reply #11 on: January 05, 2005, 12:06:44 PM »
ummm... yes!

:shock: :P

Actualy, I just made mine to handle linear, but if you got one for weighted, thats extra cool!
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(Challange) Interpolate
« Reply #12 on: January 05, 2005, 12:21:54 PM »
Ok ...2 hours are up .....

Code: [Select]
(defun interpolate ( @k1 @v1 @k2 @v2 @N )
  (+ @v1(*(/(- @v2 @v1)(- @k2 @k1))(- @N @k1)))
)


Syntax:
(interpolate Key1 Value1 Key2 Value2 UnknownKey)
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

JohnK

  • Administrator
  • Seagull
  • Posts: 10638
(Challange) Interpolate
« Reply #13 on: January 05, 2005, 01:11:44 PM »
mine too.  ...Wow same one. (Well i guess that was to be expected. Its just a formula after all huh?!)

Code: [Select]
;;;
;;; Example:
;;; 20  --  2400
;;; 28  --  3200
;;; Find the value for: 24
;;; (interpolate 20 2400 28 3200 24)
;;; -> 2800
(defun interpolate (n1 v1 n2 v2 n3)
  (+ (* (/ (- v2 v1) (- n2 n1)) (- n3 n1)) v1))
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

whdjr

  • Guest
(Challange) Interpolate
« Reply #14 on: January 05, 2005, 01:29:07 PM »
hm... no formula here.  Just logic.  24 is halfway between 20 and 28, so 2800 is halfway between 2400 and 3200.  :D