Skip to content

Instantly share code, notes, and snippets.

View Otumian-empire's full-sized avatar

Otu Michael Otumian-empire

View GitHub Profile
@Otumian-empire
Otumian-empire / makefile
Created May 3, 2023 17:51
makefile for the random disdtribution snippet
cc = gcc -Wall
file = rand_test.c
bin = app.o
all: compile run
compile:
@clear
@$(cc) $(file) -o $(bin)
7 7 3 4 6 9 7 1 5 1 2 2 6 4 7 5 6 7 8 4 0 5 5 2 8 5 7 7 7 4 1 0 7 4 2 3 0 6 9 5 3 8 4 5 7 5 0 8 9 9 7 6 8 7 5 5 7 0 3 2 4 4 8 7 7 9 6 7 1 9 8 5 4 0 5 7 7 0 5 7 6 0 6 4 4 1 9 1 2 6 1 8 7 1 8 8 4 1 6 5 2 0 3 1 3 5 0 6 8 9 1 2 1 7 3 7 6 1 1 3 7 8 7 1 6 8 6 4 3 4 1 3 9 3 8 3 8 3 1 1 2 0 7 5 7 8 0 3 0 5 4 1 7 5 9 1 4 5 3 7 9 3 5 1 7 0 6 1 4 4 5 3 0 1 8 5 9 4 9 7 2 0 3 6 9 0 6 8 9 9 1 1 5 6 1 3 6 9 4 9 0 0 5 6 0 0 9 2 5 4 4 5 1 7 2 9 0 7 0 7 9 3 8 3 1 5 7 2 0 2 0 1 6 7 7 2 6 5 6 6 7 6 8 4 7 9 5 2 6 2 9 6 1 3 8 3 6 4 8 3 7 9 3 5 5 9 5 1 4 2 4 1 2 3 0 1 2 6 2 6 0 5 2 8 2 6 3 6 0 7 6 3 3 0 2 6 6 5 2 9 8 4 9 6 5 8 3 0 2 0 7 6 4 4 0 4 5 7 4 5 0 2 2 3 2 0 8 9 8 3 8 6 9 4 6 4 7 4 7 9 5 0 8 5 7 0 2 4 6 7 7 2 8 4 1 6 1 1 0 4 2 7 3 8 7 7 5 9 9 4 0 1 5 4 9 0 5 4 8 3 1 9 3 5 1 0 4 8 9 2 0 9 8 3 7 1 3 5 6 7 0 0 5 7 3 2 2 8 2 1 9 2 0 1 6 0 5 2 5 1 2 7 6 2 3 2 7 3 8 3 6 0 7 1 6 7 4 4 2 8 3 1 5 1 0 2 8 1 0 0 9 3 8 1 9 5 3 1 0 0 4 9 1 7 1 4 4 3 1 8 9 6 5 4 3 7 9 4 8 4 2 5 1 4 7 6 7 1 1 6 2 6 7 4 7 4 2 8 3 5 0 2 4 4 1 6 3 8 3 6 7 6
@Otumian-empire
Otumian-empire / employee.py
Created November 22, 2021 03:52
More example
# file name: employee.py
# calculating the gross pay
class Employee:
def __init__(self, name, job, salary):
self.name = name
self.job = job
self.salary = salary
@Otumian-empire
Otumian-empire / math_module.py
Created November 22, 2021 03:49
We are going to import a lot of things from the math module thus to keep it structured we shall group them as tuples though it will work fine anyway.
# import objects from the math lib
# making use of some constants such as `pi` and `e`,
# some trig function like the cosine and sine
# and other functions
from math import (
pi, e,
cos, sin, tan,
sqrt, pow, exp,
gcd, factorial
@Otumian-empire
Otumian-empire / hello.py
Created May 15, 2020 23:00
I am getting a SyntaxError: invalid syntax, whenever i run this code
def say_hello()
print("hello")
@Otumian-empire
Otumian-empire / ch01.py
Created January 1, 2020 15:29
Given a rod of length n inches and an array of prices that contains prices of all pieces of size smaller than n. Determine the maximum value obtainable by cutting up the rod and selling the pieces. For example, if length of the rod is 8 and the values of different pieces are given as following, then the maximum obtainable value is 22 (by cutting…
# Problem definition and analysis
# Determine the maximum value obtainable by cutting
# up a rod and selling the pieces
# given given that the rod is of size, n
# and an array with the prices of pieces of the rod
# less than n
# For example, if length of the rod is 8 and the values of
# different pieces are given as following, then the maximum
@Otumian-empire
Otumian-empire / putwordinmiddle.py
Last active July 6, 2019 10:52
Given an out string of lenghth, 4 such as "<<>>" and a word. Return a new string where by word is in the middle of the out string. Example, <<word>>
# a program that inserts a str, "word" in the middle of another str, "out"
# this code make_out_word is very limit, i'd say won't even work
def make_out_word(out, word):
nstr = ""
leno = len(out)
if len(out) == 4: # replace with len(out) % 2 == 0
for i in range(leno):
if i == 2: # replace with i == leno // 2
nstr += str(word)
@Otumian-empire
Otumian-empire / LoopTwice.java
Created January 15, 2019 15:18
Write a program to output 0123401234
public class LoopTwice {
public static void main(String[] args) {
for (int i = 0; i < 2; i++) {
for (int x = 0; x < 5; x++) {
System.out.printf(x);
}
}
}
}
@Otumian-empire
Otumian-empire / helloworld.py
Created January 3, 2019 11:28
Hello world in python
print("Hello world")