You are given two angles of a triangle in degrees.
Write a function to return the third angle. Only positive integers will be tested.
Sample Test...
For further actions, you may consider blocking this person and/or reporting abuse
ANSI C
Run with
~$ gcc -lm <file_name> && ./a.out
Kept it simple
My solution in js
What happens if I enter
thirdAngle(0,0)
?Good catch. Edited. But the challenge is to deal with positive integers so didn't take 0 into account as it is neither positive nor negative integer.
True enough. But why code purely for specs when coding for the edge and error cases takes just a few more minutes?
Elm
Test it online
Here.
This oughta do it for Elixir.
In Go!
Go Playground
Solution in APL
(using Dyalog APL)
Tests:
Try it online!
Keeping it simple in bash
Running through the examples on the cmd:
BTW the challenge on Kata only tests for valid triangles,
was sufficient in JS
What happens if I enter
thirdAngle(0,0)
?you are right, I just wrote it very fast and I did not think about this case.
TDD will help a lot in these situations.