Skip to content

Instantly share code, notes, and snippets.

View nixiz's full-sized avatar
🎯
Focusing

Oguzhan KATLI nixiz

🎯
Focusing
View GitHub Profile
@nixiz
nixiz / contiguous_list.c
Created April 19, 2021 09:49
Contiguous list implementation in C language
#include <stdlib.h>
#include <string.h>
#include "contiguous_list.h"
contiguous_list_t* create_new_list(const size_t size_of_elem) {
return create_new_list_with_cap(size_of_elem, 2);
}
contiguous_list_t* create_new_list_with_cap(const size_t s, const size_t cap) {
contiguous_list_t mlist = {
@nixiz
nixiz / thread_safe.cpp
Created April 19, 2021 19:06
Thread safe accessor encapsulation implementation in C++
#include <iostream>
#include <mutex>
#include <assert.h>
/*
From the book "Modern C++ Design: Generic Programming and Design Patterns Applied" Andrei Alexandrescu
There are interesting applications of smart pointer layering, mainly because of the mechanics of
operator->. When you apply operator-> to a type that's not a built-in pointer, the compiler does an
@nixiz
nixiz / multi_observer.cc
Created March 4, 2022 15:14
Multiple Observer handling by using single observer bridge
#include <functional>
#include <iostream>
#include <string>
#include <tuple>
#include <type_traits>
struct IObserver {
virtual ~IObserver() = default;
virtual void OnMessage(const std::string&) = 0;
};
@nixiz
nixiz / nqueen.c
Created July 20, 2022 07:32
N Queen Problem Solution done in C language.
#include <stdio.h>
#include <stdlib.h>
#define N_MAX_BOARD_ROW_SIZE 15
/*
Board array keeps queen placement(column index) on given indexed row value
Example board allocation for N = 4
1 2 3 4
1 - Q - -
2 - - - Q
@nixiz
nixiz / love_calc.rs
Last active August 24, 2022 14:05
Aşk uyumu hesaplayıcı
use std::collections::HashSet;
use itertools::Itertools;
use itertools::EitherOrBoth::{Both, Left, Right};
type Score = usize;
fn main() {
let score = calculate("Selçuk", "Evin");
println!("score: {}", score);
}
@nixiz
nixiz / contiguous_list.c
Last active August 7, 2023 14:37
Example implementation contiguous list in C
#include <stdlib.h>
#include <string.h>
#include "contiguous_list.h"
contiguous_list_t* create_new_list(const size_t size_of_elem) {
return create_new_list_with_cap(size_of_elem, 2);
}
contiguous_list_t* create_new_list_with_cap(const size_t s, const size_t cap) {
contiguous_list_t mlist = {