|
-
Jan 15th, 2017, 01:47 AM
#1
Thread Starter
Addicted Member
I finally got it!
I finally understand how to add 2 numbers properly! Try it out yourself!
Code:
Function Add(A As Integer, B As Integer) As Integer
Dim C As Integer = CInt((Math.Sign(A) * Math.Abs(A)).ToString.ToUpper.ToLower)
Dim D As New List(Of Integer)
With D
.Add(CInt(CStr(CInt(CStr(CInt(B.ToString))))))
End With
A = A * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 1 * 0
B = CInt(Math.Sqrt(Math.Pow(B, 2))) - ----((((((((((((B))))))))))))
If True OrElse False Then A = ((((((((((((((((((((((C * 2)))))))))))))))) - --------C))))))
If True AndAlso A - -1 > A Then B = Convert.ToInt32(D(0) * 2) - Convert.ToInt32(Convert.ToInt64(D(0)))
Dim E As New With {.Value = A + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + (10000 * 0)}
Dim F() As Integer = {B}
A = CInt(C.ToString.ToString.ToString.ToString.ToString.ToString.ToString.ToString)
B = (((((((((((((((((((((((((((((((((((((((((((((D(0) + D(0) - D(0))))))))))))))))))))))))))))))))))))))))))))))
Return E.Value + F(0) + (2 * (A + B) - A - B) - (C + D(0))
End Function
-
Jan 15th, 2017, 01:58 AM
#2
-
Jan 15th, 2017, 08:48 AM
#3
The best argument against democracy is a five minute conversation with the average voter - Winston Churchill
Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd
-
Jan 15th, 2017, 11:10 AM
#4
Thread Starter
Addicted Member
Re: I finally got it!
Here's the recursion:
Code:
Function Add(A As Integer, B As Integer) As Integer
If A = 0 AndAlso B > 0 Then Return 1 + Add(A, B - 1)
If A = 0 AndAlso B < 0 Then Return -1 + Add(A, B + 1)
If A > 0 AndAlso B = 0 Then Return 1 + Add(A - 1, B)
If A < 0 AndAlso B = 0 Then Return -1 + Add(A + 1, B)
If A > 0 AndAlso B < 0 Then Return Add(A - 1, B + 1)
If A < 0 AndAlso B > 0 Then Return Add(A + 1, B - 1)
If A > 0 AndAlso B > 0 Then Return 2 + Add(A - 1, B - 1)
If A < 0 AndAlso B < 0 Then Return -2 + Add(A + 1, B + 1)
If A = 0 AndAlso B = 0 Then Return 0
End Function
I tried to improve it, but I kept on getting a StackOverflowException. 
Code:
Function Add(A As Integer, B As Integer) As Integer
If A = 0 AndAlso B > 0 Then Return 1 + Add(A, Add(B, -1))
If A = 0 AndAlso B < 0 Then Return -1 + Add(A, Add(B, 1))
If A > 0 AndAlso B = 0 Then Return 1 + Add(Add(A, -1), B)
If A < 0 AndAlso B = 0 Then Return -1 + Add(Add(A, 1), B)
If A > 0 AndAlso B < 0 Then Return Add(Add(A, -1), Add(B, 1))
If A < 0 AndAlso B > 0 Then Return Add(Add(A, 1), Add(B, -1))
If A > 0 AndAlso B > 0 Then Return 2 + Add(Add(A, -1), Add(B, -1))
If A < 0 AndAlso B < 0 Then Return -2 + Add(Add(A, 1), Add(B, 1))
If A = 0 AndAlso B = 0 Then Return 0
End Function
-
Jan 15th, 2017, 12:11 PM
#5
Re: I finally got it!
 Originally Posted by NinjaNic
I tried to improve it, but I kept on getting a StackOverflowException. 
You can find a solution to that here
-
Jan 15th, 2017, 12:37 PM
#6
Thread Starter
Addicted Member
Re: I finally got it!
 Originally Posted by si_the_geek
You can find a solution to that here
Good find.
Last edited by NinjaNic; Jan 15th, 2017 at 12:38 PM.
Reason: Found the solution here
-
Jan 15th, 2017, 04:33 PM
#7
Re: I finally got it!
I thought it was going to be a link to an exceptional Stack Overflow thread.
My usual boring signature: Nothing
 
-
Jan 15th, 2017, 06:32 PM
#8
Thread Starter
Addicted Member
Re: I finally got it!
 Originally Posted by Shaggy Hiker
I thought it was going to be a link to an exceptional Stack Overflow thread.
Me too, to be honest.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|