Skip to content

Instantly share code, notes, and snippets.

View rvalenciano's full-sized avatar
🐻

Randall Valenciano Fallas rvalenciano

🐻
View GitHub Profile

Git Exercise

Preparation (First Time Contribution)

This section contains some of the preparation work before being able to start contributing to the repository.

Introduction to Git

The first and more important thing to know is that:

@rvalenciano
rvalenciano / practice4.rb
Last active September 11, 2015 21:29
Is a number prime?
# Test if number is prime
def isPrime(num)
for d in 2..(num - 1)
if (num % d) == 0
return false
end
end
true
end
@rvalenciano
rvalenciano / practic3.rb
Created September 11, 2015 20:22
Custom attr_accessor
class SuperFoo
attr_accessor :data
def initialize
@data = {}
end
def self.data_accessor(*args)
args.each do |arg|
def consecutive(arr)
#your code here
min_numbers = 0
if arr.size > 1
arr.sort!
arr.each_with_index do |item, index|
if index != (arr.size - 1)
min_numbers = min_numbers + ((arr[index+1] - arr[index]) - 1 )
end
end
@rvalenciano
rvalenciano / practice2.rb
Last active September 11, 2015 06:14
Repeated Substring
def f(s)
#your code here
substring = s.scan(/(.+)\1+/)
unless substring.empty? || substring.first.first.size == 1
temp = temp2 = substring
loop do
break if temp2.empty?
temp2 = temp.first.first.scan(/(.+)\1+/)
unless temp2.empty?
temp = temp2
@rvalenciano
rvalenciano / days.php
Created December 9, 2014 23:58
Problem of counting the number of days since the beginning of the year
<?php
function countDays($dateInString) {
// Write your code here
// To print results to the standard output you can use print
// Example:
// print "Hello world!";
$month = '';