[Golfing] Filter 08-26-2015, 09:45 PM
#1
Oh boy! More golfing challenges!
You'll be given a bunch of text for your program to process line-by-line, and said text will be full of words and randomly generated non-word characters.
With that text in a separate file, your code needs to go through it one line at a time, sorting out all the random crap and outputting the words, separated by spaces.
Good luck!
You'll be given a bunch of text for your program to process line-by-line, and said text will be full of words and randomly generated non-word characters.
With that text in a separate file, your code needs to go through it one line at a time, sorting out all the random crap and outputting the words, separated by spaces.
Spoiler: Input
Code:
[.;'/Hello,';`~world
(*^Oh'.>:$fuck>":}what?>)#happened>:?$%here
{">?Alrighty>:%&thenSpoiler: My solution
Ruby, as usual
129 bytes. I feel like I could've done better, but I got stumped trying to get any smaller.
129 bytes. I feel like I could've done better, but I got stumped trying to get any smaller.
Code:
File.open(ARGV[0]).each_line{|l|x=[];l.each_char{|c|/[A-z]/.match(c) ? x<<c : x[-1]==" "||x[-1]==nil ? nil : x<<" "};puts x.join}Spoiler: Output
Code:
Hello world
Oh fuck what happened here
Alrighty thenSpoiler: BIG tip
Regex (or Regexp) is your friend here.
Leaderboard
@0xDEAD10CC - 48B - J
@null - 53B - Bash
@null - 59B - Ruby
@Eclipse - 79B - Python
@Shebang - 102B - Python
@"Chitoge" - 129B - Ruby
@0xDEAD10CC - 48B - J
@null - 53B - Bash
@null - 59B - Ruby
@Eclipse - 79B - Python
@Shebang - 102B - Python
@"Chitoge" - 129B - Ruby
Good luck!
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.
don't have much in the first place, who feel the new currents and ride them the farthest.

















![[+]](https://sinister.li/images/modern/collapse_collapsed.png)




![[Image: CDUAq9d.png]](http://i.imgur.com/CDUAq9d.png)





You have to put the file in the same location as the script. I just tested, seems to work:
![[Image: rIQCTF6.png]](https://i.imgur.com/rIQCTF6.png)