Skip to content

Instantly share code, notes, and snippets.

import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class LeftAndRightHandedDiv2 {
// srm 612 div 2
public int count(String S) {
// find number of "RL" in S
int cpt = 0;
Pattern regex = Pattern.compile("RL", Pattern.MULTILINE);
package bridge.services;
public interface BridgeService extends /* refine */ LimitedRoadService {
/** Observateur: nombre de véhicule sur le pont en direction de l'ile */
public int getNbIn();
/** Observateur: nombre de véhicule sur le pont en direction du continent */
public int getNbOut();
// inv: getNbCars() == getNbIn() + getNbOut()
This file has been truncated, but you can view the full file.
.file 1 "a.c"
.section .mdebug.abi32
.previous
.gnu_attribute 4, 1
.abicalls
.comm caml_code_fragments_table,12,4
.comm caml_extern_sp,4,4
/**
* fib.java engendre par ml2java
*/
/**
* de'claration de la fonction fib___1
* vue comme la classe : MLfun_fib___1
*/
class MLfun_fib___1 extends MLfun {
int coin = 0;
for (Coord c : coords) {
if (coin==0) {
previousNode = createOrUpdateNode(c, previousNode);
System.err.println("Pile");
} else {
System.err.println("Face");
}
coin = (coin+1)%2;
}
@davidsan
davidsan / MapRoute.java
Created February 9, 2014 13:15
snippet
int coin = 0;
for (List<Coord> l : coords) {
if (coin==0) {
List<MapNode> nodes = new ArrayList<MapNode>();
for (Coord c : l) {
// make coordinates match sim map data
if (mirror) {
c.setLocation(c.getX(), -c.getY());
}
c.translate(xOffset, yOffset);
#
# Default settings for the simulation
#
## Scenario settings
Scenario.name = default_scenario
Scenario.simulateConnections = true
Scenario.updateInterval = 0.1
# 43200s == 12h
Scenario.endTime = 43200
@Override
public Object clone(){
Zoo res = new Zoo(t.length);
for(int i = 0; i<t.length; i++){
res.t[i] = new Cage(t[i]);
}
res.n = n;
return res;
}
@davidsan
davidsan / IRappel.java
Last active January 2, 2016 09:19
Dictionnaire RMI - Examen de rattrapage du 14 mai 2013 - untested
package dict;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface IRappel extends Remote {
void done() throws RemoteException;
void setResult(Object o) throws RemoteException;
@davidsan
davidsan / ex2.c
Last active January 2, 2016 07:48
POSIX 9x2
// Exercice 2 :
// Fait la meme chose que l'exo1, mais lorsque l'aio a fini il n'envoie pas de signal
// on utilise le timer qui envoie un signal (SIGRTMIN ici) périodiquement
// à chaque fois qu'on recoit le signal, on vérifie si l'aio est terminée
void interrupt_signal(int s, siginfo_t *si, void *val) { }
int main(int argc, char **argv) {
/* masquer tout */
sigset_t block_mask;
struct sigaction action;
sigfillset(&block_mask);