Created
April 24, 2015 00:19
-
-
Save takayahilton/4aa69fe801fbb0162b34 to your computer and use it in GitHub Desktop.
listの部分和でkを満たすものが存在するかどうかを判定する
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
def dfs(li:List[Int] ,k:Int,sum:Int = 0):Boolean = li match{ | |
case _ if sum == k => true | |
case Nil => false | |
case x::xs => dfs(xs,k,sum) || dfs(xs,k,sum+x) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment