Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

66%
+2 −0
Challenges Connect the corners without 4 in a row

Haskell + hgl, 134 bytes k=cy"X.XX" x#1=[4,0,9,9]!x 2#y=8 3#y=[8,9,4,4]!y x#3=[0,3]!x _#_=0 x?y|(n,j)<-fvD 4$x%4#(y%4)=tk y$dr j$tk x<dr n<cy[dr2 k,k,cy".X",k] Attempt This Onlin...

posted 1y ago by WheatWizard‭  ·  edited 1y ago by WheatWizard‭

Answer
#4: Post edited by user avatar WheatWizard‭ · 2023-06-19T16:59:34Z (over 1 year ago)
Fixed alignment
  • # [Haskell](https://www.haskell.org) + [hgl](https://gitlab.com/wheatwizard/haskell-golfing-library), 136 bytes
  • ```haskell
  • k=cy"X.XX"
  • 2#y=[8,9]!y
  • 3#y=[8,9,4,4]!y
  • x#1=[4,0]!x
  • x#3=[0,3]!x
  • _#_=0
  • x?y|(n,j)<-fvD 4$x%4#(y%4)=tk y$dr j$tk x<dr n<cy[dr2 k,k,cy".X",k]
  • ````
  • [Attempt This Online!](https://ato.pxeger.com/run?1=lZHPaoNAEMbpdZ9i_BNYy0asbiAJbnMpgd4CvQgiIlGpWTWp1eJCL731HXrxUvpM6dN0g54sNA0s7Dczv4_5YD6-HqNnnuR5d1Sy4rCvanhqojxLsySGTZXkTZygYbD5bOp0Oj--c7YVqmd6nopsTTB_ThaBIpAzaEIJPdWtdsN8SqxAaaV2mG8R56RDLWQWalfiFZdkZ7jT9OUOqN5OqIbFhBqs5iD0uIKdLlXrSlW6W-HHlQ2ccCKXm55KeNDn-b56SxleGaiIspLFewRQhHB4AB1SsC35ZEeWqor6EcbXt33DAHdgXcliG5ZLuC9rwwDfNs1FcIZ3LuTpL_4vw3ocaXZuxXoc6n8OerFjNnb0l-i6_v8B)
  • I first set up a pretty dense background pattern which doesn't break any rules:
  • ```
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • ```
  • All we have to do is make sure the pattern is aligned so there's always a path. I wish I had some clever way of doing this, but I just use a bunch of magic numbers I calculated by trial and error.
  • Since the pattern repeats with period 4, I just tried every pair of numbers on the range 1-4 and found a shifting that lined up. I encoded these in base 4 and that's what the program uses.
  • There might be an opportunity to optimize this by finding better numbers.
  • # [Haskell](https://www.haskell.org) + [hgl](https://gitlab.com/wheatwizard/haskell-golfing-library), 134 bytes
  • ```haskell
  • k=cy"X.XX"
  • x#1=[4,0,9,9]!x
  • 2#y=8
  • 3#y=[8,9,4,4]!y
  • x#3=[0,3]!x
  • _#_=0
  • x?y|(n,j)<-fvD 4$x%4#(y%4)=tk y$dr j$tk x<dr n<cy[dr2 k,k,cy".X",k]
  • ````
  • [Attempt This Online!](https://ato.pxeger.com/run?1=lZHNaoNAFIXpdp7i-hOYKROxOgENTrMpge4C3QgiIlGp8Sep1eJAN930JbrJJvSZ0qfpFLOy0DQwzNx77ne4B-bj8zF-LtKy3B-VvNptmxaeurjMszxNYNWkZZek6DRYHbo2mzrH94Kvheobvq-iXrvhAaMmdakbKj2yNMEdZMs7cKTGKAsVISmbBya1f4hIi7iJ-oV4xTXdEG-avdwB0_sJ07CYMMLbAoSeNLDRZdV7sqq9tQiSxoKCFlSuNnyVFuGQ5uvqLeN4QVAV5zVPtgigimD3ADpkYJnySEW2qoqGEcbXt4NAwDuxnmSxBfM53NctIRBYhuGGZ3j7Qp794v8yLMeRZudWLMeh_udgFztmY8fwE_v98H4D)
  • I first set up a pretty dense background pattern which doesn't break any rules:
  • ```
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • ```
  • All we have to do is make sure the pattern is aligned so there's always a path. I wish I had some clever way of doing this, but I just use a bunch of magic numbers I calculated by trial and error.
  • Since the pattern repeats with period 4, I just tried every pair of numbers on the range 1-4 and found a shifting that lined up. I encoded these in base 4 and that's what the program uses.
  • There might be an opportunity to optimize this by finding better numbers.
#3: Post edited by user avatar WheatWizard‭ · 2023-06-19T14:04:14Z (over 1 year ago)
Improved score.
  • # [Haskell](https://www.haskell.org) + [hgl](https://gitlab.com/wheatwizard/haskell-golfing-library), 142 bytes
  • ```haskell
  • k=cy"X.XX"
  • 3#y=[8,9,4,4]!y
  • 2#y=[8,9,8,8]!y
  • x#1=[4,0]!x
  • x#3=[0,3]!x
  • _#_=0
  • f x y|(n,j)<-fvD 4$x%4#(y%4)=tk y$dr j$tk x<dr n<cy[dr2 k,k,cy".X",k]
  • ````
  • [Attempt This Online!](https://ato.pxeger.com/run?1=lZHNaoNAFIXpdp7i-hMYy0SsTsAEp6sS6C7QjSAiEpWaUZNaLQ7tM_QFunFT8kzp03SC6cZC08DAnHPvd5gD87F_jJ95WhT9QcnL3bZu4KmNizzL0wRWdVq0SYpOi9Vn22RT9_DO2Vqovun7KnI0wQKXzAklNFQEsn-8S9yj77QbFlBihUontcMCizhHHWkRs1AGHYg3XJGN4U2zlzugejehGhYTarCGg9CTGja6VJ0nVeWtRZDUNnDCiaxg-irh4dDq6-q1jPOKJVsEUEawewAdMrAteeREWlVFwwrj69thYIB3Yj3JYhsWC7ivGsOAwDbNeXiGdy7k6S_-r8ByXGl27onluNT_EvTixGycGP6g74f7Gw)
  • I first set up a pretty dense background pattern which doesn't break any rules:
  • ```
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • ```
  • All we have to do is make sure the pattern is aligned so there's always a path. I wish I had some clever way of doing this, but I just use a bunch of magic numbers I calculated by trial and error.
  • Since the pattern repeats with period 4, I just tried every pair of numbers on the range 1-4 and found a shifting that lined up. I encoded these in base 4 and that's what the program uses.
  • There might be an opportunity to optimize this by finding better numbers.
  • # [Haskell](https://www.haskell.org) + [hgl](https://gitlab.com/wheatwizard/haskell-golfing-library), 136 bytes
  • ```haskell
  • k=cy"X.XX"
  • 2#y=[8,9]!y
  • 3#y=[8,9,4,4]!y
  • x#1=[4,0]!x
  • x#3=[0,3]!x
  • _#_=0
  • x?y|(n,j)<-fvD 4$x%4#(y%4)=tk y$dr j$tk x<dr n<cy[dr2 k,k,cy".X",k]
  • ````
  • [Attempt This Online!](https://ato.pxeger.com/run?1=lZHPaoNAEMbpdZ9i_BNYy0asbiAJbnMpgd4CvQgiIlGpWTWp1eJCL731HXrxUvpM6dN0g54sNA0s7Dczv4_5YD6-HqNnnuR5d1Sy4rCvanhqojxLsySGTZXkTZygYbD5bOp0Oj--c7YVqmd6nopsTTB_ThaBIpAzaEIJPdWtdsN8SqxAaaV2mG8R56RDLWQWalfiFZdkZ7jT9OUOqN5OqIbFhBqs5iD0uIKdLlXrSlW6W-HHlQ2ccCKXm55KeNDn-b56SxleGaiIspLFewRQhHB4AB1SsC35ZEeWqor6EcbXt33DAHdgXcliG5ZLuC9rwwDfNs1FcIZ3LuTpL_4vw3ocaXZuxXoc6n8OerFjNnb0l-i6_v8B)
  • I first set up a pretty dense background pattern which doesn't break any rules:
  • ```
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • ```
  • All we have to do is make sure the pattern is aligned so there's always a path. I wish I had some clever way of doing this, but I just use a bunch of magic numbers I calculated by trial and error.
  • Since the pattern repeats with period 4, I just tried every pair of numbers on the range 1-4 and found a shifting that lined up. I encoded these in base 4 and that's what the program uses.
  • There might be an opportunity to optimize this by finding better numbers.
#2: Post edited by user avatar WheatWizard‭ · 2023-06-19T04:41:14Z (over 1 year ago)
  • # [Haskell](https://www.haskell.org) + [hgl](https://gitlab.com/wheatwizard/haskell-golfing-library), 144 bytes
  • ```haskell
  • k=cy"X.XX"
  • 3#y=[8,9,4,4]!y
  • 2#y=[8,9,8,8]!y
  • x#1=[4,0]!x
  • x#3=[0,3]!x
  • _#_=0
  • f x y|(n,j)<-fvD 4$x%4#(y%4)=tk y$dr j$tk x<dr n<cy[dr2 k,k,cy"...X",k]
  • ````
  • [Attempt This Online!](https://ato.pxeger.com/run?1=lZDPaoNAEMbp1acY_wTWslmsbsAEt6cS6C3QiyBiJbrUrJrUanGhD9F7L15Knyl9miq2FwtNc5rfzHwf8zFvHw_xk0jzvDuqWXHYVzU8NnGe8SxNYFOleZOkyvdi897UfO4eXwXbSs0nvq8pji5Z4OIlppiGqlTsn97F7tC3-hULKLZCte3ZYYGFnYEjPWKWwqEF-YJKvDO9OX--AWq0M6ojOaMmqwVII6lgZ_TUej2V3lYGSWWDwAL3EQghvoZFOOb6vLgv4qxkyV4BKCJA6PIaDnegaSZ4w6BnDzggG1YruC1r04TAJmQZntA7Z-rpL_1fhvU00uLUifU01P8c9GzHYuoYH911Y_0C)
  • I first set up a pretty dense background pattern which doesn't break any rules:
  • ```
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • ...X...X...X...X...X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • ...X...X...X...X...X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • ...X...X...X...X...X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • ...X...X...X...X...X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • ...X...X...X...X...X
  • X.XXX.XXX.XXX.XXX.XX
  • ```
  • All we have to do is make sure the pattern is aligned so there's always a path. I wish I had some clever way of doing this, but I just use a bunch of magic numbers I calculated by trial and error.
  • Since the pattern repeats with period 4, I just tried every pair of numbers on the range 1-4 and found a shifting that lined up. I encoded these in base 4 and that's what the program uses.
  • There might be an opportunity to optimize this by finding better numbers.
  • # [Haskell](https://www.haskell.org) + [hgl](https://gitlab.com/wheatwizard/haskell-golfing-library), 142 bytes
  • ```haskell
  • k=cy"X.XX"
  • 3#y=[8,9,4,4]!y
  • 2#y=[8,9,8,8]!y
  • x#1=[4,0]!x
  • x#3=[0,3]!x
  • _#_=0
  • f x y|(n,j)<-fvD 4$x%4#(y%4)=tk y$dr j$tk x<dr n<cy[dr2 k,k,cy".X",k]
  • ````
  • [Attempt This Online!](https://ato.pxeger.com/run?1=lZHNaoNAFIXpdp7i-hMYy0SsTsAEp6sS6C7QjSAiEpWaUZNaLQ7tM_QFunFT8kzp03SC6cZC08DAnHPvd5gD87F_jJ95WhT9QcnL3bZu4KmNizzL0wRWdVq0SYpOi9Vn22RT9_DO2Vqovun7KnI0wQKXzAklNFQEsn-8S9yj77QbFlBihUontcMCizhHHWkRs1AGHYg3XJGN4U2zlzugejehGhYTarCGg9CTGja6VJ0nVeWtRZDUNnDCiaxg-irh4dDq6-q1jPOKJVsEUEawewAdMrAteeREWlVFwwrj69thYIB3Yj3JYhsWC7ivGsOAwDbNeXiGdy7k6S_-r8ByXGl27onluNT_EvTixGycGP6g74f7Gw)
  • I first set up a pretty dense background pattern which doesn't break any rules:
  • ```
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • XXX.XXX.XXX.XXX.XXX.
  • X.XXX.XXX.XXX.XXX.XX
  • .X.X.X.X.X.X.X.X.X.X
  • X.XXX.XXX.XXX.XXX.XX
  • ```
  • All we have to do is make sure the pattern is aligned so there's always a path. I wish I had some clever way of doing this, but I just use a bunch of magic numbers I calculated by trial and error.
  • Since the pattern repeats with period 4, I just tried every pair of numbers on the range 1-4 and found a shifting that lined up. I encoded these in base 4 and that's what the program uses.
  • There might be an opportunity to optimize this by finding better numbers.
#1: Initial revision by user avatar WheatWizard‭ · 2023-06-19T04:39:10Z (over 1 year ago)
# [Haskell](https://www.haskell.org) + [hgl](https://gitlab.com/wheatwizard/haskell-golfing-library), 144 bytes

```haskell
k=cy"X.XX"
3#y=[8,9,4,4]!y
2#y=[8,9,8,8]!y
x#1=[4,0]!x
x#3=[0,3]!x
_#_=0
f x y|(n,j)<-fvD 4$x%4#(y%4)=tk y$dr j$tk x<dr n<cy[dr2 k,k,cy"...X",k]
````

[Attempt This Online!](https://ato.pxeger.com/run?1=lZDPaoNAEMbp1acY_wTWslmsbsAEt6cS6C3QiyBiJbrUrJrUanGhD9F7L15Knyl9miq2FwtNc5rfzHwf8zFvHw_xk0jzvDuqWXHYVzU8NnGe8SxNYFOleZOkyvdi897UfO4eXwXbSs0nvq8pji5Z4OIlppiGqlTsn97F7tC3-hULKLZCte3ZYYGFnYEjPWKWwqEF-YJKvDO9OX--AWq0M6ojOaMmqwVII6lgZ_TUej2V3lYGSWWDwAL3EQghvoZFOOb6vLgv4qxkyV4BKCJA6PIaDnegaSZ4w6BnDzggG1YruC1r04TAJmQZntA7Z-rpL_1fhvU00uLUifU01P8c9GzHYuoYH911Y_0C)

I first set up a pretty dense background pattern which doesn't break any rules:

```
XXX.XXX.XXX.XXX.XXX.
X.XXX.XXX.XXX.XXX.XX
...X...X...X...X...X
X.XXX.XXX.XXX.XXX.XX
XXX.XXX.XXX.XXX.XXX.
X.XXX.XXX.XXX.XXX.XX
...X...X...X...X...X
X.XXX.XXX.XXX.XXX.XX
XXX.XXX.XXX.XXX.XXX.
X.XXX.XXX.XXX.XXX.XX
...X...X...X...X...X
X.XXX.XXX.XXX.XXX.XX
XXX.XXX.XXX.XXX.XXX.
X.XXX.XXX.XXX.XXX.XX
...X...X...X...X...X
X.XXX.XXX.XXX.XXX.XX
XXX.XXX.XXX.XXX.XXX.
X.XXX.XXX.XXX.XXX.XX
...X...X...X...X...X
X.XXX.XXX.XXX.XXX.XX
```

All we have to do is make sure the pattern is aligned so there's always a path. I wish I had some clever way of doing this, but I just use a bunch of magic numbers I calculated by trial and error.

Since the pattern repeats with period 4, I just tried every pair of numbers on the range 1-4 and found a shifting that lined up. I encoded these in base 4 and that's what the program uses.

There might be an opportunity to optimize this by finding better numbers.