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
solve = (s, c = 0) -> if c is 81 then s else if s[x = c/9|0][y = c%9] isnt 0 then solve s, c+1 else (([1..9].filter (g) -> ![0...9].some (i) -> g in [s[x][i], s[i][y], s[3*(x/3|0) + i/3|0][3*(y/3|0) + i%3]]).some (g) -> s[x][y] = g; solve s, c+1) or s[x][y] = 0 |
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 java.util.BitSet; | |
import java.util.NavigableSet; | |
import java.util.NoSuchElementException; | |
import java.util.concurrent.ConcurrentSkipListSet; | |
/** | |
* A concurrent sorted set with a fixed bound | |
*/ | |
public class BoundedConcurrentSortedSet { |
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 ants.Action; | |
import ants.Ant; | |
import ants.Direction; | |
import ants.Surroundings; | |
import ants.Tile; | |
import java.awt.Point; | |
import java.io.ByteArrayInputStream; | |
import java.io.ByteArrayOutputStream; | |
import java.io.ObjectInputStream; |
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
var config = require('./config'), request = require('request'), fs = require('fs'), Zip = require('adm-zip'), path = require('path'); | |
var tmpDir = 'tmp'; | |
fs.mkdir(tmpDir); | |
request.post(config.bloomberg.bsym_url, function (err, res, body) { | |
if(err) throw err; | |
var record = eval('(' + body.substring(body.indexOf('{data'), body.lastIndexOf(';'))); | |
record.data.forEach(function(data) { | |
var url = data.uri, name = path.join(tmpDir, url.substring(url.lastIndexOf('/') + 1)); |
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 collection.mutable | |
import collection.JavaConversions._ | |
import org.mapdb.DBMaker // Great disk based map - https://github.com/jankotek/MapDB | |
/** | |
* My attempt at http://www.azspcs.net/Contest/Factorials/ | |
* Brief explanation: | |
* Brute force BFS (ignoring non-positive numbers and duplicates) upto length `fbf` | |
* Higher the `fbf`, the better quality result. I managed to get to `fbf`=8 before running out of memory | |
* Beyond `fbf`, try to multiply your way to n! Since the last few steps involve only multiplication, |
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
/* | |
* Works from dates after Sep 14, 1752 (New System of Gregorian Calendar (UK adoption)) | |
* May crash or return junk value for negative or other invalid inputs. | |
*/ | |
public static String calendar(int d, int m, int y) {return "Sun Mon Tues Wednes Thurs Fri Satur ".substring(d=((6-2*(y/100%4)+(m<3&&y%4==0&&(y%100!=0||y%400==0)?-1:0)+(y%=100)/12+5*(y%12)/4+"xbeehcfhdgbeg".charAt(m)+d)%7)*7,d+7).trim()+"day";} |
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 java.util.*; | |
public class Trick { | |
public static void main(String args[]) { | |
System.out.println("/////////////////////////////////////////////////"); | |
HashSet<Long> h = new HashSet(); | |
Long l = (long)4; | |
h.add(l); | |
System.out.println(h.contains(4)); |
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 com.github.pathikrit.scalgos; | |
import java.util.Map.Entry; | |
import java.util.TreeMap; | |
/** | |
* Efficient data structure to map values to intervals | |
* e.g. set(5, 60000, "hello") would set all keys in [5, 60000) to be "hello" | |
* | |
* All operations are O(log n) (in practice much faster since n is usually number of segments) |
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 <graphics.h> | |
#include <stdio.h> | |
#include <conio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <dos.h> | |
#include <time.h> | |
#include <ctype.h> | |
class player |
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
git checkout gh-pages; git merge -s subtree master; git push origin master gh-pages; git checkout master; |
OlderNewer