Upgrade to Pro — share decks privately, control downloads, hide ads and more …

初学者でも遊べる!Rubyで競技プログラミング

 初学者でも遊べる!Rubyで競技プログラミング

gogutan

June 27, 2020
Tweet

More Decks by gogutan

Other Decks in Programming

Transcript

  1. w "U$PEFSɹˠΦεεϝ✨
 IUUQTBUDPEFSKQ 
 ೔ຊͷίϯςεταΠτɺ΄΅ຖि຤։࠵ɺສਓ΄Ͳ͕ಉ࣌ࢀՃ w (PPHMF$PEF+BN
 IUUQTDPEJOHDPNQFUJUJPOTXJUIHPPHMFDPNDPEFKBN 
 (PPHMFओ࠵ɺ೥ʹ౓ͷେ͖ͳίϯςετ

    w 5PQDPEFS
 IUUQTBSFOBUPQDPEFSDPN 
 ΞϝϦΧͷ࿝ฮίϯςεταΠτ w $PEFGPSDFT
 IUUQTDPEFGPSDFTDPN 
 ϩγΞͷίϯςεταΠτɺ։࠵ස౓͕ߴ͘ࢀՃਓ਺΋ଟ͍ ओཁͳڝٕϓϩάϥϛϯάαΠτͷҰྫ
  2. "U$PEFS#FHJOOFS$POUFTU#1PTUBM$PEF IUUQTBUDPEFSKQDPOUFTUTBCDUBTLTBCD@C ग़୊ྫ ࣮૷ྫʢจࣈͣͭ֬ೝʣ def postal_code?(string, a, b) string.each_char.with_index do

    |char, index| case index when a return false unless char == “-" else return false unless (“0”.."9").include?(char) end end true end w ۭจࣈ͕ೖྗ͞Εͯ΋USVF͕ฦ͖ͬͯͯ͠·͏ w ਖ਼نදݱΛ࢖͑͹ɺ΋ͬͱ͍͍ײ͡ʹॻ͚ΔͷͰ͸ʁ
  3. "U$PEFS#FHJOOFS$POUFTU#1PTUBM$PEF IUUQTBUDPEFSKQDPOUFTUTBCDUBTLTBCD@C ग़୊ྫ ࣮૷ྫʢจࣈͣͭ֬ೝʣ def postal_code?(string, a, b) string.each_char.with_index do

    |char, index| case index when a return false unless char == “-" else return false unless (“0”.."9").include?(char) end end true end def postal_code?(string, a, b) string.match?(/\d{#{a}}-\d{#{b}}/) end w ۭจࣈ͕ೖྗ͞Εͯ΋USVF͕ฦ͖ͬͯͯ͠·͏ w ਖ਼نදݱΛ࢖͑͹ɺ΋ͬͱ͍͍ײ͡ʹॻ͚ΔͷͰ͸ʁ ࣮૷ྫʢਖ਼نදݱʣ ˠ؆͔ܿͭਖ਼֬ͳίʔυʹʂ