Jelly, (削除) 32 (削除ここまで) 27 bytes
,U=€JẸ,E,SÆ2$E;SÆ2$
ZL«L’aL€Ç$æA/ZL«L’aL€Ç$æAƝ
Now taking input at a list of lines and switched &g×ばつ with ’a and using SÆ2 after L€ instead of FLÆ2Ɗ. These allowed me to condense into two lines and I saved 5 bytes in total. The following values are the same as before.
[0.0, 0.0]=Mess
[0.0, 1.5707963267948966]=Rectangle
[0.0, 0.7853981633974483]=Square
[1.5707963267948966, 0.0]=Triangle
ZL«L gets the minimum of height and width and ’ subtracts 1 from it. Ç calls the second link and at the end if the input is a single line the result of Ç gets logical ANDed with the previous number if there is only a single line the output will be [0.0, 0.0].
In the second link: ,U yields a list of line lengths paired with it's reverse. J is range(number of lines) and =€ checks whether each of them are equal to the result of J. Ẹ (Any) yields 1 if the input is a triangle.
E checks if all line lengths are equal (rectangle/square).
SÆ2 with a $ to group them into a single monad checks whether the total number of characters is a square number.
So at the end of the second link we have [[a,b],c] where each number is 0 or 1 indicating whether the input is a triangle, rectangular, and has square number of characters respectively.
However a square number of elements doesn't imply the input is a square since an messy input like
a3.
4
has a square number of elements but isn't a square.
This is where æA (arctan2) comes in. 0æA0 == 0æA1 == 0. In other words, if the input has square number of elements but is not a rectangle, then it is not a square. There are certainly more clear ways to do this but what does that matter when we have bytes to think about and we are allowed consistent arbitrary output.
Note I was previously using æA/ instead of æAƝ (and a , instead of a ; in the second link) but the former method distinguishes between triangles that have square number of elements and those that don't but they should obviously be counted as the same thing.
Jelly, (削除) 32 (削除ここまで) 27 bytes
,U=€JẸ,E,SÆ2$
ZL«L’aL€Ç$æA/
Now taking input at a list of lines and switched &g×ばつ with ’a and using SÆ2 after L€ instead of FLÆ2Ɗ. These allowed me to condense into two lines and I saved 5 bytes in total. The following values are the same as before.
[0.0, 0.0]=Mess
[0.0, 1.5707963267948966]=Rectangle
[0.0, 0.7853981633974483]=Square
[1.5707963267948966, 0.0]=Triangle
ZL«L gets the minimum of height and width and ’ subtracts 1 from it. Ç calls the second link and at the end if the input is a single line the result of Ç gets logical ANDed with the previous number if there is only a single line the output will be [0.0, 0.0].
In the second link: ,U yields a list of line lengths paired with it's reverse. J is range(number of lines) and =€ checks whether each of them are equal to the result of J. Ẹ (Any) yields 1 if the input is a triangle.
E checks if all line lengths are equal (rectangle/square).
SÆ2 with a $ to group them into a single monad checks whether the total number of characters is a square number.
So at the end of the second link we have [[a,b],c] where each number is 0 or 1 indicating whether the input is a triangle, rectangular, and has square number of characters respectively.
However a square number of elements doesn't imply the input is a square since an messy input like
a3.
4
has a square number of elements but isn't a square.
This is where æA (arctan2) comes in. 0æA0 == 0æA1 == 0. In other words, if the input has square number of elements but is not a rectangle, then it is not a square. There are certainly more clear ways to do this but what does that matter when we have bytes to think about and we are allowed consistent arbitrary output.
Jelly, (削除) 32 (削除ここまで) 27 bytes
,U=€JẸ,E;SÆ2$
ZL«L’aL€Ç$æAƝ
Now taking input at a list of lines and switched &g×ばつ with ’a and using SÆ2 after L€ instead of FLÆ2Ɗ. These allowed me to condense into two lines and I saved 5 bytes in total. The following values are the same as before.
[0.0, 0.0]=Mess
[0.0, 1.5707963267948966]=Rectangle
[0.0, 0.7853981633974483]=Square
[1.5707963267948966, 0.0]=Triangle
ZL«L gets the minimum of height and width and ’ subtracts 1 from it. Ç calls the second link and at the end if the input is a single line the result of Ç gets logical ANDed with the previous number if there is only a single line the output will be [0.0, 0.0].
In the second link: ,U yields a list of line lengths paired with it's reverse. J is range(number of lines) and =€ checks whether each of them are equal to the result of J. Ẹ (Any) yields 1 if the input is a triangle.
E checks if all line lengths are equal (rectangle/square).
SÆ2 with a $ to group them into a single monad checks whether the total number of characters is a square number.
So at the end of the second link we have [[a,b],c] where each number is 0 or 1 indicating whether the input is a triangle, rectangular, and has square number of characters respectively.
However a square number of elements doesn't imply the input is a square since an messy input like
a3.
4
has a square number of elements but isn't a square.
This is where æA (arctan2) comes in. 0æA0 == 0æA1 == 0. In other words, if the input has square number of elements but is not a rectangle, then it is not a square. There are certainly more clear ways to do this but what does that matter when we have bytes to think about and we are allowed consistent arbitrary output.
Note I was previously using æA/ instead of æAƝ (and a , instead of a ; in the second link) but the former method distinguishes between triangles that have square number of elements and those that don't but they should obviously be counted as the same thing.
Jelly, 32(削除) 32 (削除ここまで) 27 bytes
,U=€JẸ,E
L€ÇæAFLÆ2Ɗ,SÆ2$
ỴμZL«L&g×ばつÇZL«L’aL€Ç$æA/
Now taking input at a list of lines and switched &g×ばつ with ’a and using SÆ2 after L€ instead of FLÆ2Ɗ. These allowed me to condense into two lines and I saved 5 bytes in total. The following values are the same as before.
[0.0, 0.0]=Mess
[0.0, 1.5707963267948966]=Rectangle
[0.0, 0.7853981633974483]=Square
[1.5707963267948966, 0.0]=Triangle
ỴZL«L splitsgets the input on newlines to get a listminimum of linesheight and μ starts a new monadic link with the list of lines as it's argument.
ZL«L>1 checks whether the input is a single line or if all lines only have 1 character. Returns 0 if it iswidth and 1’ ifsubtracts 1 from it isn't. Ç calls the second link (which calls the third) and at the end if the input is a single line the result of Ç gets multiplied by 0 so it doesn't get confused for a rectangle, square or triangle.
In the beginning of the second link: L€ calculates the length of each line oflogical ANDed with the input and this list of intsprevious number if there is passed toonly a single line the third link withoutput will be Ç[0.0, 0.0].
In the thirdsecond link: ,U pairs theyields a list of line lengths paired with it's reverse.=€J checks if €Jach of these is equal to [1 2range(number ..of n]lines) whereand n=€ ischecks whether each of them are equal to the numberresult of lines (what J returns). If either of these is true Ẹ (anyAny) returns 1 which means we haveyields 1 if the input is a triangle and 0 if we don't have one. Finally,
E checks whetherif all lines have the same length and this result gets paired with theline lengths are equal (rectangle/square).
0SÆ2/ with a 1$ indicating triangularness. There are two extra spaces at the end to pad this line to the same length asgroup them into a single monad checks whether the other twototal number of characters is a square number.
So at the end of the third linesecond link we have [1[[a,0]b],c] if the inputwhere each number is a triangle and [0,1]0 ifor 1 indicating whether the input is a rectangle ortriangle, rectangular, and has square. Now back to the second link number of characters respectively.
FLÆ2 acts as However a monad (Ɗ groups them together). It Flattens the listsquare number of lines, takeselements doesn't imply the Length then checks if itinput is a sÆ2quare number. This test isn't perfect however because it yields 1 forsquare since an messy input like
that has a square number of elements but isn't a square.
Jelly, 32 bytes
,U=€JẸ,E
L€ÇæAFLÆ2Ɗ
ỴμZL«L&g×ばつÇ
[0.0, 0.0]=Mess
[0.0, 1.5707963267948966]=Rectangle
[0.0, 0.7853981633974483]=Square
[1.5707963267948966, 0.0]=Triangle
Ỵ splits the input on newlines to get a list of lines and μ starts a new monadic link with the list of lines as it's argument.
ZL«L>1 checks whether the input is a single line or if all lines only have 1 character. Returns 0 if it is and 1 if it isn't. Ç calls the second link (which calls the third) and at the end if the input is a single line the result of Ç gets multiplied by 0 so it doesn't get confused for a rectangle, square or triangle.
In the beginning of the second link: L€ calculates the length of each line of the input and this list of ints is passed to the third link with Ç.
In the third link ,U pairs the list of line lengths with it's reverse.=€J checks if €ach of these is equal to [1 2 .. n] where n is the number of lines (what J returns). If either of these is true Ẹ (any) returns 1 which means we have a triangle and 0 if we don't have one. Finally, E checks whether all lines have the same length and this result gets paired with the 0/1 indicating triangularness. There are two extra spaces at the end to pad this line to the same length as the other two.
So at the end of the third line we have [1,0] if the input is a triangle and [0,1] if the input is a rectangle or square. Now back to the second link.
FLÆ2 acts as a monad (Ɗ groups them together). It Flattens the list of lines, takes the Length then checks if it is a sÆ2quare number. This test isn't perfect however because it yields 1 for an input like
that has a square number of elements but isn't a square.
Jelly, (削除) 32 (削除ここまで) 27 bytes
,U=€JẸ,E,SÆ2$
ZL«L’aL€Ç$æA/
Now taking input at a list of lines and switched &g×ばつ with ’a and using SÆ2 after L€ instead of FLÆ2Ɗ. These allowed me to condense into two lines and I saved 5 bytes in total. The following values are the same as before.
[0.0, 0.0]=Mess
[0.0, 1.5707963267948966]=Rectangle
[0.0, 0.7853981633974483]=Square
[1.5707963267948966, 0.0]=Triangle
ZL«L gets the minimum of height and width and ’ subtracts 1 from it. Ç calls the second link and at the end if the input is a single line the result of Ç gets logical ANDed with the previous number if there is only a single line the output will be [0.0, 0.0].
In the second link: ,U yields a list of line lengths paired with it's reverse. J is range(number of lines) and =€ checks whether each of them are equal to the result of J. Ẹ (Any) yields 1 if the input is a triangle.
E checks if all line lengths are equal (rectangle/square).
SÆ2 with a $ to group them into a single monad checks whether the total number of characters is a square number.
So at the end of the second link we have [[a,b],c] where each number is 0 or 1 indicating whether the input is a triangle, rectangular, and has square number of characters respectively.
However a square number of elements doesn't imply the input is a square since an messy input like
has a square number of elements but isn't a square.
Jelly, 32 bytes
,U=€JẸ,E
L€ÇæAFLÆ2Ɗ
ỴμZL«L&g×ばつÇ
[0.0, 0.0]=Mess
[0.0, 1.5707963267948966]=Rectangle
[0.0, 0.7853981633974483]=Square
[1.5707963267948966, 0.0]=Triangle
Ỵ splits the input on newlines to get a list of lines and μ starts a new monadic link with the list of lines as it's argument.
ZL«L>1 checks whether the input is a single line or if all lines only have 1 character. Returns 0 if it is and 1 if it isn't. Ç calls the second link (which calls the third) and at the end if the input is a single line the result of Ç gets multiplied by 0 so it doesn't get confused for a rectangle, square or triangle.
In the beginning of the second link: L€ calculates the length of each line of the input and this list of ints is passed to the third link with Ç.
In the third link ,U pairs the list of line lengths with it's reverse. =€J checks if €ach of these is equal to [1 2 .. n] where n is the number of lines (what J returns). If either of these is true Ẹ (any) returns 1 which means we have a triangle and 0 if we don't have one. Finally, E checks whether all lines have the same length and this result gets paired with the 0/1 indicating triangularness. There are two extra spaces at the end to pad this line to the same length as the other two.
So at the end of the third line we have [1,0] if the input is a triangle and [0,1] if the input is a rectangle or square. Now back to the second link.
FLÆ2 acts as a monad (Ɗ groups them together). It Flattens the list of lines, takes the Length then checks if it is a sÆ2quare number. This test isn't perfect however because it yields 1 for an input like
a3.
4
that has a square number of elements but isn't a square.
This is where æA (arctan2) comes in. 0æA0 == 0æA1 == 0. In other words, if the input has square number of elements but is not a rectangle, then it is not a square. There are certainly more clear ways to do this but what does that matter when we have bytes to think about and we are allowed consistent arbitrary output.
Jelly, 32 bytes
,U=€JẸ,E
L€ÇæAFLÆ2Ɗ
ỴμZL«L&g×ばつÇ
[0.0, 0.0]=Mess
[0.0, 1.5707963267948966]=Rectangle
[0.0, 0.7853981633974483]=Square
[1.5707963267948966, 0.0]=Triangle
Ỵ splits the input on newlines to get a list of lines and μ starts a new monadic link with the list of lines as it's argument.
ZL«L>1 checks whether the input is a single line or if all lines only have 1 character. Returns 0 if it is and 1 if it isn't. Ç calls the second link (which calls the third) and at the end if the input is a single line the result of Ç gets multiplied by 0 so it doesn't get confused for a rectangle, square or triangle.
In the beginning of the second link: L€ calculates the length of each line of the input and this list of ints is passed to the third link with Ç.
In the third link ,U pairs the list of line lengths with it's reverse. =€J checks if €ach of these is equal to [1 2 .. n] where n is the number of lines (what J returns). If either of these is true Ẹ (any) returns 1 which means we have a triangle and 0 if we don't have one. Finally, E checks whether all lines have the same length and this result gets paired with the 0/1 indicating triangularness. There are two extra spaces at the end to pad this line to the same length as the other two.
So at the end of the third line we have [1,0] if the input is a triangle and [0,1] if the input is a rectangle or square. Now back to the second link.
FLÆ2 acts as a monad (Ɗ groups them together). It Flattens the list of lines, takes the Length then checks if it is a sÆ2quare number.
Jelly, 32 bytes
,U=€JẸ,E
L€ÇæAFLÆ2Ɗ
ỴμZL«L&g×ばつÇ
[0.0, 0.0]=Mess
[0.0, 1.5707963267948966]=Rectangle
[0.0, 0.7853981633974483]=Square
[1.5707963267948966, 0.0]=Triangle
Ỵ splits the input on newlines to get a list of lines and μ starts a new monadic link with the list of lines as it's argument.
ZL«L>1 checks whether the input is a single line or if all lines only have 1 character. Returns 0 if it is and 1 if it isn't. Ç calls the second link (which calls the third) and at the end if the input is a single line the result of Ç gets multiplied by 0 so it doesn't get confused for a rectangle, square or triangle.
In the beginning of the second link: L€ calculates the length of each line of the input and this list of ints is passed to the third link with Ç.
In the third link ,U pairs the list of line lengths with it's reverse. =€J checks if €ach of these is equal to [1 2 .. n] where n is the number of lines (what J returns). If either of these is true Ẹ (any) returns 1 which means we have a triangle and 0 if we don't have one. Finally, E checks whether all lines have the same length and this result gets paired with the 0/1 indicating triangularness. There are two extra spaces at the end to pad this line to the same length as the other two.
So at the end of the third line we have [1,0] if the input is a triangle and [0,1] if the input is a rectangle or square. Now back to the second link.
FLÆ2 acts as a monad (Ɗ groups them together). It Flattens the list of lines, takes the Length then checks if it is a sÆ2quare number. This test isn't perfect however because it yields 1 for an input like
a3.
4
that has a square number of elements but isn't a square.
This is where æA (arctan2) comes in. 0æA0 == 0æA1 == 0. In other words, if the input has square number of elements but is not a rectangle, then it is not a square. There are certainly more clear ways to do this but what does that matter when we have bytes to think about and we are allowed consistent arbitrary output.