Skip to content

Instantly share code, notes, and snippets.

View prateek27's full-sized avatar

Prateek Narang prateek27

View GitHub Profile
#include<iostream>
#include<queue>
#define INT_MAX 1000000
using namespace std;
/* Author : Prateek Narang */
int findMinMoves(int *board,int n){
//We will use BFS to calculate shortest path
//moves[i] maintains the min number of moves to reach position i
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-code', { preload: preload, create: create, update: update });
var sprite;
function preload() {
game.load.image('phaser', 'assets/sprites/phaser.png');
}
function create() {
@prateek27
prateek27 / js
Created April 12, 2017 10:22
snake.js
function init(){
canvas = document.getElementById('mycanvas');
pen = canvas.getContext('2d');
W = canvas.width;
H = canvas.height;
score = 0;
snake = {
length:5,
function loadImages(){
enemyImage = new Image();
shipImage = new Image();
enemyImage.src = "Images/enemy.png";
shipImage.src = "Images/player.png";
}
var GameState = {
///Some Hidden Objects
init:function(){
//console.log("In init");
this.physics.startSystem(Phaser.Physics.ARCADE);
this.physics.arcade.gravity.y = 1000;
@prateek27
prateek27 / flappyb.js
Created April 16, 2017 10:13
flappyb
var game = new Phaser.Game(320,514,Phaser.AUTO,'game_div');
var c=0;
var userName =0 ;
var main_state={
preload:function(){
this.game.stage.backgroundColor='#0B0B61';
var text = "Loading....";
#include<iostream>
using namespace std;
/// N - steps in ladder, jump max 1,2,3
int countWays(int n){
if(n==0){
return 1;
}
if(n<0){
return 0;
#include<iostream>
using namespace std;
int coinsNeeded(int coins[],int amount,int n){
if(amount==0){
return 0;
}
int ans = INT_MAX;
#include<iostream>
using namespace std;
int knapsack(int wts[],int prices[],int N,int W){
///Base Case
if(N==0||W==0){
return 0;
}
///Rec Case
#include<iostream>
#include<climits>
using namespace std;
int query(int *tree,int index,int s,int e,int qs,int qe){
///No Overlap
if(qs>e || qe<s){
return INT_MAX;
}
///Complete Overlap