0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

塗って繋ぐ

Posted at

もう知らないToT
水に流そうToT

以下、http://ange1.hateblo.jp/entry/2016/12/05/022642 の写経です

tyama_henae10.hs
# !/usr/bin/env runghc
-- http://mtsmfm.github.io/2016/12/03/doukaku-e10.html
-- http://qiita.com/mtsmfm/items/8a78b895910a89e3012d

import System.IO (isEOF,hFlush,stdout)
rec x o l ('X':xs) = rec (x+1) (o+l) 0 xs
rec x o l ('O':xs) = rec x o (l+1) xs
rec x o l [] = ((2^l)-1)*4*2^o + case x of
	0 -> 0
	1 -> 5+(if o==0 then 0 else 5^o)
	otherwise -> 1+4^(x-1)*5^o

main = do
	eof <- isEOF
	if not eof then do
		getLine >>= print . rec 0 0 0
		hFlush stdout
		main
	else return ()
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?