Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1(UI#v´yXiн?}Tи`žMvykˆ}¯ʒ2+≠}WD.ïiŠŠs>£?}X>U}"-"?UR2£R?
- I'll go over the improvements step-by-step, since it's mostly so you can learn from it. :)
- -1 has a builtin constant: ® (see this tip for some others: https://codegolf.stackexchange.com/a/96417/52210), so that's -1 byte:
- ®UI#v´yXiн?}Tи`žMvykˆ}¯ʒ2+≠}WD.ïiŠŠs>£?}X>U}"-"?UR2£R?
- I noticed you're using the `X` as a counter to indicate when you're at the third (X=1) iteration. Instead, I would suggest to use the actual counter variable `¾`, since it's easier to increment it by 1 with `¼`. The counter variable is 0 by default, so you'd have to check if it's equal to 2 if you'd want to check whether you're at the third iteration:
- I#v´y¾<iн?}Tи`žMvykˆ}¯ʒ2+≠}WD.ïiŠŠs>£?}¼}"-"?UR2£R?
- Also note how I've used `¾<i` here to check if the counter variable is 2, instead of `¾2Qi`, since only 1 is truthy in 05AB1E.
- Next, we can remove the leading `I`, since input is implicitly:
- #v´y¾<iн?}Tи`žMvykˆ}¯ʒ2+≠}WD.ïiŠŠs>£?}¼}"-"?UR2£R?
- Umm.. At this point I'm not 100% understand what your approach is with the global array, filter, etc. So instead some other random golfing tips near the end:
- There are single-byte builtins for strings of length 1, 2, or 3, being '„… respectively, so the `"-"` can be `'-` for another -1.
- The `U` you're using here is just to clear it from the stack it seem, so instead you could use `\`, which does the same thing, but is a bit clearer of what you are actually doing. :)
- And the `R2£R` can be `2.£` instead.
- So it's now at 48 bytes:
- #v´y¾<iн?}Tи`žMvykˆ}¯ʒ2+≠}WD.ïiŠŠs>£?}¼}'-?\2.£?
- And I'm also pretty sure the challenge allowed a flexible input, so you don't need the `#` if you already take the input as a list of strings.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement