Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions solutions/8th/triangle/2/triangle.8th
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
: istriangle? \ n n n -- T
3dup
3dup n:- n:abs swap n:< -3 roll
rot 3dup n:- n:abs swap n:< -3 roll
rot n:- n:abs swap n:<
and and
;

: equilateral? \ n n n -- T
istriangle? not if 3drop false
else
2dup n:= -3 roll
rot n:=
drop and
then
;

: scalene? \ n n n -- T
istriangle? not if 3drop false
else
2dup n:= not -3 roll
rot 2dup n:= not -3 roll
rot 2dup n:= not -3 roll
3drop and and
then
;

: isosceles? \ n n n -- T
istriangle? not if 3drop false
else
2dup n:= -3 roll
rot 2dup n:= -3 roll
rot 2dup n:= -3 roll
3drop xor xor
then
;