Skip to content

Instantly share code, notes, and snippets.

View GnsP's full-sized avatar
👽
avant-garde

Ganesh Prasad GnsP

👽
avant-garde
View GitHub Profile
@GnsP
GnsP / gccTest.c
Last active August 29, 2015 14:15
// This is a simple C program to experiment with the GCC Compilation Steps
// It uses the #define directives below only to provide a good visualization
// of the preprocessing step.
// author : Ganesh Prasad (gnsp)
#define ONE 1
#define TWO 2
#define EXIT_OK 0
#define EXIT_FAILURE 1
$ gcc --help
Usage: gcc [options] file...
Options:
-pass-exit-codes Exit with highest error code from a phase
--help Display this information
--target-help Display target specific command line options
--help={target|optimizers|warnings|params|[^]{joined|separate|undocumented}}[,...]
Display specific types of command line options
(Use '-v --help' to display command line options of sub-processes)
#include <stdio.h>
int main(){
int a, b, c; // a, b and c are two integers
scanf("%d %d", &a, &b); // read a and b from user input
c = a + b;
printf("%d \n", c); // print the value of c
return 0; // 0 is returned to indicate that
// the program exited without errors
}
@GnsP
GnsP / tmp_random_access_expt.cpp
Created February 26, 2015 13:00
TMP Random Access Container
#define STATIC_ASSERT(expr) { char assertion_stage[((expr) ? 0:-1)]; }
#define RANDOM_ACCESS_CONTAINER_META(KEY_TYPE, val_type, name) \
template<KEY_TYPE KEY> \
struct meta_container_##name##_{ \
typedef val_type value_type; \
typedef KEY_TYPE key_type; \
static const value_type value = static_cast<value_type>(0); \
}; \
typedef KEY_TYPE meta_container_##name##_key_type_; \
@GnsP
GnsP / wikispider
Created March 14, 2015 06:00
wikipedia crawler and downloader
#!/usr/bin/python3
'''
This script is a web crawler (spider) that searches the wikipedia pages on a
given keyword recursively and returns only relevant pages that contain relevant
info on the given topic in their contents section. It also creates a directory
under the present working directory and saves the webpages for further reading.
It also builds a graph representation of the dependencies among the webpages to
show the user how the pages and the fields are interlinked.
@GnsP
GnsP / gsoc_boost_ublas.md
Last active August 29, 2015 14:17
GSoC'15 Proposal for Boost.uBLAS Algorithms

##GSoC'15 Proposal for Boost.uBLAS Algorithms

###Personal Details

  • Name : Ganesh Prasad Sahoo
  • University : National Institute of Technology, Rourkela, India
  • Course/Major : Computer Science and Engineering
  • Degree Program : B.Tech.
  • Email : sir.gnsp@gmail.com

###Availability

#include <iostream>
using namespace std;
/*
///////////////////////////////////////////////////////////////////////////////////
//
// This commented out code was used to generate the array of prime palindromes :D
//
// But there is a glitch , I am using fermat's primality test to check if a number is
// prime or not. Fermat's primality test is a probabilistic test, meaning it can go wrong
#include <iostream>
#include <vector> // a vector is a dynamically resizable array.
// ( Read about it from any standard C++ text book )
#include <algorithm> // include "algorithm" to use pre defined functions for
// commonly used algorithms like search, sort, max_element
// min_element etc
using namespace std;
int main(){
@GnsP
GnsP / KINGSHIP.c
Last active August 29, 2015 14:20
/* CHEF AND KINGSHIP, Codechef, easy
*
* This is probably the easiest problem I have posted here. The logic is very
* simple. To minimize the cost i.e. the sum of product of population of cities
* the optimal way is to construct roads from the city with minimum population
* to every other city. :D (think and try to mathematically prove why).
*
* Hence now the solution is as easy as finding the minimum population and sum of
* all other populations and just multiply the sum and the min.
*
@GnsP
GnsP / prime_ap_seq.py
Last active August 29, 2015 14:21
A project euler problem
"""
The arithmetic sequence 1487, 4817, 8147, in which each of the terms increase by
3330 is unusual in 2 ways. (i) each of the terms are prime (ii) there are permutations
of each other.
There is one more 4 digit sequence like this. Find the 12digit number formed by
concatenating them.
"""
########################################################################################