Skip to content

Instantly share code, notes, and snippets.

View ga2arch's full-sized avatar
🐢

Gabriele Carrettoni ga2arch

🐢
View GitHub Profile
@ga2arch
ga2arch / gist:1621666
Created January 16, 2012 16:34
clj-sudoku (backtracking)
(ns clj-sudoku.core
(:gen-class))
;;; Records
(defrecord Square [pos x y num hints sure unit])
;;; Grids
(def easy-grid ".931.564.7.......55.12.93.72.......3.369.752.9.......13.24.81.96.......4.473.285.")
@ga2arch
ga2arch / core.clj
Created January 20, 2012 13:14
clj-maze
(ns clj-maze.core
(:use [clojure.test])
(:gen-class))
(def north 2r0001)
(def east 2r0010)
(def south 2r0100)
(def west 2r1000)
(defn dir-open? [square dir]
@ga2arch
ga2arch / maze.clj
Created January 21, 2012 20:09 — forked from cgrand/maze.clj
A maze generator (Wilson's algorithm) which can work with any topography (hextiles, torus variants, teapot etc.)
; http://groups.google.com/group/clojure/browse_thread/thread/974e2c7f89e27231/5f4bff3e58dfa36f
; output images http://i.imgur.com/gSASS.png (square maze)
; http://i.imgur.com/uEqaq.png (hex maze)
;; generic Wilson's algorithm implementation
(defn maze
"Returns a random maze carved out of walls; walls is a set of
2-item sets #{a b} where a and b are locations.
The returned maze is a set of the remaining walls."
[walls]
@ga2arch
ga2arch / maze.clj
Created January 25, 2012 23:30
clj-maze (backtracking)
(ns clj-maze.core
(:use [clojure.test]
[clojure.java.io :only (as-file)])
(:gen-class))
;;; Records
(defrecord Cell [corridors visited])
;;; Methods
@ga2arch
ga2arch / ircbot.scm
Created February 15, 2012 21:27
scm-ircbot
(use tcp6 regex)
(define server "irc.freenode.net")
(define port 6667)
(define nick "SchemeBot")
(define chan "#web")
(define nick "scm-bot")
(define chan "#clojure")
@ga2arch
ga2arch / perms.scm
Created February 26, 2012 21:35
Permutations
; Scrivere un programma che chiede all’utente un numero intero n positivo e poi visualizza tutte le combinazioni ; di lunghezza n costituite da sequenze di simboli ’+’ e ’-’. L’ordine delle combinazioni `e a piacere.
; Esempio : input 3
; output: +++ ++- +-- +-+ -++ --+ --- -+-
(define (permutation data)
(define (neg el)
(cond
((string=? el "+") "-")
((string=? el "-") "+")))
@ga2arch
ga2arch / algo.hs
Created March 8, 2012 18:56
Sort Algorithms
import Data.List
main = do
let ra = [3, 7, 4, 9, 5, 2, 6, 1]
let sa = selectionSort ra
print sa
-- Insertion sort
insert' :: (Ord a) => a -> [a] -> [a]
public class Player {
public int points;
public int ping;
public String nickname;
public Player(String ping, String points, String nickname) {
this.ping = Integer.parseInt(ping);
this.points = Integer.parseInt(points);
this.nickname = nickname.substring(1, nickname.length()-1);
@ga2arch
ga2arch / nix_battery.c
Created April 22, 2012 21:34
Read battery on linux
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 15
typedef struct {
int hours;
int minutes;
} Time;
@ga2arch
ga2arch / clj-vodafone-sms.clj
Created May 10, 2012 21:04
Send sms through vodafone online sms
(ns clj-vodafone-sms.core
(:require [clj-http.client :as client])
(:gen-class))
(def home-url "http://www.vodafone.it/190/trilogy/jsp/home.do")
(def dispatcher-url "http://www.vodafone.it/190/trilogy/jsp/dispatcher.do?ty_key=fdt_invia_sms&tk=9616")
(def dispatcher-url2 "http://www.areaprivati.vodafone.it/190/trilogy/jsp/dispatcher.do?ty_key=fsms_hp&ipage=next")
(def prepare-url "http://www.areaprivati.vodafone.it/190/fsms/prepare.do")
(def captcha-url "http://www.areaprivati.vodafone.it/190/fsms/generateimg.do")
(def send-url "http://www.areaprivati.vodafone.it/190/fsms/send.do")