Guest User

Untitled

a guest
Jan 21st, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. def countChange_sort(money: Int, coins: List[Int]): Int =
  2. if (coins.isEmpty || money < 0)
  3. 0
  4. else if (coins.tail.isEmpty && money % coins.head != 0) {
  5. 0
  6. } else if (coins.tail.isEmpty && money % coins.head == 0 || money == 0) {
  7. 1
  8. } else {
  9. -- redacted --
  10. }
  11. }
  12.  
  13. } else {
  14. var cnt = 0
  15. var i = 0
  16.  
  17. def loop(????) : ??? = {
  18. if (money - (i * coins.head) > 0) {
  19. cnt += countChange_sort(money - (i * coins.head), coins.tail)
  20. i = i + 1
  21. loop(????)
  22. }
  23. }
  24.  
  25. loop(????)
  26. cnt
  27. }
  28.  
  29. } else {
  30. var cnt = 0
  31. var i = 0
  32.  
  33. def loop(cnt : Int, i : Int) : ??? = {
  34. if (money - (i * coins.head) > 0) {
  35. cnt += countChange_sort(money - (i * coins.head), coins.tail)
  36. i = i + 1
  37. loop(cnt, i)
  38. }
  39. }
  40.  
  41. loop(cnt, i)
  42.  
  43. cnt
  44. }
  45.  
  46. } else {
  47. var cnt = 0
  48. var i = 0
  49.  
  50. def loop(cnt : Int, i : Int) : Int = {
  51. if (money - (i * coins.head) > 0) {
  52. cnt += countChange_sort(money - (i * coins.head), coins.tail)
  53. i = i + 1
  54. loop(cnt, i)
  55. } else {
  56. cnt
  57. }
  58. }
  59.  
  60. cnt = loop(cnt, i)
  61.  
  62. cnt
  63. }
  64.  
  65. } else {
  66. var cnt = 0
  67. var i = 0
  68.  
  69. def loop(cnt : Int, i : Int) : Int = {
  70. if (money - (i * coins.head) > 0) {
  71. loop(cnt + countChange_sort(money - (i * coins.head), coins.tail), i + 1)
  72. } else {
  73. cnt
  74. }
  75. }
  76.  
  77. cnt = loop(cnt, i)
  78.  
  79. cnt
  80. }
  81.  
  82. } else {
  83. def loop(cnt : Int, i : Int) : Int = {
  84. if (money - (i * coins.head) > 0) {
  85. loop(cnt + countChange_sort(money - (i * coins.head), coins.tail), i + 1)
  86. } else {
  87. cnt
  88. }
  89. }
  90.  
  91. loop(0, 0)
  92. }
Add Comment
Please, Sign In to add comment