This file contains hidden or 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 itertools | |
| C = int(raw_input()) | |
| for c in xrange(C): | |
| N = int(raw_input()) | |
| cities = [int(x) for x in raw_input().split()] | |
| cables = [int(x) for x in raw_input().split()] | |
| # dist = sum([sum([(cables[i]-cables[j])*(cities[i]-cities[j]) if cables[i]>cables[j] else (cables[j]-cables[i])*(cities[i]-cities[j]) for i in xrange(j,N)]) for j in xrange(N)]) | |
| # pairs = [] | |
| # sums = 0 | |
| # for i in xrange(N-1): |
This file contains hidden or 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
| if(!document.getElementById("viewer")) document.body.innerHTML+="<div id='viewer'></div>"; | |
| viewer = document.getElementById("viewer"); | |
| include = function(st) { | |
| ext = st.split('.').pop(); | |
| ext = ext.toLowerCase(); | |
| switch(ext){ | |
| case "js": | |
| viewer.innerHTML+='<script type="text/JavaScript" src="'+st+'"></script>'; | |
| break; | |
| case "css": |
This file contains hidden or 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
| #http://xkcd.com/710/ or you could leave the job to your computer and go out with your friends :P | |
| number = int(raw_input()) | |
| stack = [] | |
| while number!=1: | |
| if number%2==0: number = number//2 | |
| else: number = 3*number+1 | |
| stack.append(number) | |
| print(len(stack)) |
This file contains hidden or 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
| <?php | |
| include_once('simple_html_dom.php'); | |
| $target_url = $_REQUEST["url"]; | |
| $html = new simple_html_dom(); | |
| $html->load_file($target_url); | |
| foreach($html->find('td[class=pbe]') as $img) { | |
| echo $img->src."<br />"; | |
| echo $img."<br/>"; | |
| } | |
| ?> |
This file contains hidden or 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
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
| <html lang="en"> | |
| <head> | |
| <title>Interactive Image Vamp up with jQuery, CSS3 and PHP</title> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
| <meta name="description" | |
| content="Interactive Image Vamp up with jQuery, CSS3 and PHP" /> | |
| <meta name="keywords" content="jquery, php, fancy, css3, rotation" /> | |
| <link type="text/css" href="css/jquery.ui.theme.css" rel="stylesheet" /> | |
| <link type="text/css" href="css/jquery.ui.core.css" rel="stylesheet" /> |
This file contains hidden or 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
| (function (w, d) { | |
| //https://gist.github.com/1847816 | |
| var a, k = 'protocol hostname host pathname port search hash href'.split(' '); | |
| w.UFCOE = w.UFCOE || {}; | |
| /** | |
| * Parse a URI, returning an object similar to Location | |
| * | |
| * Usage: UFCOE.parseUri("hello?search#hash").search -> "?search" | |
| * | |
| * @param String url |
This file contains hidden or 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
| nextNode = function(node) { | |
| if(node===document) { | |
| console.log("Document"); | |
| node = null; | |
| } | |
| else if(node.firstChild) { | |
| console.log("FirstCHild"); | |
| node = node.firstChild; | |
| } | |
| else if (node.nextSibling) { |
This file contains hidden or 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
| // Select all Approve buttons | |
| a=document.querySelectorAll("a.uiButton.uiButtonConfirm"); | |
| // Fire the click event on each of them | |
| for(var i=0,j=a.length;i<j;i++){fireEvent(a[i], "click")} |
This file contains hidden or 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
| // Card Constructor | |
| var Card = function(suit,cardNumber){ | |
| var prototype=this; | |
| prototype.getNumber=function(){return cardNumber;}; | |
| prototype.getSuit=function(){return suit;}; | |
| prototype.getSuitName=function(){ | |
| switch(suit){ | |
| case 1: return "Hearts"; | |
| case 2: return "Spades"; | |
| case 3: return "Diamonds"; |
This file contains hidden or 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
| #!/bin/python | |
| # Head ends here | |
| import math | |
| def getArrayIndex(stringIndex, size): | |
| stringIndex += 1 # Switch base to 1 from 0 | |
| row = math.ceil(float(stringIndex)/size) | |
| col = stringIndex - (row-1)*size | |
| return row, col | |
| def displayPathtoPrincess(n,grid): | |
| #print all the moves here |
OlderNewer