Algorithms

  • Challenge 1

    Write a function modemean that accepts an array of numbers, and returns a boolean indicating if the mode and mean of the array are equal.
  • Challenge 2

    Write a function nthFibonacci that returns the nth Fibonacci number. A Fibonnaci sequence is a list of numbers that begin with 0 and 1, and each subsequent number is the sum of the previous two.
  • Challenge 3

    Write a function gcd that accepts two integers, and returns the greatest common divisor.
  • Challenge 4

    Write a function rotategrid that is given an NxN grid of elements represented by a 2D array, and outputs a grid equivalent to the same grid rotated 90 degrees clockwise.
  • Challenge 5

    Write a function transpose that accepts a two dimensional array and returns a transposed version of that array
  • Challenge 6

    Write a function anagrams that accepts a string, and returns an array of all possible anagrams of the string.
  • Challenge 7

    Write a function permPalin that accepts a string, and returns a boolean indicating if ANY of the permutations of that string is a palindrome.
  • Challenge 8

    Write a function knightjumps that will accept two numbers, indicating the location of a knight on a standard 8x8 chess board with no other pieces on the board. The two arguments, x and y, range from 1 to 8. knightjumps should return the number of spaces that the knight can move to from those given coordinates. For example: if the invocation is knightjumps(4, 5), then knightjumps should output 8 because the knight can move to 8 different spaces from position x = 4 and y = 5.
  • Challenge 9

    Write a function countTwos that takes a number as an argument, num. The function will return the number of 2s encountered on EVERY number when counting from 1 to num (inclusive). 2222 counts as having 4 2s.
Supported Browsers: