Skip to content

Instantly share code, notes, and snippets.

@dmahapatro
Last active January 4, 2016 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmahapatro/8660084 to your computer and use it in GitHub Desktop.
Save dmahapatro/8660084 to your computer and use it in GitHub Desktop.
Prove two adjacent numbers are equal.
//Prove 4 == 5
def lhs = 4
def rhs = 5
assert -20 == -20
assert 16 - 36 == 25 - 45
assert lhs ** 2 - 36 == rhs ** 2 - 45
assert lhs ** 2 - 2 * lhs * ( 9 / 2 ) == rhs ** 2 - 2 * rhs *( 9 / 2 )
assert lhs ** 2 - 2 * lhs * ( 9 / 2 ) + ( 9 / 2 ) ** 2 == rhs ** 2 - 2 * rhs * ( 9 / 2 ) + ( 9 / 2 ) ** 2
assert ( lhs - ( 9 / 2 ) ) ** 2 == ( rhs - ( 9 / 2 ) ) ** 2 //[(a-b)**2 == a**2 + b**2 - 2*a*b]
assert Math.sqrt( ( lhs - ( 9 / 2 ) ) ** 2 ) == Math.sqrt( ( rhs - ( 9 / 2 ) ) ** 2 )
assert Math.abs( lhs - ( 9 / 2 ) ) == Math.abs( rhs - ( 9 / 2 ) )
//Caveat
assert lhs - 9 / 2 != rhs - 9 / 2
//Hence
assert lhs != rhs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment