/53functions

Functions to prepare coders to do Code Katas. Each coder will have to clone this repository and start to commit the implementation of the functions. A central CI instance will run their functions and give them a score fo reach function based on how many tests are passing.

Primary LanguageJavaScript

53functions

You can think of 53 functions as small bite size programming challanges which aim to prepare coders to do Code Katas. Each coder will have to clone this repository and start to commit their implementation of the functions. A central CI instance will run their functions and give them a score for each function based on how many tests are passing. These functions are not to be completed on one sitting, but is to be completed on the coders own time.

Fifty-three is the 16th prime number. It is also an Eisenstein prime, and a Sophie Germain prime. The sum of the first 53 primes is 5830, which is divisible by 53, a property shared by few other numbers.

You should:

  • fork this repo
  • link your forked copy of the repo to the upstream repo to get changes easily
  • To see how to do that have a look here: https://help.github.com/articles/syncing-a-fork/
  • regularly update from upstream to check for changes
  • use TDD
    • Write the first 5 functions your own framework at first - the one you created in the Codex Setup
    • start looking at Qunit
      • Rewrite the tests for the first 5 functions using Qunit.
    • From now on use Qunit
    • Setup a Travis and start monitoring your tests
  • commit to GIT regularly

These things count:

  • regular commits
  • testable code
  • passing tests

The functions

The function name and the file name should be the same

For example for hello.js the function should look like this:

function hello(){
	// your code goes here
}

Each function should have a test file called functionname_test.js

For hello.js it should be called hello_test.js

If any of these function specifications don't make sense, let's discuss, clarify and change it.

Create a function that:

# File name & function name Write a function that?
1 hello.js return "hello world"
2 hello_uppercase.js takes a username as parameter and returns "Hello, < USERNAME parameter >!"
3 hello_joe.js takes a username as parameter and returns as "Hello, < USERNAME parameter >!" if the username is Joe or Bob only say "Hello!"
4 number_list.js takes a number as a parameter (n) and return a list of number from 1 to n
5 sum_numbers.js takes a number as a parameter (n) and return the sum of numbers from 1 to n
6 length.js takes a string parameter and return the length of the supplied parameter
7 upper.js takes a string parameter and return the supplied parameter in uppercase
8 reverse.js takes a string parameter and return the reversed string parameter
9 hello_list.js takes a number as parameter and return a list of "hello world" entries equal to the number supplied
10 high_low.js given a list of numbers returns the highest and lowest numbers in the list
11 count_words.js takes a sentence as a parameter and return the number of words in the sentence
12 sum_word_len.js takes a sentence as a parameter and return the sum of the length of words in the sentence
13 longest_word.js takes a sentence as a parameter and return the longest word in the sentence and the length of the word
14 shortest_word.js takes a sentence as a parameter and return the shortest word in the sentence and the length of the word
15 word_length.js takes a sentence as a parameter and returns both the average word length rounded up & down
16 avg.js takes a sentence as a parameter and return the average word length rounded up
17 start.js takes a sentence as a parameter and return the letter most words starts with
18 ends.js takes a sentence as a parameter and return the letter most words ends with
19 occurs_most.js takes a sentence as a parameter and return the letter that occurs the most
20 occurs_least.js takes a sentence as a parameter and return the letter that occurs the least
21 uppercase_letters.js that can find all the uppercase letters in a string
22 lowercase_letters.js that can find all the lowercase letters in a string
23 square_stars.js can draw a square shape using * it should be 4x4
24 square.js can draw a square shape using the character supplied as a parameter it should be 4x4
25 square_param.js can draw a square shape using the character supplied as a parameter, the dimensions should be supplied by a parameter
26 tri.js can draw a triangle shape using *, it should be have a base of 4
27 tri_char.js can draw a triangle shape using the character supplied as a parameter, it should be have a base of 4
28 square_param_base.js can draw a square shape using the character supplied as a parameter, the base should be supplied as a parameter
29 diamond.js can draw a diamond shape using * the center of the diamond should be 5
30 diamond_star.js can draw a diamond shape using the character supplied as parameter base of the diamond should be 5
31 diamond_char_base.js can draw a diamond shape using the character supplied as parameter base of the diamond should be supplied as parameter.
32 add.js can add two numbers
33 divide can divide two numbers
34 calc_all.js can add, subtract, multiply or divide 2 numbers - parameters are the symbol followed by the 2 numbers
35 calc_chain.js has and add, subtract, multiply and divide method - methods should be chainable and it should be possible to do Calculator.add(1,2).multiply(9).value() should equal 27
36 paper_rock.js allows one to play rock paper scissors * = rock, # = paper, x = scissors, it should be a constructor function that take in number of games that will be played. var game1 = new RockPaperScissors(3) - it should have a playerOne and a playerTwo functions, a play and a score method.
37 factors2.js find all the factors of 2 that is less than the number specified by the parameter
38 factors_2_or_7.js find all the factors of 2 or 7 that is less than the number specified by the parameter
39 factors_2_and_7.js find all the numbers that are factors of both 2 and 7 that is less than the number specified by the parameter
40 factorial.js can calculate the factorial for a number supplied as a parameter
41 fibonacci.js can calculate a fibonacci for the number supplied as a parameter
42 ascii_upper.js find the sum of all the capital letters ASCII codes
43 ascii_params.js return the sum of all the ascii codes for the word that is being passed in as a parameters.
44 mondays.js when given a year find the number of mondays there were in that year
45 anyday.js when given a year and a day of the week it can find the number of that weeks days that was in the year
46 dice_rolls.js can simulate dice rolls for the number of times specified as a parameter - returns the result of the dice rolls.
47 lower_ascii_sum.js given a string return the sum of the all the lower case letters ascii codes in the string.
48 multiples.js that can count in multiples, it takes a parameter of the multiple to count in and have a .count() method to give the next number and a list function to return all the numbers that was already counted.
49 cricket.js that solves this riddle: The common field cricket chirps in direct proportion to the current tem­perature. Adding 40 to the number of times a cricket chirps in a minute, then dividing by 4, gives us the temperature (in Fahrenheit degrees). Write a program that accepts as input the number of cricket chirps in fifteen seconds, then outputs the current temperature to the nearest half degree. http://users.csc.calpoly.edu/~jdalbey/101/HomeworkProblems.html
50 filter.js takes a list of values and a filter function that can filter the list of values - the filtered result should be returned by the function. This function should be able to filter any kind of data, it shouldn't care about the data.
51 tbd ?
52 tbd ?
53 tbd ?