Challenge: Un-Recursive (Simple?)

  • (4 Pages)
  • +
  • « First
  • 2
  • 3
  • 4

50 Replies - 17608 Views - Last Post: 18 September 2013 - 04:57 AM

#46 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Challenge: Un-Recursive (Simple?)

Posted 05 May 2013 - 12:50 PM

This is my final, and it returns the same as recursive:
Spoiler

Was This Post Helpful? 1
  • +
  • -

#47 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2240
  • View blog
  • Posts: 9,411
  • Joined: 29-May 08

Re: Challenge: Un-Recursive (Simple?)

Posted 05 May 2013 - 12:52 PM

You sure? Final answer? Do you need to phone a friend?
Was This Post Helpful? 1
  • +
  • -

#48 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2240
  • View blog
  • Posts: 9,411
  • Joined: 29-May 08

Re: Challenge: Un-Recursive (Simple?)

Posted 05 May 2013 - 01:13 PM

Give lucky3 a Coconut. :^:
Give modi123_1 a Goldfish in a bag. :^:

This post has been edited by AdamSpeight2008: 05 May 2013 - 01:18 PM

Was This Post Helpful? 0
  • +
  • -

#49 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2240
  • View blog
  • Posts: 9,411
  • Joined: 29-May 08

Re: Challenge: Un-Recursive (Simple?)

Posted 07 May 2013 - 01:41 PM

1 LoC Non-Recursive version. :ph34r:
Public Function AddWorkDays(d As Date, x As Integer) As Date
  Return  d.AddDays(If(x<0, 0, If( d.IsA(Saturday), 2, If( d.IsA(Sunday), 1, 0) ) )+((2* Math.Floor(x * (2/7)))+x))
End Function 



I'm pretty sure it works. It works for the values I've tried.
Was This Post Helpful? 0
  • +
  • -

#50 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Challenge: Un-Recursive (Simple?)

Posted 10 May 2013 - 10:25 AM

AdamSpeight2008 please try your 1 LoC function with d = #5/3/2013# and x = 1.
I get Saturday (4th of May) as return. For x = -1, it returns Tuesday, April 30th... Am I testing it wrongly with IsA extension?

This post has been edited by lucky3: 10 May 2013 - 10:32 AM

Was This Post Helpful? 1
  • +
  • -

#51 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: Challenge: Un-Recursive (Simple?)

Posted 18 September 2013 - 04:57 AM

how about this one
Spoiler

Was This Post Helpful? 0
  • +
  • -

  • (4 Pages)
  • +
  • « First
  • 2
  • 3
  • 4