Help us understand the problem. What is going on with this article?

勉強会の参考問題の解答例。groovyで。

More than 5 years have passed since last update.

7/6(金) に行われる予定の勉強会( http://atnd.org/events/30285 )の参考問題( http://qiita.com/items/cbc3af152ee3f50a822f )の解答例、もう一つ。
まだ出てない言語で書こうということで、groovy。

poka.groovy
import java.util.regex.Pattern

def hands=[ "14":"4K", "23":"FH", "113":"3K", "122":"2P", "1112":"1P", "11111":"--" ]
def cardPattern=Pattern.compile( /[SHDC](\d+|J|Q|K|A)/ )

[ "DASAD10CAHA", "S10HJDJCJSJ",
  "S10HAD10DAC10", "HJDJC3SJS3",
  "S3S4H3D3DA", "S2HADKCKSK",
  "SASJDACJS10", "S2S10H10HKD2",
  "CKH10D10H3HJ", "C3D3S10SKS2",
  "S3SJDAC10SQ", "C3C9SAS10D2"].each(
{ q->
  m=cardPattern.matcher( (CharSequence)q )
  ranks=[:].withDefault{0}
  while( m.find() ){
    ++ranks[m.group(1)]
  }
  println( hands[ranks.values().sort().join()] )
} )

投稿のプレビューをみて初めて気づいたんだけど、シンタックスハイライト可能な言語リストに groovy が入っていない。

scala も coffeescript もあるのに groovy がないなんて。

それはさておき、java の正規表現ライブラリの使い方の勉強になった気がするが、実装内容としては新味がない。そんなものだと思う。

Nabetani
横浜へなちょこプログラミング勉強会をやっていました。 / CodeIQ の出題者でした。 / 日経 WinPC に連載を持っていました(名義が違うけど) / Yokohama rb に半分ぐらい参加しています。 / twitter : http://twitter.com/Nabetani
https://nabetani.hatenadiary.com/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした