Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System
- [<EntryPoint>]
- let main argv =
- let testCases = Console.ReadLine() |> int
- let rec cases (totalCases, currentNum, workingList):list<int> =
- if totalCases > currentNum then
- let tempList = [Console.ReadLine() |> int]
- cases (totalCases, currentNum+1, workingList@tempList)
- else
- workingList
- let rec calcHeight (maxCycles, currentCycle, height):int =
- if maxCycles > currentCycle then
- if currentCycle % 2 = 0 then
- calcHeight (maxCycles, currentCycle+1, (height*2))
- else
- calcHeight (maxCycles, currentCycle+1, height+1)
- else
- height
- let listOfCases = cases (testCases, 0, [])
- for i in listOfCases do
- printfn "%d" (calcHeight (i, 0, 1))
- 0 // return an integer exit code
Add Comment
Please, Sign In to add comment