Skip to content

Instantly share code, notes, and snippets.

View yvan-sraka's full-sized avatar

Yvan Sraka yvan-sraka

View GitHub Profile
@yvan-sraka
yvan-sraka / max.py
Last active October 14, 2023 17:00
Max function implementation explained in Python
# Input data
list_0 = [1, 3, 6, 7, 8, 9, 10, 2, 3, 4]
list_1 = [12, 56, 3, 78, 34, 56, 2, 10]
list_2 = [123, 567, 234, 890]
list_3 = [5, 7, 8, 9, 3, -2, -4, -2, 5, 6, 8, 11, 2]
# Iterative algorithm
def maximum(L):
biggest_item = L[0]
for item in L:
@yvan-sraka
yvan-sraka / binary.md
Last active November 6, 2017 17:27
Explain how binary numbers works
  • 0000 0
  • 0001 1
  • 0010 2
  • 0011 3
  • 0100 4
  • 0101 5
  • 0110 6
  • 0111 7
  • 1000 8
  • 1001 9
@yvan-sraka
yvan-sraka / ascii.md
Last active November 6, 2017 17:29
Explain how strings are represented

BOB\0

42 4F 42 00

0100 0010 0100 1111 0100 0010 0000 0000

@yvan-sraka
yvan-sraka / cash_machine.py
Last active November 6, 2017 17:37
Python cash machine algorithme code to complete
BILLS = [200, 100, 50, 20, 10]
amount = 60
i = 0
while amount > 0:
BILLS[i]
...
...
print("Finish")
# fac(1) = 1
# fac(n) = n * fac(n - 1)
def fac(n):
if n == 1:
return 1
return n * fac(n-1)
# fibo(0) = 0
# fibo(1) = 1
# fibo(n) = fibo(n-1) + fibo(n-2)
# ALGO
def fibo(n):
if n == 0:
return 0
# fibo(0) = 0
# fibo(1) = 1
# fibo(n) = fibo(n-1) + fibo(n-2)
# ALGO
def fibo(n):
a, b = 0, 1
for _ in range(n):
#! /bin/sh -x
language='javascript'
# Get x-common repository
git clone https://github.com/exercism/x-common/
cd x-common
git pull origin master
cd ..
# Get x$language repository
git clone "https://github.com/exercism/x$language/"
cd "x$language"
def ma_super_function(n):
print("start", n)
if n > 0:
ma_super_function(n - 1)
print("end", n)
ma_super_function(10)
# CPU
#include "unistd.h"
#include "stdlib.h"
#include "stdio.h"
int main(void) {
char* key = malloc(sizeof(char) * 20);
key = "cookie";
for (char i = 0; i < 20; ++i) {
printf("[%c]", key[i]);
}