99 Problems in OCaml
https://ocaml.org/learn/tutorials/99problems.html
99 problems – OCaml
Your Help is Needed Many of the solutions below have been written by Victor Nicollet. Please contribute more solutions or improve the existing ones. 99 Problems (solved) in OCaml This section is inspired by Ninety-Nine Lisp Problems which in turn was based
ocaml.org
6번 문제
- is_palindrome
- is_palindrome list
- list가 회문인지 판단한다. 회문이면 true, 그렇지 않으면 false
정답 코드
어떻게 풀어야할지 좀 더 고민해보고 싶어서 다른 문제를 먼저 풀었는데 고민이 무색하게 쉽게 구현 가능했다.
솔루션을 보고 너무 놀랐다..
test 결과
9번 문제
- pack
- pack list
- list에 연속으로 똑같은게 나오면 하나의 리스트에 담아서 리스트에 넣는다.
내가 구현한 코드
정답 코드
test 결과
구현한 코드가 맞는지 확인해보고 싶어서 출력을 해보려고했는데
위의 방법 말고는 어떻게 출력하는지 모르겠어서 파일이 아니라 ocaml 실행기를 이용해 test 결과를 확인하였다.
728x90
'Ocaml' 카테고리의 다른 글
[99 Problems in OCaml] 11번, 12번, 13번 문제 (0) | 2021.09.23 |
---|---|
[99 Problems in OCaml] 10번 문제 (0) | 2021.09.19 |
[99 Problems in OCaml] 9번 문제 (0) | 2021.09.16 |
[99 Problems in OCaml] 8번 문제 (0) | 2021.09.15 |
[99 Problems in OCaml] 7번 문제 (0) | 2021.09.14 |
댓글