Skip to content

Instantly share code, notes, and snippets.

View coderaven's full-sized avatar
💭
Making the world a better place, one innovation at a time.

Raven coderaven

💭
Making the world a better place, one innovation at a time.
View GitHub Profile
@coderaven
coderaven / C_cup_problemA.rb
Created December 8, 2012 09:04
Solution for Devcon C-Cup Problem A
gets.to_i.times do
q = gets.to_i
sum_x, sum_y, sum_x2, sum_xy = 0, 0, 0, 0
q.times do
x,y=gets.split.map(&:to_f)
sum_x += x
sum_y += y
sum_x2 += x**2
sum_xy += x*y
end
@coderaven
coderaven / icts_a.c
Created December 18, 2012 15:02
ICTS Programming Competition Solution for Problem A
#include <stdio.h>
#include <string.h>
int main(){
char speeds[100], *splice;
int curr_speed,i;
fgets(speeds,100,stdin);
splice = strtok(speeds," ");
for(i = 1; splice != NULL; i++){
var util = require('util'),
http = require('http'),
events = require('events');
var Twitter = function(opts) {
this.username = opts.username;
this.password = opts.password;
this.track = opts.track;
this.data = '';
};
@coderaven
coderaven / fcfs.c
Last active February 20, 2021 16:14
OS Project - First Come First Served
#include <stdio.h>
// Coded by Raven G. Duran
struct process {
int arrival_time;
int burst_time;
int waiting_time;
int turnaround_time;
@coderaven
coderaven / peterson.rb
Created January 23, 2013 12:57
Peterson's Process Control Algorithm Implementation in Ruby
(@flag ||= []) << false << false # Initialize @flag[0] and @flag[1] as false
@shared = 0 and @turn # Initialize @shared variable and declare @turn variable
puts "---------- Peterson's Algorithm Implementation ----------"
puts "A process control algorithm to ensure that only one"
puts "process can be in the critical section at any given time."
puts ""
puts "Project Implemented in Ruby by: Raven G. Duran BSIT 2R5"
puts "---------------------------------------------------------",""
@coderaven
coderaven / Paging.java
Created March 23, 2013 02:12
An OS Project for simulating different Paging Algorithms.
package paging;
/**
*
* @author imraven
*/
import java.io.*;
public class Paging {
@coderaven
coderaven / euler42.rb
Last active December 15, 2015 13:39
Project Euler Problem 42 Solution
require 'open-uri'
(o = "\n") && ( puts "There are a total of %s " % (open('http://projecteuler.net/project/words.txt', 'r'){ |f| IO.readlines(f).to_s.gsub(/\"|\\|\[|\]/,"").split(",").inject(0){|t,s| (z =( Math.sqrt(8 * (c = s.split(//).inject(0){|n,l| n+(l.ord-64)}) +1)-1)/2) % 1==0 ? (t+1 if ((o = o + "#{t+1}.#{s} (#{c},#{z.to_i})\n") || true) ) : t}}.to_s + "triangle words:" + o) )
<!--
Inspired on Dr.Nic ruby-tmbundle (https://github.com/drnic/ruby-tmbundle/blob/master/Snippets/Insert%20ERb's%20%3C%25%20__%20%25%3E%20or%20%3C%25%3D%20__%20%25%3E.tmSnippet)
In your Sublime Text 2 User folder (Sublime Text 2/Packages/User), create this file and give a name "erb.sublime-snippet".
Than open a Ruby on Rails view file like HAML or ERB, type "erb" command and tab key.
This create ERB tag on your view file.
-->
<snippet>
<content><![CDATA[<%= ${0} %>]]></content>
<tabTrigger>erb</tabTrigger>
@coderaven
coderaven / euler41.c
Last active December 15, 2015 15:39
My C implementation and solution for Project Euler problem 41 - Pandigital Prime
#include <stdio.h>
#include <stdbool.h>
#include <math.h>
// Euler 41 in C - Solution by Raven G. Duran
// If this is correct for you sir Barongkot
// Then you owe me 500 PHP which you can send to my Paypal: me@imraven.com or during a meetup :D
// Common good ol' prime checker
bool is_prime(long int n){
@coderaven
coderaven / euler41-P.cpp
Last active December 15, 2015 16:08
Euler 41 in C++ Using Permutation
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cmath>
// Euler 41 in C++ Using Permutation - Solution by Raven G. Duran
// Common good ol' prime checker
bool is_prime(long int n){
int i;