Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 605 characters in body
Source Link
Wheat Wizard
  • 102.8k
  • 23
  • 299
  • 697

Haskell, \$n= 10\$\$n = 8\$

No comments!

Takes input as a 1-D list

s a b= 
 a/=b
f =s<*> 
 reverse
esrever 
 >*<s= f
b=/a 
 =b a s

Try it online!

\$n= 10\$

Takes input as a 2-D matrix

r =reverse
s a b=a/=b
f =s<*>r
c =concat
g = f<$>c
c>$<f = g
tacnoc= c
r>*<s= f
b=/a=b a s
esrever= r

Try it online!

Thanks to potato44 for all their help in chat. And Lynn for golfing off a row.

Explanation

The general idea here is a simple one, we concatconcat the list and compare it to it's reverse. However since we want to be centrosymmetric we have to tread carefully. First we write the code as we would normally:

g=((==)<*>reverse).concat

Now in order for our reverse lines to also be valid Haskell we need the left hand side of our equations to look like a function definition tacnoc.)esrever>*<)==(( doesn't.

The first step to fixing this is disposing of parentheses.

s a b=a==b
f=s<*>reverse
g=f.concat

However we have some new problems now. Both . and == when reversed are the same, so our reversed lines attempt to redefine the operators (<*> reversed is >*< so we are fine on that front). . can be replaced with <$> since functions are functors. And we can replace == with /=, which negates our output, but that is still within the specs. Now we have

s a b=a/=b
f=s<*>reverse
g=f<$>concat

In order to trim down our line length we alias concat and reverse.

r=reverse
s a b=a/=b
f=s<*>r
c=concat
g=f<$>c

Now we just finish this by making everything centrosymmetric and square.

\$n = 8\$

If we decide to take input as aThe shorter 1-D list we don'tversion works in much the same way except since there is no need to concat saving uswe can save two rowslines by removing it.

s a b= 
 a/=b
f =s<*> 
 reverse
esrever 
 >*<s= f
b=/a 
 =b a s

Try it online!

Haskell, \$n= 10\$

No comments

r =reverse
s a b=a/=b
f =s<*>r
c =concat
g = f<$>c
c>$<f = g
tacnoc= c
r>*<s= f
b=/a=b a s
esrever= r

Try it online!

Thanks to potato44 for all their help in chat. And Lynn for golfing off a row.

Explanation

The general idea here is a simple one, we concat the list and compare it to it's reverse. However since we want to be centrosymmetric we have to tread carefully. First we write the code as we would normally:

g=((==)<*>reverse).concat

Now in order for our reverse lines to also be valid Haskell we need the left hand side of our equations to look like a function definition tacnoc.)esrever>*<)==(( doesn't.

The first step to fixing this is disposing of parentheses.

s a b=a==b
f=s<*>reverse
g=f.concat

However we have some new problems now. Both . and == when reversed are the same, so our reversed lines attempt to redefine the operators (<*> reversed is >*< so we are fine on that front). . can be replaced with <$> since functions are functors. And we can replace == with /=, which negates our output, but that is still within the specs. Now we have

s a b=a/=b
f=s<*>reverse
g=f<$>concat

In order to trim down our line length we alias concat and reverse.

r=reverse
s a b=a/=b
f=s<*>r
c=concat
g=f<$>c

Now we just finish this by making everything centrosymmetric and square.

\$n = 8\$

If we decide to take input as a 1-D list we don't need to concat saving us two rows.

s a b= 
 a/=b
f =s<*> 
 reverse
esrever 
 >*<s= f
b=/a 
 =b a s

Try it online!

Haskell, \$n = 8\$

No comments!

Takes input as a 1-D list

s a b= 
 a/=b
f =s<*> 
 reverse
esrever 
 >*<s= f
b=/a 
 =b a s

Try it online!

\$n= 10\$

Takes input as a 2-D matrix

r =reverse
s a b=a/=b
f =s<*>r
c =concat
g = f<$>c
c>$<f = g
tacnoc= c
r>*<s= f
b=/a=b a s
esrever= r

Try it online!

Thanks to potato44 for all their help in chat. And Lynn for golfing off a row.

Explanation

The general idea here is a simple one, we concat the list and compare it to it's reverse. However since we want to be centrosymmetric we have to tread carefully. First we write the code as we would normally:

g=((==)<*>reverse).concat

Now in order for our reverse lines to also be valid Haskell we need the left hand side of our equations to look like a function definition tacnoc.)esrever>*<)==(( doesn't.

The first step to fixing this is disposing of parentheses.

s a b=a==b
f=s<*>reverse
g=f.concat

However we have some new problems now. Both . and == when reversed are the same, so our reversed lines attempt to redefine the operators (<*> reversed is >*< so we are fine on that front). . can be replaced with <$> since functions are functors. And we can replace == with /=, which negates our output, but that is still within the specs. Now we have

s a b=a/=b
f=s<*>reverse
g=f<$>concat

In order to trim down our line length we alias concat and reverse.

r=reverse
s a b=a/=b
f=s<*>r
c=concat
g=f<$>c

Now we just finish this by making everything centrosymmetric and square.

The shorter 1-D version works in much the same way except since there is no need to concat we can save two lines by removing it.

added 605 characters in body
Source Link
Wheat Wizard
  • 102.8k
  • 23
  • 299
  • 697

Haskell, \$n= 10\$

No comments

r =reverse
s a b=a/=b
f =s<*>r
c =concat
g = f<$>c
c>$<f = g
tacnoc= c
r>*<s= f
b=/a=b a s
esrever= r

Try it online!

Thanks to potato44 for all their help in chat. And Lynn for golfing off a row.

Explanation

The general idea here is a simple one, we concat the list and compare it to it's reverse. However since we want to be centrosymmetric we have to tread carefully. First we write the code as we would normally:

g=((==)<*>reverse).concat

Now in order for our reverse lines to also be valid Haskell we need the left hand side of our equations to look like a function definition tacnoc.)esrever>*<)==(( doesn't.

The first step to fixing this is disposing of parentheses.

s a b=a==b
f=s<*>reverse
g=f.concat

However we have some new problems now. Both . and == when reversed are the same, so our reversed lines attempt to redefine the operators (<*> reversed is >*< so we are fine on that front). . can be replaced with <$> since functions are functors. And we can replace == with /=, which negates our output, but that is still within the specs. Now we have

s a b=a/=b
f=s<*>reverse
g=f<$>concat

In order to trim down our line length we alias concat and reverse.

r=reverse
s a b=a/=b
f=s<*>r
c=concat
g=f<$>c

Now we just finish this by making everything centrosymmetric and square.

\$n = 8\$

If we decide to take input as a 1-D list we don't need to concat saving us two rows.

s a b= 
 a/=b
f =s<*> 
 reverse
esrever 
 >*<s= f
b=/a 
 =b a s

Try it online!

Haskell, \$n= 10\$

No comments

r =reverse
s a b=a/=b
f =s<*>r
c =concat
g = f<$>c
c>$<f = g
tacnoc= c
r>*<s= f
b=/a=b a s
esrever= r

Try it online!

Thanks to potato44 for all their help in chat. And Lynn for golfing off a row.

Explanation

The general idea here is a simple one, we concat the list and compare it to it's reverse. However since we want to be centrosymmetric we have to tread carefully. First we write the code as we would normally:

g=((==)<*>reverse).concat

Now in order for our reverse lines to also be valid Haskell we need the left hand side of our equations to look like a function definition tacnoc.)esrever>*<)==(( doesn't.

The first step to fixing this is disposing of parentheses.

s a b=a==b
f=s<*>reverse
g=f.concat

However we have some new problems now. Both . and == when reversed are the same, so our reversed lines attempt to redefine the operators (<*> reversed is >*< so we are fine on that front). . can be replaced with <$> since functions are functors. And we can replace == with /=, which negates our output, but that is still within the specs. Now we have

s a b=a/=b
f=s<*>reverse
g=f<$>concat

In order to trim down our line length we alias concat and reverse.

r=reverse
s a b=a/=b
f=s<*>r
c=concat
g=f<$>c

Now we just finish this by making everything centrosymmetric and square.

Haskell, \$n= 10\$

No comments

r =reverse
s a b=a/=b
f =s<*>r
c =concat
g = f<$>c
c>$<f = g
tacnoc= c
r>*<s= f
b=/a=b a s
esrever= r

Try it online!

Thanks to potato44 for all their help in chat. And Lynn for golfing off a row.

Explanation

The general idea here is a simple one, we concat the list and compare it to it's reverse. However since we want to be centrosymmetric we have to tread carefully. First we write the code as we would normally:

g=((==)<*>reverse).concat

Now in order for our reverse lines to also be valid Haskell we need the left hand side of our equations to look like a function definition tacnoc.)esrever>*<)==(( doesn't.

The first step to fixing this is disposing of parentheses.

s a b=a==b
f=s<*>reverse
g=f.concat

However we have some new problems now. Both . and == when reversed are the same, so our reversed lines attempt to redefine the operators (<*> reversed is >*< so we are fine on that front). . can be replaced with <$> since functions are functors. And we can replace == with /=, which negates our output, but that is still within the specs. Now we have

s a b=a/=b
f=s<*>reverse
g=f<$>concat

In order to trim down our line length we alias concat and reverse.

r=reverse
s a b=a/=b
f=s<*>r
c=concat
g=f<$>c

Now we just finish this by making everything centrosymmetric and square.

\$n = 8\$

If we decide to take input as a 1-D list we don't need to concat saving us two rows.

s a b= 
 a/=b
f =s<*> 
 reverse
esrever 
 >*<s= f
b=/a 
 =b a s

Try it online!

edited body
Source Link
Wheat Wizard
  • 102.8k
  • 23
  • 299
  • 697

Haskell, 109 bytes\$n= 10\$

No comments

r =reverse
s a b=a/=b
f =s<*>r
c =concat
g = f<$>c
c>$<f = g
tacnoc= c
r>*<s= f
b=/a=b a s
esrever= r

Try it online!

Thanks to potato44 for all their help in chat. And Lynn for golfing off a row.

Explanation

The general idea here is a simple one, we concat the list and compare it to it's reverse. However since we want to be centrosymmetric we have to tread carefully. First we write the code as we would normally:

g=((==)<*>reverse).concat

Now in order for our reverse lines to also be valid Haskell we need the left hand side of our equations to look like a function definition tacnoc.)esrever>*<)==(( doesn't.

The first step to fixing this is disposing of parentheses.

s a b=a==b
f=s<*>reverse
g=f.concat

However we have some new problems now. Both . and == when reversed are the same, so our reversed lines attempt to redefine the operators (<*> reversed is >*< so we are fine on that front). . can be replaced with <$> since functions are functors. And we can replace == with /=, which negates our output, but that is still within the specs. Now we have

s a b=a/=b
f=s<*>reverse
g=f<$>concat

In order to trim down our line length we alias concat and reverse.

r=reverse
s a b=a/=b
f=s<*>r
c=concat
g=f<$>c

Now we just finish this by making everything centrosymmetric and square.

Haskell, 109 bytes

No comments

r =reverse
s a b=a/=b
f =s<*>r
c =concat
g = f<$>c
c>$<f = g
tacnoc= c
r>*<s= f
b=/a=b a s
esrever= r

Try it online!

Thanks to potato44 for all their help in chat. And Lynn for golfing off a row.

Explanation

The general idea here is a simple one, we concat the list and compare it to it's reverse. However since we want to be centrosymmetric we have to tread carefully. First we write the code as we would normally:

g=((==)<*>reverse).concat

Now in order for our reverse lines to also be valid Haskell we need the left hand side of our equations to look like a function definition tacnoc.)esrever>*<)==(( doesn't.

The first step to fixing this is disposing of parentheses.

s a b=a==b
f=s<*>reverse
g=f.concat

However we have some new problems now. Both . and == when reversed are the same, so our reversed lines attempt to redefine the operators (<*> reversed is >*< so we are fine on that front). . can be replaced with <$> since functions are functors. And we can replace == with /=, which negates our output, but that is still within the specs. Now we have

s a b=a/=b
f=s<*>reverse
g=f<$>concat

In order to trim down our line length we alias concat and reverse.

r=reverse
s a b=a/=b
f=s<*>r
c=concat
g=f<$>c

Now we just finish this by making everything centrosymmetric and square.

Haskell, \$n= 10\$

No comments

r =reverse
s a b=a/=b
f =s<*>r
c =concat
g = f<$>c
c>$<f = g
tacnoc= c
r>*<s= f
b=/a=b a s
esrever= r

Try it online!

Thanks to potato44 for all their help in chat. And Lynn for golfing off a row.

Explanation

The general idea here is a simple one, we concat the list and compare it to it's reverse. However since we want to be centrosymmetric we have to tread carefully. First we write the code as we would normally:

g=((==)<*>reverse).concat

Now in order for our reverse lines to also be valid Haskell we need the left hand side of our equations to look like a function definition tacnoc.)esrever>*<)==(( doesn't.

The first step to fixing this is disposing of parentheses.

s a b=a==b
f=s<*>reverse
g=f.concat

However we have some new problems now. Both . and == when reversed are the same, so our reversed lines attempt to redefine the operators (<*> reversed is >*< so we are fine on that front). . can be replaced with <$> since functions are functors. And we can replace == with /=, which negates our output, but that is still within the specs. Now we have

s a b=a/=b
f=s<*>reverse
g=f<$>concat

In order to trim down our line length we alias concat and reverse.

r=reverse
s a b=a/=b
f=s<*>r
c=concat
g=f<$>c

Now we just finish this by making everything centrosymmetric and square.

added 58 characters in body
Source Link
Wheat Wizard
  • 102.8k
  • 23
  • 299
  • 697
Loading
added 1305 characters in body
Source Link
Wheat Wizard
  • 102.8k
  • 23
  • 299
  • 697
Loading
Source Link
Wheat Wizard
  • 102.8k
  • 23
  • 299
  • 697
Loading

AltStyle によって変換されたページ (->オリジナル) /