This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |