# 99 Elm Problems

## Contents

## NOTICE[edit]

Development of *99 Elm Problems* is continuing on Gitbook.com.

## Introduction[edit]

The purpose of this problem collection is to give you the opportunity to practice your skills in Elm programming and functional programming, and to see how other programmers solve these problems. Your goal should be to find the most elegant solution of the given problems. Efficiency is important, but logical clarity is more crucial. Some of the problems can be trivially solved using built-in functions. In these cases, you will learn more if you try to implement your own solution.

These problems were adapted for Elm from 99 Haskell Problems, which are adaptations of 99 Lisp Problems, which are adaptations of 99 Prolog Problems. Some problems have been removed where they don't apply to Elm

## Testing your work[edit]

You can compile and execute the examples online at http://elm-lang.org/try or http://share-elm.com/.

## The Problems[edit]

### Lists[edit]

- Problem 1: Find the last element of a list
- Problem 2: Find the next to last element of a list
- Problem 3: Find the n-th element of a list
- Problem 4: Find the number of elements of a list
- Problem 5: Reverse a list
- Problem 6: Determine if a list is a palindrome
- Problem 7: Flatten a nested list structure
- Problem 8: Eliminate consecutive duplicates of list elements
- Problem 9: Pack consecutive duplicates of list elements into sublists
- Problem 10: Run length encode a list of tuples

### Lists, continued[edit]

- Problem 11: Run-length encoding
- Problem 12: Run-length decoding
- Problem 14: Duplicate the elements
- Problem 15: Repeat each element
- Problem 16: Drop every N'th element
- Problem 17: Split a list into two parts
- Problem 18: Extract a sublist
- Problem 19: Rotate a list N places
- Problem 20: Remove the nth element

### Lists again[edit]

- Problem 21: Insert an element
- Problem 22: Create a range of integers
- Problem 23: Randomly selected elements
- Problem 24: Randomly select from a set
- Problem 25: Generate a random permutation
- Problem 26: Generate combinations of a set
- Problem 27: Group elements into disjoint subsets
- Problem 28: Sort a list of lists

### Arithmetic[edit]

- Problem 31: Check for prime
- Problem 32: Find greatest common divisor
- Problem 33: Check for coprime
- Problem 34: Calculate Euler's totient function
- Problem 35: Find prime factors
- Problem 36: List the prime factors
- Problem 37: Calculate Euler's totient function using prime factors
- Problem 39: List prime numbers within a range
- Problem 40: Goldbach's conjecture
- Problem 41: Search a range of numbers

### Logic and Codes[edit]

- Problem 46: Define functions for logical operations
- Problem 47: Build truth tables for logical expressions
- Problem 48: Build truth tables for any logical expressions
- Problem 49: Gray codes
- Problem 50: Huffman codes

### Binary Trees[edit]

- Problem 55: Construct a balanced binary tree
- Problem 56: Construct a symmetric binary tree
- Problem 57: Construct a binary search tree
- Problem 58: Generate and test paradigm
- Problem 59: Construct a height balanced binary tree
- Problem 60: Construct a height-balanced binary tree of N nodes

### Binary Trees, continued[edit]

- Problem 61: Count the leaves
- Problem 62: Collect the internal nodes
- Problem 63: Construct a complete binary tree
- Problem 64: Plot node coordinates 1
- Problem 65: Plot node coordinates 2
- Problem 66: Plot node coordinates 3
- Problem 67: Represent a tree as a string
- Problem 68: Generate an ordered sequence
- Problem 69: Represent a tree with Dot Notation

### Multi-way Trees[edit]

- Problem 70: Count the nodes of a multiway tree
- Problem 71: Internal path of a multiway tree
- Problem 72: Bottom-up sequence of a multiway tree
- Problem 73: Lisp representation of a multiway tree

### Graphs[edit]

- Problem 80: Convert graphs representations
- Problem 81: Find all cyclic paths
- Problem 82: Find closed paths
- Problem 83: Find spanning trees
- Problem 84: Find the minimal spanning tree
- Problem 85: Determine if two graphs are isomorphic
- Problem 86: Calculate degree of a node
- Problem 87: Depth-first order graph traversal
- Problem 88: Connected components
- Problem 89: Check for bipartite graph

### Puzzles[edit]

- Problem 90: Eight Queens
- Problem 91: The Knight's Tour
- Problem 92: Graceful Labeling
- Problem 93: Inserting operators
- Problem 94: Generate regular graphs
- Problem 95: Numbers to text
- Problem 96: Syntax checker
- Problem 97: Sudoku solver
- Problem 98: Nonogram solver
- Problem 99: Elm Problems: Crossword puzzle solver

## Authors and contributors[edit]

This Wikibook has been written by: