Showing posts from September, 2017

Generic quicksort in C

Recently I've learned how to use void pointers and function pointers in C and make functions generic as a part of MRND . So I've tried developing a generic quicksort function using it. I've implemented it in a header file so that it can be reused. Here's the gist for genericSort.h  The four arguments being sent into the genericQSort function are: void ** arr :  It's an array of pointers which holds the addresses of each element of the array that is to be sorted. int lo: The start index from where the array needs to be sorted. int hi:  The end index till where the array needs to be sorted. int (*compare)( void * , void * ) : A function pointer to the user's implementation of how to compare the sent array. It returns -1, 1 or 0. Here's a C program that makes use of the above function to sort an array of pair s . Here pair is a user-defined data-type which has two members x and y . The array is sorted based on the sum of x and y. H

PvP Chain reaction game using Python

At last, I've taken time and ventured a little deeper into the Python language! I used the  Tkinter   package to develop a rip-off of an android game called chain-reaction . It's a simple multiplayer board game in which the first person to occupy all the blocks on the board or of the opponent(s) wins. Try downloading and playing the game with your friends, it's FUN! Here's a video of the game I've developed(I've set the number of players to 4 and board dimensions are 6*8): Coming to the coding, I actually enjoyed the process of writing code much more in Python compared to any other previous languages that I've used. Maybe it is due to the fact that it's the first high-level language that I got my hands on. I'd never worked with Tkinter package before. It was quite easy to understand and I was able to build the game in roughly in four hours. I think that just a little effort is enough for anyone to understand how to use the  tkinter  packa