Skip to content

Instantly share code, notes, and snippets.

@joshuabamboo
joshuabamboo / tenpin.rb
Last active August 21, 2019 16:47
Basic Ruby Implementation of a Bowling Game
class Tenpin
attr_accessor :score, :previous_roll, :previous_spare, :previous_strike,
:frame_count, :beginning_of_frame, :current_roll, :double_strikes
TOTAL_PINS = 10
TOTAL_FRAMES = 10
def initialize
@score, @strike_count, @frame_count, @current_roll, @previous_roll = 0,0,0,0,0
@beginning_of_frame = true
end

Keybase proof

I hereby claim:

  • I am joshuabamboo on github.
  • I am joshuabamboo (https://keybase.io/joshuabamboo) on keybase.
  • I have a public key ASCpYpFyhvWxGIBMcd7qOPIO3uSk6wW8uvmvwu7u3Rt1zAo

To claim this, I am signing this object:

@joshuabamboo
joshuabamboo / spiral_order_traversal.rb
Created April 4, 2017 21:24
Traversing a 2D array in a spiral motion
# 1 2 3 A
# 4 5 6 B
# 7 8 9 C
# G F E D
# 1 2 3 9 8 6 3 2 1 0 7 4 5 6 9 8
def spiral_order_traversal(arr, output = nil)
# create array for output
output ||= []
Topics: Methods, arguments, default arguments, return values, scope, string interpolation, call the method.
Have them construct a method and hit on all of these topics:
1. define a method called `greeting`
2. it should accept 2 arguments--greeting and name
3. puts a string using the greeting and the name
4. whats the return value of the method
5. create a default greeting
6. how would you call the method