diff --git a/.template.lua b/.template.lua index 8d18d86..82a80ed 100644 --- a/.template.lua +++ b/.template.lua @@ -1,3 +1,5 @@ +-- Description +-- -- Solution -------------------------------------------------------------------- function f() -- Your implementation here diff --git a/anagrams.lua b/anagrams.lua index cbf083b..61c53d7 100644 --- a/anagrams.lua +++ b/anagrams.lua @@ -1,3 +1,7 @@ +-- Implement the is_anagram() function below, so that it returns true if +-- the two passed strings are anagrams of each other. Any non- +-- alphabetical characters in the string should be ignored. +-- -- Solution -------------------------------------------------------------------- function is_anagram(str1, str2) -- Your implementation here diff --git a/balanced_brackets.lua b/balanced_brackets.lua index 8a7a33b..5c4c134 100644 --- a/balanced_brackets.lua +++ b/balanced_brackets.lua @@ -1,3 +1,7 @@ +-- Implement is_balanced(), which should return true or false depending +-- on whether the brackets in the input string are balanced, +-- i.e. there is a closing bracket for each opening one. +-- -- Solution -------------------------------------------------------------------- function is_balanced(input) -- Your implementation here diff --git a/fibonacci_numbers.lua b/fibonacci_numbers.lua index d55868f..d896442 100644 --- a/fibonacci_numbers.lua +++ b/fibonacci_numbers.lua @@ -1,3 +1,5 @@ +-- Write a function to calculate the nth fibonacci number. +-- -- Solution -------------------------------------------------------------------- function nth_fibonacci_number(n) -- Your implementation here diff --git a/greatest_common_divisor.lua b/greatest_common_divisor.lua index d6559c2..9d475cc 100644 --- a/greatest_common_divisor.lua +++ b/greatest_common_divisor.lua @@ -1,3 +1,7 @@ +-- The greatest common divisor (GCD) of two numbers X and Y is, as the +-- name suggests, the largest number which evenly divides both X and +-- Y. Implement the function below to calculate this. +-- -- Solution -------------------------------------------------------------------- function greatest_common_divisor(x, y) -- Your implementation here diff --git a/hamming_distance.lua b/hamming_distance.lua index 8a71bd2..2ae3d4a 100644 --- a/hamming_distance.lua +++ b/hamming_distance.lua @@ -1,3 +1,8 @@ +-- The hamming distance is the number of positions in which two +-- strings differ, and is used to measure how similar strings are. +-- Implement the hamming_distance() function below to calculate this; +-- you may assume that the strings are of equal length. +-- -- Solution -------------------------------------------------------------------- function hamming_distance(str1, str2) -- Your implementation here diff --git a/hexadecimal.lua b/hexadecimal.lua index bb0e7f8..0ab2f02 100644 --- a/hexadecimal.lua +++ b/hexadecimal.lua @@ -1,3 +1,6 @@ +-- Write a function to return the hexadecimal representation (in a +-- string) of a number. Use lowercase a to f. +-- -- Solution -------------------------------------------------------------------- function hexadecimal(x) -- Your implementation here diff --git a/leap_years.lua b/leap_years.lua index d633280..7ba9c2c 100644 --- a/leap_years.lua +++ b/leap_years.lua @@ -1,3 +1,6 @@ +-- Implement is_leap_year() below, returning whether the given year is +-- a leap year according to the Gregorian calendar. +-- -- Solution -------------------------------------------------------------------- function is_leap_year(year) -- Your implementation here diff --git a/maximum.lua b/maximum.lua index cf02855..6c446ed 100644 --- a/maximum.lua +++ b/maximum.lua @@ -1,3 +1,5 @@ +-- Implement a function to return the largest value in a list. +-- -- Solution -------------------------------------------------------------------- function maximum(list) -- Your implementation here diff --git a/palindromes.lua b/palindromes.lua index e94d656..fe10f4c 100644 --- a/palindromes.lua +++ b/palindromes.lua @@ -1,3 +1,7 @@ +-- Implement is_palindrome(), which should return whether the passed +-- string is palindromic (i.e the same forwards as it is backwards). +-- Ignore non-letters and case. +-- -- Solution -------------------------------------------------------------------- function is_palindrome(str) -- Your implementation here diff --git a/prime_numbers.lua b/prime_numbers.lua index 05451a9..f89fe88 100644 --- a/prime_numbers.lua +++ b/prime_numbers.lua @@ -1,3 +1,5 @@ +-- Write a function to determine whether a given number is prime. +-- -- Solution -------------------------------------------------------------------- function is_prime(x) -- Your implementation here diff --git a/queen_threats.lua b/queen_threats.lua index bbecbd6..c0e55b9 100644 --- a/queen_threats.lua +++ b/queen_threats.lua @@ -1,3 +1,8 @@ +-- Implement the function is_queen_threat() below. It should return +-- true if the queen is threatening the pawn and false otherwise. The +-- coordinates are as given as file (A-H), rank (1-8) pairs such as B3 +-- and D7. +-- -- Solution -------------------------------------------------------------------- function is_queen_threat(queen_position, pawn_position) -- Your implementation here diff --git a/resistor_colours.lua b/resistor_colours.lua index 559351a..0f829c3 100644 --- a/resistor_colours.lua +++ b/resistor_colours.lua @@ -1,3 +1,7 @@ +-- Write a function to determine the resistance (in ohms) of a given +-- three-part resistor colour code. The colour code is passed as a +-- list of strings. +-- -- Solution -------------------------------------------------------------------- function decode_resistance(colours) -- Your implementation here