Skip to content

Instantly share code, notes, and snippets.

@dstavis
dstavis / tc_reflections.md
Last active November 4, 2022 04:02
Technical Challenge Reflections

Challenge 1

Millions of Numbers

  • What felt good about your process? I tried a new solution after my first one worked

  • What was difficult/where did you struggle? My new solution performed WORSE than the first one

  • What feedback did you receive?

React Router Prework

This gist contains a short assignment I'd like everyone to complete before our formal lesson. The prework involves reading some of the React Router documentation, and will allow us to keep the lesson more hands on.

Instructions

  1. Fork this gist
  2. On your own copy, go through the listed readings and answer associated questions

You will not be turning this in; it's for your own understanding/learning/benefit 😁

Mod 0 Plan

Environment

  1. Keep a separate desk exclusively for Turing work
  2. Only ever use my Turing laptop for Turing work
  3. Ensure that the work desk never gains an item of clutter
  • The only item that may be placed atop the school desk is an item that is being used for school

Social Strategies

@dstavis
dstavis / 0.2.1-boggle_class_from_methods.rb
Last active January 2, 2016 10:29 — forked from dbc-challenges/0.2.1-boggle_class_from_methods.rb
phase 0 unit 2 week 1 boggle class challenge
class BoggleBoard
def initialize(board)
@board = board
end
# method that maps through each
def create_word(*coords)
coords.map { |coord| @board[coord.first][coord.last] }.join("") #@board is a 2D array
end
@dstavis
dstavis / gist:7979892
Created December 15, 2013 23:36
Exercise: Implement FizzBuzz (Super Edition) FizzBuzz is a classic programming exercise. The usual example asks the developer to write a program which prints out each number from 1 to 100. But for multiples of 3 print 'Fizz' instead of the number and for multiples of 5 print 'Buzz'. For numbers which are multiples of both 3 and 5 print 'FizzBuzz…
def super_fizzbuzz(array)
#It should return a "fizzbuzzed" Array, i.e., the array is identical to the input with the following substitutions:
array.each do |number|
#Multiples of 3 should be replaced with the string "Fizz"
#Multiples of 5 should be replaced with the string "Buzz"
#Multiples of 15 should be replaced with the string "FizzBuzz"
if number % 3 == 0
@dstavis
dstavis / gist:7979797
Created December 15, 2013 23:24
Exercise 21: Implement the factorial function
Write a factorial method which takes as its input a non-negative integer and calculates the factorial of that number.
The factorial of a number is the product of all integers from 1 up to that number. For example:
factorial(5) == 5 * 4 * 3 * 2 * 1 == 120
The factorial of 0 is defined to be 1.
------------CODE-------------
@dstavis
dstavis / gist:7979684
Created December 15, 2013 23:12
Exercise 19: Finding the longest string in an array
# longest_string is a method that takes an array of strings as its input
# and returns the longest string
#
# +array+ is an array of strings
# longest_string(array) should return the longest string in +array+
#
# If +array+ is empty the method should return nil
def longest_string(array)
return nil if array.empty?
@dstavis
dstavis / gist:7979221
Created December 15, 2013 22:31
Exercise 6: Triangle side lengths Write a method valid_triangle? which takes as its input three non-negative numbers. It should return true if the three numbers could form the side lengths of a triangle and false otherwise. The arguments don't correspond to specific sides. Don't worry about handling negative inputs — garbage in, garbage out. For…
#Write a method valid_triangle? which takes as its input three non-negative numbers.
def valid_triangle?(a, b, c)
#if the three numbers could form the side lengths of a triangle
if a**2 + b**2 == c**2
#It should return true
return true
#and false otherwise.
else
return false
@dstavis
dstavis / gist:7978900
Last active December 31, 2015 11:19
Exercise 16, Calculating the median of an array of numbers.
def median(array)
array.sort!
#if total number of items in the array is odd,
if array.length % 3 == 0
#Figure out the index of the middle item. Which is one greater than half the length rounded down.
middle_index = array.length / 2 + 1
middle_index = middle_index.to_int
#return the item at that index
median = array[middle_index]