Verify yourself to prove that you are not a ROBOT! After verification the page will apear. Thanks for understanding.
Question  Dynamic Programming with Scala 

Answers  3  
Added at  20180104 17:01  
Tags  
Question 
To practice Scala I wanted do solve simple dynamic programming exercises with Scala. For some exercises I already wrote a Python implementation. Using Python most of the time I saved the intermediate results in an array. For example this Exercise: The algorithm outputs the minimal amount of coins needed to reach a value, given the value and a list of coins. (Assuming there is an unlimited amount of coins.)
Looks very simple in Python. Nevertheless I have problems writing the same code in Scala. Because of the functional paradigm I did not want to use a forloop, but rather a tailrecursive algorithm to solve that problem. And I couldn't find any good solution. Maybe a tailrecursive algorithm is not the right way to go and there is a different scalaway to implement this simple algorithm. I already looked for scala implementation of dynamic programming exercises and couldn't find a good source yet. Has someone an idea what the scala way to implement this would look like? UPDATE: The closest I came so far is very similar to Dimas tailrecursive approach. It looks like this


Answers
to Dynamic Programming with Scala 


Source  Show 