Skip to content

Instantly share code, notes, and snippets.

#include <cmath>
#include <iostream>
#include <string>
using namespace std;
string calc(string msg){
int len,row,col,allot,margin;
string str="";
len=msg.length();
import re
N = int(raw_input())
for i in xrange(N):
T=str(raw_input())
if re.search(r'^hackerrank',T) and re.search(r'hackerrank$',T):
print 0
elif re.search(r'^hackerrank',T):
print 1
elif re.search(r'hackerrank$',T):
@djadmin
djadmin / uk-and-us
Created August 23, 2013 07:03
HackerRank- The British and American style of Spelling https://www.hackerrank.com/challenges/uk-and-us
TEXT=''
sum=0
N=int(raw_input())
for i in xrange(N):
TEXT+=' '+str(raw_input())
T=int(raw_input())
for i in xrange(T):
FIND=str(raw_input())
print TEXT.count(FIND)+TEXT.count(FIND[:-2]+'se')
import re
for i in xrange(input()):
pan=str(raw_input())
if re.search(r'[A-Z]{5}[0-9]{4}[A-Z]',pan):
print 'YES'
else:
print 'NO'
import re
for i in range(input()):
text=str(raw_input())
if re.search(r'^(hi [^d])',text,re.IGNORECASE):
print text
count=0
for i in xrange(input()):
text=str(raw_input())
if 'hackerrank' in text.lower():
count+=1
print count
languages=['C','CPP','JAVA','PYTHON','PERL','PHP','RUBY','CSHARP','HASKELL','CLOJURE','BASH','SCALA','ERLANG','CLISP','LUA','BRAINFUCK','JAVASCRIPT','GO','D','OCAML','R','PASCAL','SBCL','DART','GROOVY','OBJECTIVEC']
for i in xrange(input()):
input=str(raw_input()).split()
language=input[1]
if language in languages:
print 'VALID'
else:
print 'INVALID'
@djadmin
djadmin / XSS-Game Solutions
Created March 15, 2015 15:31
Google's XSS-Game Solutions
Below are the solutions to Google XSS challenges hosted on https://xss-game.appspot.com/
########################## Level 1: Hello, world of XSS ##########################
*** Query ***
https://xss-game.appspot.com/level1/frame?query=<script>alert(1)</script>
*** Vector ***
<script>alert(1)</script>
########################## Level 2: Persistence is key ##########################
@djadmin
djadmin / divshot.sh
Last active October 5, 2015 15:22
Download your Divshot project
# Please follow these steps if you need to download your divshot project.
# Let's say you need to download 'my-project' from production and you have Divshot CLI installed.
divshot login
mkdir my-project
divshot init
divshot download production
# Done
@djadmin
djadmin / git-status-watch.sh
Created November 23, 2015 08:57
Watch Git Status
#Tired to doing git status? Watch git changes using the below script
#install watch using homebrew
$ brew install watch
#watch git status
$ watch --color git status