Skip to content

Instantly share code, notes, and snippets.

@supremebeing7
Created June 5, 2014 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save supremebeing7/aa61bf14e95cd67b59ca to your computer and use it in GitHub Desktop.
Save supremebeing7/aa61bf14e95cd67b59ca to your computer and use it in GitHub Desktop.
Reverse a string
this can be an easy one
no using ‘reverse’ :)
Word Count
count words in a block of text
count how many times each word appears
display a list of all unique words
Sports Statistics
we will provide arrays / objects that have players & numbers (stats)?
compute averages / all-time records etc
Refactoring Exercises
we provide a bunch of code to refactor
using many if / else / elsif statements
String Interpolation
write a method that will handle string interpolation
will accept 2 arguments: 1) the string interpolation (“hello #{firstName} #{lastName}, how are you?”} 2) a dictionary (hash / object in js) to convert the variables.
Find Dates
example: write a method to find the first sunday that is also on the 15th from now until 2050
find all sundays that are on the 15th, 18th in a given year etc
other date finding stuff
Hotel Booking / Date Validation
should take a string of dd/mm/yy and validate that it’s a correct date
validate that it isn’t in the past
accept 2 ranges and validate that the 2nd is after the first and return the difference (how many nights the stay is)
Possible combinations
Generate all possible combinations of a string in order
example: ‘mac’ should return ‘m, ma, mac, a, ac, c’
Also show possibilities not in order: ‘ca, cam etc’
Number Arrays
accept of an array of numbers as an argument
return lowest number and highest number in array
exclude negative numbers
Coin possibilities (perhaps too long?)
accepts an amount of cents as an argument
return the possible combinations in US coins (example: 10 cents would return options of: 10 pennies, 1 dime, 2 nickels, 1 nickel 1 penny - this can be in an object / hash)
start small and keep going
Generate a random string / key
use uppercase / lowercase / numbers and special charchters as possibilities
generate a unique random string that is xx long based on the argument
Array Practice
accept an array with an unlimited amount of arrays in it
add the indexes of each array together
return 1 array with the sum of all the indexes of every array
example: [[1,3,5,8], [2,3,2], [1,1,1,1,1,1]] == [4,7,8,9,1,1]
Get RGB
Write a function that converts a hexadecimal color, for example blue "#0000FF", into its RGB representation "rgb(0, 0, 255)"
using jQuery, change colors on the page to reflect the input
Compounded Interest
Write a method that determines how long it will take to grow $100 to $500 assuming 5% APR
Step 2, take in as arguments both numbers and the APR
String Match (basic / possibly repetitive)
take in 2 strings as arguments, return if the second string includes the first string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment