Skip to content

Instantly share code, notes, and snippets.

View pallavsharma's full-sized avatar
🎯
Focusing

Pallav Sharma pallavsharma

🎯
Focusing
View GitHub Profile
@pallavsharma
pallavsharma / bowling_match_score_calculator
Created February 5, 2015 12:25
Bowling match score calculator.
def bowling(input)
scores = []
result = []
scores = input.split.collect { |e| e.to_i }
cf = 0 # current frame
i = 0
while(cf < 10) do
if scores[i] == 10 # For strike
result[cf] = scores[i] + scores[i + 1] + (scores[i + 2] ? scores[i + 2] : 0)
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
def dec2bin(number)
number = Integer(number)
if(number == 0) then 0 end
ret_bin = ""
while(number != 0)
ret_bin = String(number % 2) + ret_bin
number = number / 2
end
ret_bin
@pallavsharma
pallavsharma / Closures.rb
Last active August 29, 2015 14:13 — forked from pamio/Closures.rb
# CLOSURES IN RUBY     Paul Cantrell    http://innig.net
# Email: username "cantrell", domain name "pobox.com"
 
# I recommend executing this file, then reading it alongside its output.
#
# Alteratively, you can give yourself a sort of Ruby test by deleting all the comments,
# then trying to guess the output of the code!
 
# A closure is a block of code which meets three criteria:
#