Skip to main content
added 803 characters in body
Source Link

J, 146 132 134 124

echo'parallel'"_`(1|.')(',[:(,',',])&(0j2&":)/[:,,.@{:%.}:)@.([:*@|[:-/ .*}:)|:".>{.`(<@}:@;@(1 2&{))`{:(`:0)"1;:;._2(1!:1)3 

Parsing this is awful.

Edit: Realized that my output is basically broken, although it works for the examples given and parallels...

Edit: Posting the shorter version I already had.

Edit: Fixed without too much pain...

Edit: Fixed a weird issue where the program was spread across multiple lines.

Somewhat ungolfed version:

words =: ;:;._2(1!:1)3 NB. Leverage J's parser itself to split each line into e.g. ax + by = c lines =: ".>{.`(<@}:@;@(1 2&{))`{:(`:0)"1 words NB. Use a 3-part gerund (`) to get boxed strings 'ax';'b';'c', unbox and parse calc_and_format =: 1|.')(',[:(,',',])&(0j2&":)/[:,,.@{:%.}: NB. %. (matrix multiply) first two rows (a d/b e) by third row turned (c/f) NB. And then format laboriously. 0j2&": formats numbers with 2 decimals. det_nonzero =: [:*@|[:-/ .*}: NB. 1 if determinant (-/ .*) of (a b/d e) is nonzero (*@|) echo'parallel'"_`[email protected]_nonzero|: lines NB. transpose parsed input to get (a d/b e/c f). NB. If det_nonzero, call calc_and_format, otherwise constant 'parallel' NB. Print 

J, 146 132 134 124

echo'parallel'"_`(1|.')(',[:(,',',])&(0j2&":)/[:,,.@{:%.}:)@.([:*@|[:-/ .*}:)|:".>{.`(<@}:@;@(1 2&{))`{:(`:0)"1;:;._2(1!:1)3 

Parsing this is awful.

Edit: Realized that my output is basically broken, although it works for the examples given and parallels...

Edit: Posting the shorter version I already had.

Edit: Fixed without too much pain...

Edit: Fixed a weird issue where the program was spread across multiple lines.

J, 146 132 134 124

echo'parallel'"_`(1|.')(',[:(,',',])&(0j2&":)/[:,,.@{:%.}:)@.([:*@|[:-/ .*}:)|:".>{.`(<@}:@;@(1 2&{))`{:(`:0)"1;:;._2(1!:1)3 

Parsing this is awful.

Edit: Realized that my output is basically broken, although it works for the examples given and parallels...

Edit: Posting the shorter version I already had.

Edit: Fixed without too much pain...

Edit: Fixed a weird issue where the program was spread across multiple lines.

Somewhat ungolfed version:

words =: ;:;._2(1!:1)3 NB. Leverage J's parser itself to split each line into e.g. ax + by = c lines =: ".>{.`(<@}:@;@(1 2&{))`{:(`:0)"1 words NB. Use a 3-part gerund (`) to get boxed strings 'ax';'b';'c', unbox and parse calc_and_format =: 1|.')(',[:(,',',])&(0j2&":)/[:,,.@{:%.}: NB. %. (matrix multiply) first two rows (a d/b e) by third row turned (c/f) NB. And then format laboriously. 0j2&": formats numbers with 2 decimals. det_nonzero =: [:*@|[:-/ .*}: NB. 1 if determinant (-/ .*) of (a b/d e) is nonzero (*@|) echo'parallel'"_`[email protected]_nonzero|: lines NB. transpose parsed input to get (a d/b e/c f). NB. If det_nonzero, call calc_and_format, otherwise constant 'parallel' NB. Print 
added 76 characters in body; deleted 82 characters in body
Source Link

J, 146 132 134134 124

n=echo'parallel'"_`(1|.')(',[:(,',',])&(0j2&":)/[:,,.@{:%.}:m=)@.([:*@|[:-/ .*}:)|:".>{.`(<@}:@;@(1 2&{))`{:(`:0)"1;:;._2(1!:1)3 k=:3 :0 1|.')(',(,',',])&(0j2&":)/,n%.~,.{:m ) echo'parallel'"_`k@.(*|-/ .*n)0 

Parsing herethis is awful. I'm still trying to cook up a solution with ;:, but it may not happen tonight.

Edit: Realized that my output is basically broken, although it works for the examples given and parallels...

Edit: Posting the shorter version I already had.

Edit: Fixed without too much pain...

Edit: Fixed a weird issue where the program was spread across multiple lines.

J, 146 132 134

n=:}:m=:|:".>{.`(<@}:@;@(1 2&{))`{:(`:0)"1;:;._2(1!:1)3 k=:3 :0 1|.')(',(,',',])&(0j2&":)/,n%.~,.{:m ) echo'parallel'"_`k@.(*|-/ .*n)0 

Parsing here is awful. I'm still trying to cook up a solution with ;:, but it may not happen tonight.

Edit: Realized that my output is basically broken, although it works for the examples given and parallels...

Edit: Posting the shorter version I already had.

Edit: Fixed without too much pain...

J, 146 132 134 124

echo'parallel'"_`(1|.')(',[:(,',',])&(0j2&":)/[:,,.@{:%.}:)@.([:*@|[:-/ .*}:)|:".>{.`(<@}:@;@(1 2&{))`{:(`:0)"1;:;._2(1!:1)3 

Parsing this is awful.

Edit: Realized that my output is basically broken, although it works for the examples given and parallels...

Edit: Posting the shorter version I already had.

Edit: Fixed without too much pain...

Edit: Fixed a weird issue where the program was spread across multiple lines.

deleted 16 characters in body
Source Link

J, 146 132 (Secretly breaks on certain answers)132 134

n=:}:m=:|:".>{.`(<@}:@;@(1 2&{))`{:(`:0)"1;:;._2(1!:1)3 k=:3 :0 1|.')(',~'(,',','4}4j2 5j2"])&(0j2&":)/,(n%.~,.{:m)%.n ) echo'parallel'"_`k@.(*|-/ .*n)0 

Parsing here is awful. I'm still trying to cook up a solution with ;:, but it may not happen tonight.

Edit: Realized that my output is basically broken, although it works for the examples given and parallels...

Edit: Posting the shorter version I already had. Probably not going to fix the output tonight

Edit: Fixed without too much pain...

J, 146 132 (Secretly breaks on certain answers)

n=:}:m=:|:".>{.`(<@}:@;@(1 2&{))`{:(`:0)"1;:;._2(1!:1)3 k=:3 :0 ')',~'(',','4}4j2 5j2":,(,.{:m)%.n ) echo'parallel'"_`k@.(*|-/ .*n)0 

Parsing here is awful. I'm still trying to cook up a solution with ;:, but it may not happen tonight.

Edit: Realized that my output is basically broken, although it works for the examples given and parallels...

Edit: Posting the shorter version I already had. Probably not going to fix the output tonight.

J, 146 132 134

n=:}:m=:|:".>{.`(<@}:@;@(1 2&{))`{:(`:0)"1;:;._2(1!:1)3 k=:3 :0 1|.')(',(,',',])&(0j2&":)/,n%.~,.{:m ) echo'parallel'"_`k@.(*|-/ .*n)0 

Parsing here is awful. I'm still trying to cook up a solution with ;:, but it may not happen tonight.

Edit: Realized that my output is basically broken, although it works for the examples given and parallels...

Edit: Posting the shorter version I already had.

Edit: Fixed without too much pain...

added 113 characters in body; added 149 characters in body
Source Link
Loading
Source Link
Loading