Skip to content

zerone0x/haskell99

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

Haskell 99 Problems

Practice solving the famous 99 Haskell problems! These problems are Haskell translations of Ninety-Nine Lisp Problems, which are themselves translations of Ninety-Nine Prolog Problems.

Resources

Problem Categories

Questions 1 to 10: Lists

  • 1. Find the last element of a list
  • 2. Find the last but one element of a list
  • 3. Find the K'th element of a list
  • 4. Find the number of elements of a list
  • 5. Reverse a list
  • 6. Find out whether a list is a palindrome
  • 7. Flatten a nested list structure
  • 8. Eliminate consecutive duplicates of list elements
  • 9. Pack consecutive duplicates of list elements into sublists
  • 10. Run-length encoding of a list

Questions 11 to 20: Lists, continued

  • 11. Modified run-length encoding
  • 12. Decode a run-length encoded list
  • 13. Run-length encoding of a list (direct solution)
  • 14. Duplicate the elements of a list
  • 15. Replicate the elements of a list a given number of times
  • 16. Drop every N'th element from a list
  • 17. Split a list into two parts
  • 18. Extract a slice from a list
  • 19. Rotate a list N places to the left
  • 20. Remove the K'th element from a list

Questions 21 to 28: Lists again

  • 21. Insert an element at a given position into a list
  • 22. Create a list containing all integers within a given range
  • 23. Extract a given number of randomly selected elements from a list
  • 24. Lotto: Draw N different random numbers from the set 1..M
  • 25. Generate a random permutation of the elements of a list
  • 26. Generate the combinations of K distinct objects chosen from the N elements of a list
  • 27. Group the elements of a set into disjoint subsets
  • 28. Sorting a list of lists according to length of sublists

Questions 31 to 41: Arithmetic

  • 31. Determine whether a given integer number is prime
  • 32. Determine the greatest common divisor of two positive integer numbers
  • 33. Determine whether two positive integer numbers are coprime
  • 34. Calculate Euler's totient function φ(m)
  • 35. Determine the prime factors of a given positive integer
  • 36. Determine the prime factors of a given positive integer (2)
  • 37. Calculate Euler's totient function φ(m) (improved)
  • 38. Compare the two methods of calculating Euler's totient function
  • 39. A list of prime numbers
  • 40. Goldbach's conjecture
  • 41. A list of Goldbach compositions

Questions 46 to 50: Logic and codes

  • 46. Truth tables for logical expressions
  • 47. Truth tables for logical expressions (2)
  • 48. Truth tables for logical expressions (3)
  • 49. Gray codes
  • 50. Huffman codes

Questions 54A to 60: Binary trees

  • 54A. Check whether a given term represents a binary tree
  • 55. Construct completely balanced binary trees
  • 56. Symmetric binary trees
  • 57. Binary search trees (dictionaries)
  • 58. Generate-and-test paradigm
  • 59. Construct height-balanced binary trees
  • 60. Construct height-balanced binary trees with a given number of nodes

Questions 61 to 69: Binary trees, continued

  • 61. Count the leaves of a binary tree
  • 62. Collect the leaves of a binary tree in a list
  • 63. Collect the internal nodes of a binary tree in a list
  • 64. Draw a binary tree
  • 65. Layout a binary tree (1)
  • 66. Layout a binary tree (2)
  • 67. Layout a binary tree (3)
  • 68. Preorder and inorder sequences of binary trees
  • 69. Dotstring representation of binary trees

Questions 70B to 73: Multiway trees

  • 70B. Check whether a given term represents a multiway tree
  • 71. Determine the internal path length of a tree
  • 72. Construct the bottom-up order sequence of the tree nodes
  • 73. Lisp-like tree representation

Questions 80 to 89: Graphs

  • 80. Conversions
  • 81. Path from one node to another one
  • 82. Cycle from a given node
  • 83. Construct all spanning trees
  • 84. Construct the minimal spanning tree
  • 85. Graph isomorphism
  • 86. Node degree and graph coloring
  • 87. Depth-first graph traversal
  • 88. Connected components
  • 89. Bipartite graphs

Questions 90 to 94: Miscellaneous problems

  • 90. Eight queens problem
  • 91. Knight's tour
  • 92. Von Koch's conjecture
  • 93. An arithmetic puzzle
  • 94. Generate K-regular simple graphs with N nodes

Questions 95 to 99: Miscellaneous problems, continued

  • 95. English number words
  • 96. Syntax checker
  • 97. Sudoku
  • 98. Nonograms
  • 99. Crossword puzzle