Created
March 28, 2011 19:04
-
-
Save brianm/891050 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
t = <<-EOT | |
#!/usr/bin/env ruby | |
if 1+1 == 2 | |
puts "hello world" | |
end | |
EOT | |
# what one liner replaces '.gsub /^\s*/, "' to make this output "win" | |
s = <<-EOB.gsub /^\s*/, "" | |
#!/usr/bin/env ruby | |
if 1+1 == 2 | |
puts "hello world" | |
end | |
EOB | |
if t == s | |
puts "win" | |
else | |
puts "lose" | |
end |
+1 for martint's last version
what a weird problem though :)
Impressive!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And the simplest one I could come up with... It takes advantage of the side-effects of matching regexes (matched groups go into $1, $2, ...):