Skip to content

Instantly share code, notes, and snippets.

View Kinjalrk2k's full-sized avatar
🥱
Bored? Code!

Kinjal Raykarmakar Kinjalrk2k

🥱
Bored? Code!
View GitHub Profile
@Kinjalrk2k
Kinjalrk2k / ring_buffer.c
Created July 22, 2019 13:40
Ring Buffer implementation using a Single Circular Linked List
#include <stdio.h>
#include <malloc.h>
typedef struct Node{
int data;
int empty;
struct Node* next;
}node; // nickname :)
struct ring_buffer{
@Kinjalrk2k
Kinjalrk2k / josephus.c
Last active July 28, 2019 07:01
Demonstrating Josephus problem using Singly Circular Linked List
#include <stdio.h>
#include <malloc.h>
typedef struct Node{
int data;
struct Node* next;
}node; // nickname :)
void display(node *head)
{
@Kinjalrk2k
Kinjalrk2k / alerts.py
Created July 28, 2019 14:07
Send messages using Telegram(API), Emails(Mailgun) and SMS(Twilio) and BoltIoT APIs
from boltiot import Email, Sms
import requests, json, cred
def send_telegram_msg(message, ifprint = False):
''' Sends the message using Telegram API\n
Return boolean about the success '''
url = "https://api.telegram.org/" + cred.telegram_bot_id + "/sendMessage"
data = {
'chat_id' : cred.telegram_chat_id,
@Kinjalrk2k
Kinjalrk2k / rem_dup_sorted_ll.c
Created August 5, 2019 14:05
Remove duplicates form a sorted Linked List
/* C Program to remove duplicates from a sorted linked list */
#include<stdio.h>
#include<stdlib.h>
/* Link list node */
struct Node
{
int data;
struct Node* next;
};
@Kinjalrk2k
Kinjalrk2k / josephus_recursion.c
Created August 9, 2019 05:27
Josephus Problem in doubly circular linked list using recursion
#include <stdio.h>
#include <stdlib.h>
typedef struct Node{
int data;
struct Node *next, *prev;
}node;
node *createDCLL(int n)
{
@Kinjalrk2k
Kinjalrk2k / stack_generic.c
Created August 16, 2019 05:29
Generic Stack functions
#include <stdio.h>
#include <stdlib.h>
typedef struct stack{
int size;
char *arr;
}stack;
stack createStack(stack s)
{
@Kinjalrk2k
Kinjalrk2k / Btree_create.c
Created August 30, 2019 05:39
Create a BTree and display it, using array implementation
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
char* createBTree(int h)
{
char *tree, val, buff;
int size = pow(2,h) - 1, p = 0;
tree = (char*)malloc(size * sizeof(char));
@Kinjalrk2k
Kinjalrk2k / graph.c
Created November 7, 2019 05:12
BFS and DFS in a graph
#include <stdio.h>
#include <stdio.h>
#include <windows.h>
int q[20], top = -1, front = -1, rear = -1, a[20][20], vis[20], stack[20];
int dequeue();
void enqueue(int item);
void bfs(int s, int n);
void dfs(int s, int n);
void push(int item);
@Kinjalrk2k
Kinjalrk2k / gist_to_github_repo.md
Created November 19, 2019 05:38 — forked from ishu3101/gist_to_github_repo.md
Transfer a gist to a GitHub repository

Transfer a gist to a GitHub repository

clone the gist

git clone https://gist.github.com/ishu3101/6fb35afd237e42ef25f9

rename the directory

mv 6fb35afd237e42ef25f9 ConvertTo-Markdown

change the working directory to the newly renamed directory

cd ConvertTo-Markdown

@Kinjalrk2k
Kinjalrk2k / dyarr.c
Created December 13, 2019 18:03
Dynamic Array
#include <stdio.h>
#include <malloc.h>
int main(int argc, char const *argv[])
{
int n, *len_list, **twoD_arr, *oneD_arr;
printf("Enter n: ");
scanf("%d", &n);
len_list = (int *)calloc(n, sizeof(int));