Skip to content

Instantly share code, notes, and snippets.

View noiano's full-sized avatar

Marco Didonna noiano

View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="img/favicon.ico">
@noiano
noiano / nqueens.pl
Last active August 3, 2023 01:06
N-queens problem in prolog
use_module(library(lists)).
/*
N-queens problem solved in Prolog (SWI-Prolog).
Usage es: n_queen(4,X).
*/
n_queen(N, Solution) :-
### Keybase proof
I hereby claim:
* I am noiano on github.
* I am noiano (https://keybase.io/noiano) on keybase.
* I have a public key whose fingerprint is 2807 F9E4 8F7E 6594 A8EA 70EE ADB8 8BD6 BFC6 9BC9
To claim this, I am signing this object:
@noiano
noiano / grand_total.py
Created August 26, 2011 09:04
Displays the sum of the sizes of the files whose paths are read from an input file
import os
import sys
#definisco funzione per human readable size
def sizeof_fmt(num):
for x in ['bytes','KB','MB','GB','TB']:
if num < 1024.0:
return "%3.1f%s" % (num, x)
num /= 1024.0
@noiano
noiano / PairOfStringInt.java
Created February 4, 2011 09:10
PairOfStringInt.java
package com.github.noiano.hXMLInvIndex;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;
@noiano
noiano / GroupingComparator.java
Created February 3, 2011 17:18
GroupingComparator
public class GroupingComparator implements RawComparator<PairOfStringInt>{
private static final Text.Comparator TEXT_COMPARATOR = new Text.Comparator();
@Override
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
return TEXT_COMPARATOR.compare(b1, s1, l1, b2, s2, l2);
/*
int firstL1;;
int firstL2;
public class TermPartitioner extends Partitioner<PairOfStringInt, PairOfWritables<Text, ArrayListOfIntsWritable>> {
public int getPartition(PairOfStringInt key, PairOfWritables<Text, ArrayListOfIntsWritable> value, int numPartitions) {
return (key.getLeftElement().hashCode() & Integer.MAX_VALUE) % numPartitions;
}
}
public class JobDriver {
/**
* @param args
* @throws IOException
* @throws ClassNotFoundException
* @throws InterruptedException
*/
public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {