Advertisement
Guest User

Untitled

a guest
Mar 18th, 2020
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. 1(UI#v´yXiн?}Tи`žMvykˆ}¯ʒ2+≠}WD.ïiŠŠs>£?}X>U}"-"?UR2£R?
  2.  
  3. I'll go over the improvements step-by-step, since it's mostly so you can learn from it. :)
  4.  
  5. -1 has a builtin constant: ® (see this tip for some others: https://codegolf.stackexchange.com/a/96417/52210), so that's -1 byte:
  6. ®UI#v´yXiн?}Tи`žMvykˆ}¯ʒ2+≠}WD.ïiŠŠs>£?}X>U}"-"?UR2£R?
  7.  
  8. 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:
  9. I#v´y¾<iн?}Tи`žMvykˆ}¯ʒ2+≠}WD.ïiŠŠs>£?}¼}"-"?UR2£R?
  10. 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.
  11.  
  12. Next, we can remove the leading `I`, since input is implicitly:
  13. #v´y¾<iн?}Tи`žMvykˆ}¯ʒ2+≠}WD.ïiŠŠs>£?}¼}"-"?UR2£R?
  14.  
  15. 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:
  16.  
  17. There are single-byte builtins for strings of length 1, 2, or 3, being '„… respectively, so the `"-"` can be `'-` for another -1.
  18.  
  19. 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. :)
  20.  
  21. And the `R2£R` can be `2.£` instead.
  22.  
  23. So it's now at 48 bytes:
  24. #v´y¾<iн?}Tи`žMvykˆ}¯ʒ2+≠}WD.ïiŠŠs>£?}¼}'-?\2.£?
  25.  
  26. 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