Skip to content

Instantly share code, notes, and snippets.

@hanachin
Last active May 19, 2019 04:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanachin/2983960d3ef180b6c929e3ac9730c9bb to your computer and use it in GitHub Desktop.
Save hanachin/2983960d3ef180b6c929e3ac9730c9bb to your computer and use it in GitHub Desktop.
Okinawa.rb Ruby Puzzles 2019/5/15 - #rubykaigi のRubyPuzzleが面白かったので真似しました。Ruby 2.7でしか動きません。

Okinawa.rb Ruby Puzzles 2019/5/15

第213回 Okinawa.rb Meetup @ 那覇で披露しました。 https://okinawarb.doorkeeper.jp/events/90112

今のtrunk(Ruby 2.7)でしか動きません。

RubyKaigi 2019のCookpad Daily Ruby Puzzlesがとてもおもしろかったので、お返しパズルです。 https://techlife.cookpad.com/entry/2019/04/25/122520

https://gist.github.com/mame/76a1dd346b3a2b468a3b9d3d5e9f1a11

1問目は想定解の他に2つ1文字解があって3通りの解き方があります。

解答はここにあります。 https://hanachin.hateblo.jp/entry/2019/05/19/132617

他の人の問題

解答

"Hello world".then do
case x = 1.010101
in ^x
puts "Goodbye world"
end
rescue NoMatchingPatternError
puts @1
end
def say
Proc.new
end
greeting = say {
case "Hello world"
in x => y if x = 1
then
1
else
0
end & 1 => y
}
puts greeting.call(1)
?...?.?%??.:puts.:[]==="Hello world":%??
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment