Skip to content

Instantly share code, notes, and snippets.

View rogerluan's full-sized avatar
🚀

Roger Oba rogerluan

🚀
View GitHub Profile
@rogerluan
rogerluan / calculate_cpf_digits.rb
Last active December 27, 2022 20:18
Calculates the digits of a CPF, given the first 9 digits of it.
# Usage: `ruby calculate_cpf_digits.rb "123456789"`
cpf = ARGV[0]
cpf_array = cpf.split("").map(&:to_i)
def calculate_digit(base_array:)
# Constants
divisor = 11 # Constant, fixed number
weighted_array = [10, 9, 8, 7, 6, 5, 4, 3, 2] # Digits, starts with 10 and decrements by 1
# Algorithm
@rogerluan
rogerluan / DefMode.java
Last active April 9, 2024 19:50
A simple yet extremely effective Robocode robot.
package a20;
import robocode.*;
import java.awt.Color;
/**
* DefMode - A Robocode robot
* @author: Roger Oba
* @date: September 2014
*
* This robot won 2nd place in an internal Robocode tournament. The 1st place had a complex algorithm with over 1k LOC, and most other participants had over 600 LOC ;)