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
package main | |
import "fmt" | |
// Error | |
type notSquared struct { | |
number int | |
} | |
func (e notSquared) Error() string { |
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
Diff for Level0, read file into HashSet: | |
======================================== | |
+require 'set' | |
path = ARGV.length > 0 ? ARGV[0] : '/usr/share/dict/words' | |
-entries = File.read(path).split("\n") | |
+entries = Set.new File.read(path).split("\n") | |
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
override def query(q: String) = { | |
val responses: Seq[Future[HttpResponse]] = clients.map {client => client.query(q)} | |
val allResponses: Future[Seq[HttpResponse]] = Future.collect(responses) | |
val successResponses: Future[Seq[HttpResponse]] = allResponses.map(responses => responses.filter(_.getStatus == HttpResponseStatus.OK)) | |
successResponses.map { responses: Seq[HttpResponse] => | |
if (responses.isEmpty) { | |
errorResponse(HttpResponseStatus.INTERNAL_SERVER_ERROR, "No successful responses") |
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
override def query(q: String) = { | |
import net.liftweb.json._ | |
import net.liftweb.json.JsonDSL._ | |
import net.liftweb.json.Serialization.{read, write} | |
implicit val formats = DefaultFormats | |
val futures = clients.map(_.query(q).map(hr => { | |
val list = (parse(hr.getContent.toString("UTF-8")) \ "results").children | |
list.map(_.extract[String]) | |
})) |
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
/* ========================================================================== | |
Chrome Frame prompt */ | |
/* ========================================================================== */ | |
.chromeframe { | |
margin: 0; | |
background: #f7f3d6; | |
color: #2c2c2c; | |
font: normal 1em/1.3 Arial, sans-serif; |
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
#coding: utf-8 | |
from cStringIO import StringIO | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
from email.header import Header | |
from email import Charset | |
from email.generator import Generator | |
import smtplib | |
# Example address data |
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 <algorithm> | |
#include <math.h> | |
#include <numeric> | |
#include <iostream> | |
#include <map> | |
#include <cstdio> | |
#include <cstdlib> | |
#include <cassert> | |
#include <cstring> | |
#define lli long long int |
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
# | |
# Google I/O 2014 secret invite code finder | |
# | |
# Blake Caldwell, 2014 | |
# | |
# Blog Post: http://blakecaldwell.net/blog/2014/4/23/solving-a-2014-google-io-secret-invite-puzzle.html | |
# | |
# Repeatedly hit https://developers.google.com looking two-colored "I/O" on the page, | |
# with a secret code in comments below it. Using the color codes of the "I" and "O", | |
# calculate the 6-character Google URL-shortened link code, and print the code out. |
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
//Google Code Jam Round 1B 2014 - Problem A.The Repeater (small input) | |
//https://code.google.com/codejam | |
#include<stdio.h> | |
#include<stdlib.h> | |
#include<string.h> | |
#include<iostream> | |
using namespace std; | |
int findAns(char* str1, char* str2, int len1, int len2) |
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
for test in range(input()): | |
N = input() | |
A = map(int, raw_input().split()) | |
ans = 0 | |
for i in range(N): | |
l = 0 | |
r = 0 | |
for j in range(N): | |
if A[j]>A[i]: | |
if j<i: |
OlderNewer