This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ''; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
// Coded by Raven G. Duran | |
struct process { | |
int arrival_time; | |
int burst_time; | |
int waiting_time; | |
int turnaround_time; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(@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 "---------------------------------------------------------","" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package paging; | |
/** | |
* | |
* @author imraven | |
*/ | |
import java.io.*; | |
public class Paging { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) ) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
OlderNewer