Skip to content

Instantly share code, notes, and snippets.

View CianLR's full-sized avatar
💻
Workin' at the car wash

Cian Ruane CianLR

💻
Workin' at the car wash
View GitHub Profile
@CianLR
CianLR / bggp.S
Created June 27, 2023 20:14
Entry for binary.golf BGGP4. This compiles to an ELF file that replicates itself to a file called '4' and prints '4' to stdout. It is 110 bytes compiled. Tested on kernel version 5.15.0
BITS 32
org 0x08048000
ehdr: ; Elf32_Ehdr
db 0x7F, "ELF", 1, 1, 1, 0 ; e_ident
; we use the padding to store data, must be 8 bytes
msg: db '4', 0xa
filename: db '4', 0
pad_entry: mov cl, 0b1000010
@CianLR
CianLR / constexpr_sieve_of_eratosthenes.cpp
Created April 16, 2023 10:40
A compile time generator of primes
#include <vector>
#include <array>
#include <iostream>
#include <algorithm>
constexpr std::vector<int> primesVec(int N) {
std::vector<int> primes;
std::vector<int> vec(N + 1, 1);
for (int i = 2; i < N + 1; ++i) {
if (!vec[i]) continue;

Keybase proof

I hereby claim:

  • I am cianlr on github.
  • I am cianlr (https://keybase.io/cianlr) on keybase.
  • I have a public key ASB5rFkyRFKMWm02zf8hSYgqlPiar39n0jEl-sGWgsnGGgo

To claim this, I am signing this object:

from math import sin, cos, pi
import sys
def polar_to_point(radius, angle):
x = radius * sin(angle)
y = radius * cos(angle)
return round(x)+radius, round(y)+radius
def circle_string(radius, to_cir):
@CianLR
CianLR / bigtruck.py
Created March 4, 2017 22:09
Solution to the Kattis problem: Big Truck
from queue import PriorityQueue
class Location:
def __init__(self, i, items):
self.i = i
self.items = items
self.connected_to = []
self.best_road_to = None
self.total_items_up_to = 0
float STRIKE_CHANCE = 0.05;
float FORK_CHANCE = 0.08;
void setup() {
size(800, 600);
//frameRate(30);
}
void draw() {
fill(37, 50, 88, 30);
% Q1
is_in(X, [X|_]) :- !.
is_in(X, [_|LT]) :-
is_in(X, LT).
delete_from(X, [X|LT], LT) :- !.
delete_from(X, [LH|LT], [LH|AT]) :-
delete_from(X, LT, AT).
% Q2
def count_char(s, c):
if s == '':
return 0
else:
is_c = int(s[0] == c) # 1 if True, 0 if False
return is_c + count_char(s[1:], c)
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
class Person
{
public:
string name;
/*
AutoMed EEPROM write by Cian Ruane 13/03/15
For Teensy++ 2.0
*/
#include <EEPROM.h>
int addr = 0;