Ruby/C# - Recursive solution
Solution\n\nAdd two arguments to the function: \n time - remainning time in the current session;\n spent - number of sessions already worked.\n \n# Explanation\
# Solution\n\nAdd two arguments to the function: \n `time` - remainning time in the current session;\n `spent` - number of sessions already worked.\n \n# Explanation\n\nCheck all tasks that can feet in remaining `time` and choose minimum posible value recursivelly \nor just start a new session if none feet (in remaining `time`).\n# Ruby\n\n```ruby\ndef min_sessions(tasks, session_time, time = 0, spent = 0)\n  return spent if tasks.empty?\n  return tasks[0] <= time ? spent : spent + 1 if tasks.one?\n\n  candidates = tasks.uniq.select { _1 <= time }\n\n  if candidates.empty?\n    t = tasks.max\n    arr = tasks.dup\n    arr.delete_at(arr.index(t))\n    min_sessions(arr, session_time, session_time - t, spent + 1)\n  else\n    candidates.map do |t|\n      arr = tasks.dup\n      arr.delete_at(arr.index(t))\n      min_sessions(arr, session_time, time - t, spent)\n    end.min\n  end\nend\n```\n\n# C#\n\n```cs\npublic class Solution {\n    public int MinSessions(int[] tasks, int sessionTime, int time = 0, int spent = 0) {\n        if (tasks.Length == 0) return spent;\n        if (tasks.Length == 1) return tasks[0] <= time ? spent : spent + 1;\n\n        var candidates = tasks.Where(t => t <= time).Distinct().ToArray();\n\n        if (candidates.Length == 0) {\n            int t = tasks.Max();\n            var arr = tasks.ToList();\n            arr.RemoveAt(arr.IndexOf(t));\n            return MinSessions(arr.ToArray(), sessionTime, sessionTime - t, spent + 1);\n        } else {\n            return candidates.Min(t => {\n                var arr = tasks.ToList();\n                arr.RemoveAt(arr.IndexOf(t));\n                return MinSessions(arr.ToArray(), sessionTime, time - t, spent);\n            });\n        }\n    }\n}\n```
['Recursion', 'Ruby']