Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar

Adrian Statescu thinkphp

View GitHub Profile
#
# Square Root Babylonian Method
# @Adrian Statescu
#
def sqrt_babylonian(n):
x = n
y = 1.0
eps = 0.000001
while x - y > eps:
x = (x + y) / 2
#
# Square Root Babylonian Method
# @Adrian Statescu
#
def sqrt_babylonian(n)
x = n
y = 1.0
e = 0.000001
while x - y > e
x = (x + y) / 2
@thinkphp
thinkphp / linkedlist.c
Created June 13, 2022 20:55
Singly Linked List
#include <stdio.h>
#include <malloc.h>
typedef struct Node {
int data;
struct Node *next;
} Node;
Node *head = NULL;
def make_bold(f):
def bold_wrapper():
return "<b>" + f() +"</b>"
return bold_wrapper
def make_italic(f):
def italic_wrapper():
return "<i>" + f() + "</i>"
return italic_wrapper
from time import sleep
from sys import stdout
def printt(string, delay = 0.05):
for c in string:
stdout.write(c)
stdout.flush()
sleep(delay)
print("")
@thinkphp
thinkphp / change-color-dir.txt
Created April 17, 2021 19:17
How do I change the color for directories with ls in console
;to change your directory colors, open up your ~/.bashrc file with your editor
;and make the following entry at the end of the
LS_COLORS=$LS_COLORS:'di=0;35:' ; export LS_COLORS
@thinkphp
thinkphp / repeatuntil.c
Last active December 12, 2020 08:11
repeat ... until control flow in c language
#include <stdio.h>
#define __repeat__ do
#define __until__(COND) while(!(COND))
int isPrime(int n) {
if( n == 0 || n == 1 ) return 0;
if( n == 2 || n == 3 ) return 1;
int i = 2,
def euclid_it a, b
while b != 0
r = a % b
a, b = b, r
end
a
end
def euclid_rec a, b
if b == 0
import sys
def _euclid(a,b):
if(b==0):
return a
else:
return _euclid(b,a%b)
def _euclid_it(a,b):
while(b):
r = a % b
#include <stdio.h>
#include <malloc.h>
#define FIN "ssm.in"
#define FOUT "ssm.out"
struct Arr {
int size;
int *data;
};