Skip to content

Instantly share code, notes, and snippets.

View bansal1232's full-sized avatar
🌴
On vacation

Shubham Bansal bansal1232

🌴
On vacation
View GitHub Profile
@bansal1232
bansal1232 / kilo.c
Created June 30, 2018 18:24
Changes made in editorUpdateSyntax() function.
/* Kilo -- A very simple editor in less than 1-kilo lines of code (as counted
* by "cloc"). Does not depend on libcurses, directly emits VT100
* escapes on the terminal.
*
* -----------------------------------------------------------------------
*
* Copyright (C) 2016 Salvatore Sanfilippo <antirez at gmail dot com>
*
* All rights reserved.
*
#include <cstdio>
#include <vector>
using namespace std;
struct s
{
s(int){ puts("s(int)"); }
s(){puts("s()");}
s(const s&){ puts("s(const s&)");}
s(s&&){ puts("s(s&&)"); }
s &operator =(const s&){ puts("operator =(const s&)"); return *this; }
int Solution::findMedian(vector<vector<int> > &vec) {
int n = vec.size(), m = vec[0].size();
int mx = 0, mn = INT_MAX;
for(int i=0; i<n; ++i){
mx = max(mx, *max_element(vec[i].begin(), vec[i].end()));
mn = min(mn, *min_element(vec[i].begin(), vec[i].end()));
}
@bansal1232
bansal1232 / 8puzzle.py
Created December 18, 2017 19:33 — forked from flatline/8puzzle.py
An eight-puzzle solver in python
# Solves a randomized 8-puzzle using A* algorithm with plug-in heuristics
import random
import math
_goal_state = [[1,2,3],
[4,5,6],
[7,8,0]]
def index(item, seq):
#include<bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
@bansal1232
bansal1232 / crash.c
Created November 30, 2017 07:28
Find 10 mistake in this C program
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define KB1 1024
#define MEMSIZE (4 * KB1)
char *string = "IDENTIFY 10 ISSUES IN THIS MEMLEAK PROGRAM";
char *gstring = "IDENTIFY 10 ISSUES IN THIS MEMLEAK PROGRAM";
char *gptr;
int num;
char * f1_alloc(void);
import requests
from bs4 import BeautifulSoup
url = "http://www.hindustantimes.com/rss/topnews/rssfeed.xml"
resp = requests.get(url)
soup = BeautifulSoup(resp.content, features="xml")
items = soup.findAll('item')