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

60%
+1 −0
Challenges Expand a greyscale/colour hex code

Haskell + hgl, 32 24 bytes tlM$tk6<cy<fiI(rl2~<)eL3 Explanation tlM map a over the tail of the input ... fiI if ... el3 the length is 3 (rl2~<) repeat each letter in place twi...

posted 11h ago by WheatWizard‭  ·  edited 8h ago by trichoplax‭

Answer
#7: Post edited by user avatar trichoplax‭ · 2025-01-18T21:13:22Z (about 8 hours ago)
Typo
  • # Haskell + [hgl](https://www.gitlab.com/wheatwizard/haskell-golfing-library), ~~32~~ 24 bytes
  • ```
  • tlM$tk6<cy<fiI(rl2~<)eL3
  • ```
  • ## Explanation
  • * `tlM` map a over the tail of the input ...
  • * `fiI` if ...
  • * `el3` the length is 3
  • * `(rl2~<)` repeat each letter in place twice.
  • * `cy` cycle the list indefinitely
  • * `tk6` take the first 6 characters.
  • ## Reflection
  • hgl is supposed to be good a structural manipulations like this, so this answer feels a little too long. I think a big part of the issue is that it involves a lot of conditional behavior which is not so robust in hgl.
  • So I have the following suggestions:
  • * `fiI`, and its partner `lii`, should have infix variants. This wouldn't actually save any bytes here, but it's a good idea.
  • * Odd length (`od<l`) and even length (`ev<l`) should have shortcuts. This would have saved an impressive 3 bytes on an earlier version of this answer, but using the odd length shortcut on this answer would tie.
  • * There should be a flip of `cz`, and it should probably be two bytes. If this existed I could do the extremely weird:
  • ```
  • tlM$cZ W6<fiI(rl2~<)eL3
  • ```
  • This reshapes the string to the size of the built-in string `"aeiouy"` as a substitute for `tk6<cy`. It would save 1 byte.
  • # Haskell + [hgl](https://www.gitlab.com/wheatwizard/haskell-golfing-library), ~~32~~ 24 bytes
  • ```
  • tlM$tk6<cy<fiI(rl2~<)eL3
  • ```
  • ## Explanation
  • * `tlM` map a over the tail of the input ...
  • * `fiI` if ...
  • * `el3` the length is 3
  • * `(rl2~<)` repeat each letter in place twice.
  • * `cy` cycle the list indefinitely
  • * `tk6` take the first 6 characters.
  • ## Reflection
  • hgl is supposed to be good at structural manipulations like this, so this answer feels a little too long. I think a big part of the issue is that it involves a lot of conditional behavior which is not so robust in hgl.
  • So I have the following suggestions:
  • * `fiI`, and its partner `lii`, should have infix variants. This wouldn't actually save any bytes here, but it's a good idea.
  • * Odd length (`od<l`) and even length (`ev<l`) should have shortcuts. This would have saved an impressive 3 bytes on an earlier version of this answer, but using the odd length shortcut on this answer would tie.
  • * There should be a flip of `cz`, and it should probably be two bytes. If this existed I could do the extremely weird:
  • ```
  • tlM$cZ W6<fiI(rl2~<)eL3
  • ```
  • This reshapes the string to the size of the built-in string `"aeiouy"` as a substitute for `tk6<cy`. It would save 1 byte.
#6: Post edited by user avatar WheatWizard‭ · 2025-01-18T18:11:25Z (about 11 hours ago)
Another thought.
  • # Haskell + [hgl](https://www.gitlab.com/wheatwizard/haskell-golfing-library), ~~32~~ 24 bytes
  • ```
  • tlM$tk6<cy<fiI(rl2~<)eL3
  • ```
  • ## Explanation
  • * `tlM` map a over the tail of the input ...
  • * `fiI` if ...
  • * `el3` the length is 3
  • * `(rl2~<)` repeat each letter in place twice.
  • * `cy` cycle the list indefinitely
  • * `tk6` take the first 6 characters.
  • ## Reflection
  • hgl is supposed to be good a structural manipulations like this, so this answer feels a little too long. I think a big part of the issue is that it involves a lot of conditional behavior which is not so robust in hgl.
  • So I have the following suggestions:
  • * `fiI`, and its partner `lii`, should have infix variants. This wouldn't actually save any bytes here, but it's a good idea.
  • * Odd length (`od<l`) and even length (`ev<l`) should have shortcuts. This would have saved an impressive 3 bytes on an earlier version of this answer, but using the odd length shortcut on this answer would tie.
  • * There should be a flip of 'cz'. If this existed I could do the extremely weird:
  • ```
  • tlM$fcz W6<fiI(rl2~<)eL3
  • ```
  • This reshapes the string to the size of the built-in string `"aeiouy"` as a substitute for `tk6<cy`. It would still tie this answer however.
  • # Haskell + [hgl](https://www.gitlab.com/wheatwizard/haskell-golfing-library), ~~32~~ 24 bytes
  • ```
  • tlM$tk6<cy<fiI(rl2~<)eL3
  • ```
  • ## Explanation
  • * `tlM` map a over the tail of the input ...
  • * `fiI` if ...
  • * `el3` the length is 3
  • * `(rl2~<)` repeat each letter in place twice.
  • * `cy` cycle the list indefinitely
  • * `tk6` take the first 6 characters.
  • ## Reflection
  • hgl is supposed to be good a structural manipulations like this, so this answer feels a little too long. I think a big part of the issue is that it involves a lot of conditional behavior which is not so robust in hgl.
  • So I have the following suggestions:
  • * `fiI`, and its partner `lii`, should have infix variants. This wouldn't actually save any bytes here, but it's a good idea.
  • * Odd length (`od<l`) and even length (`ev<l`) should have shortcuts. This would have saved an impressive 3 bytes on an earlier version of this answer, but using the odd length shortcut on this answer would tie.
  • * There should be a flip of `cz`, and it should probably be two bytes. If this existed I could do the extremely weird:
  • ```
  • tlM$cZ W6<fiI(rl2~<)eL3
  • ```
  • This reshapes the string to the size of the built-in string `"aeiouy"` as a substitute for `tk6<cy`. It would save 1 byte.
#5: Post edited by user avatar WheatWizard‭ · 2025-01-18T18:08:27Z (about 11 hours ago)
Another thought.
  • # Haskell + [hgl](https://www.gitlab.com/wheatwizard/haskell-golfing-library), ~~32~~ 24 bytes
  • ```
  • tlM$tk6<cy<fiI(rl2~<)eL3
  • ```
  • ## Explanation
  • * `tlM` map a over the tail of the input ...
  • * `fiI` if ...
  • * `el3` the length is 3
  • * `(rl2~<)` repeat each letter in place twice.
  • * `cy` cycle the list indefinitely
  • * `tk6` take the first 6 characters.
  • ## Reflection
  • hgl is supposed to be good a structural manipulations like this, so this answer feels a little too long. I think a big part of the issue is that it involves a lot of conditional behavior which is not so robust in hgl.
  • So I have the following suggestions:
  • * `fiI`, and its partner `lii`, should have infix variants.
  • * Odd length (`od<l`) and even length (`ev<l`) should have shortcuts. This would have saved an impressive 3 bytes on an earlier version of this answer, but using the odd length shortcut on this answer would tie.
  • # Haskell + [hgl](https://www.gitlab.com/wheatwizard/haskell-golfing-library), ~~32~~ 24 bytes
  • ```
  • tlM$tk6<cy<fiI(rl2~<)eL3
  • ```
  • ## Explanation
  • * `tlM` map a over the tail of the input ...
  • * `fiI` if ...
  • * `el3` the length is 3
  • * `(rl2~<)` repeat each letter in place twice.
  • * `cy` cycle the list indefinitely
  • * `tk6` take the first 6 characters.
  • ## Reflection
  • hgl is supposed to be good a structural manipulations like this, so this answer feels a little too long. I think a big part of the issue is that it involves a lot of conditional behavior which is not so robust in hgl.
  • So I have the following suggestions:
  • * `fiI`, and its partner `lii`, should have infix variants. This wouldn't actually save any bytes here, but it's a good idea.
  • * Odd length (`od<l`) and even length (`ev<l`) should have shortcuts. This would have saved an impressive 3 bytes on an earlier version of this answer, but using the odd length shortcut on this answer would tie.
  • * There should be a flip of 'cz'. If this existed I could do the extremely weird:
  • ```
  • tlM$fcz W6<fiI(rl2~<)eL3
  • ```
  • This reshapes the string to the size of the built-in string `"aeiouy"` as a substitute for `tk6<cy`. It would still tie this answer however.
#4: Post edited by user avatar WheatWizard‭ · 2025-01-18T17:51:42Z (about 11 hours ago)
Golf.
  • # Haskell + [hgl](https://www.gitlab.com/wheatwizard/haskell-golfing-library), ~~32~~ 24 bytes
  • ```
  • tlM$tk6<cy<fiI(rl2~<)eL3
  • ```
  • ## Explanation
  • * `tlM` map a over the tail of the input ...
  • * `fiI` if ...
  • * `el3` the length is 3
  • * `(rl2~<)` repeat each letter in place twice.
  • * `cy` cycle the list indefinitely
  • * `tk6` take the first 6 characters.
  • ## Reflection
  • hgl is supposed to be good a structural manipulations like this, so this answer is way too long. I think a big part of the issue is that it involves a lot of conditional behavior which is not so robust in hgl.
  • So I have the following suggestions:
  • * `fiI`, and its partner `lii`, should have infix variants.
  • * Odd length (`od<l`) and even length (`ev<l`) should have shortcuts. This would save an impressive 3 bytes on this answer.
  • # Haskell + [hgl](https://www.gitlab.com/wheatwizard/haskell-golfing-library), ~~32~~ 24 bytes
  • ```
  • tlM$tk6<cy<fiI(rl2~<)eL3
  • ```
  • ## Explanation
  • * `tlM` map a over the tail of the input ...
  • * `fiI` if ...
  • * `el3` the length is 3
  • * `(rl2~<)` repeat each letter in place twice.
  • * `cy` cycle the list indefinitely
  • * `tk6` take the first 6 characters.
  • ## Reflection
  • hgl is supposed to be good a structural manipulations like this, so this answer feels a little too long. I think a big part of the issue is that it involves a lot of conditional behavior which is not so robust in hgl.
  • So I have the following suggestions:
  • * `fiI`, and its partner `lii`, should have infix variants.
  • * Odd length (`od<l`) and even length (`ev<l`) should have shortcuts. This would have saved an impressive 3 bytes on an earlier version of this answer, but using the odd length shortcut on this answer would tie.
#3: Post edited by user avatar WheatWizard‭ · 2025-01-18T17:49:56Z (about 11 hours ago)
Golf.
  • # Haskell + [hgl](https://www.gitlab.com/wheatwizard/haskell-golfing-library), 32 bytes
  • ```
  • tlM$fiI rt3 eL2<fiI(rl2~<)(od<l)
  • ```
  • ## Explanation
  • * `tlM` map a over the tail of the input ...
  • * `fiI` if ...
  • * `l` the length ...
  • * `od` is odd ..
  • * `(rl2~<)` repeat each letter in place twice.
  • * `fiI` if ...
  • * `eL2` the length is 2 ...
  • * `rt3` repeat the entire thing thrice.
  • Odd length occurs only when the input is size 1 or 3, at which point doubling in place gets us to an even length.
  • ## Reflection
  • hgl is supposed to be good a structural manipulations like this, so this answer is way too long. I think a big part of the issue is that it involves a lot of conditional behavior which is not so robust in hgl.
  • So I have the following suggestions:
  • * `fiI`, and its partner `lii`, should have infix variants.
  • * Odd length (`od<l`) and even length (`ev<l`) should have shortcuts. This would save an impressive 3 bytes on this answer.
  • # Haskell + [hgl](https://www.gitlab.com/wheatwizard/haskell-golfing-library), ~~32~~ 24 bytes
  • ```
  • tlM$tk6<cy<fiI(rl2~<)eL3
  • ```
  • ## Explanation
  • * `tlM` map a over the tail of the input ...
  • * `fiI` if ...
  • * `el3` the length is 3
  • * `(rl2~<)` repeat each letter in place twice.
  • * `cy` cycle the list indefinitely
  • * `tk6` take the first 6 characters.
  • ## Reflection
  • hgl is supposed to be good a structural manipulations like this, so this answer is way too long. I think a big part of the issue is that it involves a lot of conditional behavior which is not so robust in hgl.
  • So I have the following suggestions:
  • * `fiI`, and its partner `lii`, should have infix variants.
  • * Odd length (`od<l`) and even length (`ev<l`) should have shortcuts. This would save an impressive 3 bytes on this answer.
#2: Post edited by user avatar WheatWizard‭ · 2025-01-18T17:46:19Z (about 11 hours ago)
Found the name of the tail map function.
  • # Haskell + [hgl](https://www.gitlab.com/wheatwizard/haskell-golfing-library), 37 bytes
  • ```
  • mp"#"<fiI rt3 eL2<fiI(rl2~<)(od<l)<tl
  • ```
  • ## Explanation
  • * `tl` remove the `#`
  • * `fiI` if ...
  • * `l` the length ...
  • * `od` is odd ..
  • * `(rl2~<)` repeat each letter in place twice.
  • * `fiI` if ...
  • * `eL2` the length is 2 ...
  • * `rt3` repeat the entire thing thrice.
  • * `mp"#"` add a hash to the front.
  • Odd length occurs only when the input is size 1 or 3, at which point doubling in place gets us to an even length.
  • ## Reflection
  • hgl is supposed to be good a structural manipulations like this, so this answer is way too long. I think a big part of the issue is that it involves a lot of conditional behavior which is not so robust in hgl.
  • So I have the following suggestions:
  • * `fiI`, and its partner `lii`, should have infix variants.
  • * Odd length (`od<l`) and even length (`ev<l`) should have shortcuts. This would save an impressive 3 bytes on this answer.
  • * I thought there was a function to map over the tail of a list. This should be implemented.
  • # Haskell + [hgl](https://www.gitlab.com/wheatwizard/haskell-golfing-library), 32 bytes
  • ```
  • tlM$fiI rt3 eL2<fiI(rl2~<)(od<l)
  • ```
  • ## Explanation
  • * `tlM` map a over the tail of the input ...
  • * `fiI` if ...
  • * `l` the length ...
  • * `od` is odd ..
  • * `(rl2~<)` repeat each letter in place twice.
  • * `fiI` if ...
  • * `eL2` the length is 2 ...
  • * `rt3` repeat the entire thing thrice.
  • Odd length occurs only when the input is size 1 or 3, at which point doubling in place gets us to an even length.
  • ## Reflection
  • hgl is supposed to be good a structural manipulations like this, so this answer is way too long. I think a big part of the issue is that it involves a lot of conditional behavior which is not so robust in hgl.
  • So I have the following suggestions:
  • * `fiI`, and its partner `lii`, should have infix variants.
  • * Odd length (`od<l`) and even length (`ev<l`) should have shortcuts. This would save an impressive 3 bytes on this answer.
#1: Initial revision by user avatar WheatWizard‭ · 2025-01-18T17:43:32Z (about 11 hours ago)
# Haskell + [hgl](https://www.gitlab.com/wheatwizard/haskell-golfing-library), 37 bytes

```
mp"#"<fiI rt3 eL2<fiI(rl2~<)(od<l)<tl
```

## Explanation

* `tl` remove the `#`
* `fiI` if ...
* `l` the length ...
* `od` is odd ..
* `(rl2~<)` repeat each letter in place twice.
* `fiI` if ...
* `eL2` the length is 2 ...
* `rt3` repeat the entire thing thrice.
* `mp"#"` add a hash to the front.

Odd length occurs only when the input is size 1 or 3, at which point doubling in place gets us to an even length.

## Reflection

hgl is supposed to be good a structural manipulations like this, so this answer is way too long. I think a big part of the issue is that it involves a lot of conditional behavior which is not so robust in hgl.

So I have the following suggestions:

* `fiI`, and its partner `lii`, should have infix variants.
* Odd length (`od<l`) and even length (`ev<l`) should have shortcuts. This would save an impressive 3 bytes on this answer.
* I thought there was a function to map over the tail of a list. This should be implemented.