Skip to content

Instantly share code, notes, and snippets.

@sckm
sckm / FigaroHelloWorld.scala
Created June 20, 2014 10:11
Hello World with Figaro
import com.cra.figaro.language.Flip
import com.cra.figaro.language.Select
import com.cra.figaro.library.compound.If
import com.cra.figaro.algorithm.factored.VariableElimination
object HelloWorld {
val sunnyToday = Flip(0.2);
val greetingToday = If(sunnyToday,
Select(0.6 -> "Hello World!", 0.4 -> "Howdy, universe!"),
Select(0.2 -> "Hello World!", 0.8 -> "Oh no, not again"))
public int minColors(int[] colors)
{
boolean[] isDependence = new boolean[colors.length];
Arrays.sort(colors);
for(int i=0;i<30;i++){
for(int j=0;j<colors.length;j++){
if(isDependence[j])
continue;
@sckm
sckm / StapCells.java
Created June 4, 2014 16:25
STAPSTAPSTAPSTAPSTAPSTAPSTAPSTAPSTAPSTAPSTAPSTAP
import java.util.Random;
public class StapCells {
public static void main(String[] args) {
StapCells p = new StapCells();
p.create();
}
public StapCells() {
}
public int maximumEarnings(int[] value, String[] earning)
{
int res = 0;
int[][] e = new int[value.length][value.length];
for(int i=0;i<value.length;i++){
res -= value[i];
for(int j=i;j<value.length;j++){
e[i][j] = earning[i].charAt(j) - '0';
e[j][i] = e[i][j];
res += e[i][j];
public int findSubset(int[] numbers)
{
Arrays.sort(numbers);
int[] numCounts = new int[numbers[numbers.length-1]+1];
for(int i=0;i<numbers.length;i++)
numCounts[numbers[i]]++;
if(numCounts[1] == 0)
return 0;
numCounts[1]--;
ArrayList<ArrayList<Integer>> seqLens;
int xs;
int ys;
public int getNumber(String[] board)
{
xs = board[0].length();
ys = board.length;
seqLens = new ArrayList<ArrayList<Integer>>();
for(int i=0;i<ys;i++){
@sckm
sckm / SRM602Div2Mid.java
Last active January 1, 2016 16:59
SRM602 Div2 Mid
public int getmax(int[] X, int[] Y, int limit)
{
ArrayList<Integer> x = new ArrayList<Integer>();
ArrayList<Integer> y = new ArrayList<Integer>();
// limitを超えないものを除外
// 横長にする
// Yを降順にソート
for(int i=0;i<X.length;i++){
if(X[i]*Y[i] < limit)
@sckm
sckm / SRM601Div2Mid.java
Last active January 1, 2016 16:59
SRM601 Div2 mid
public int getNumber(int[] type)
{
Arrays.sort(type);
int res;
int lastNum;
int curNumCount;
int lastComb;
if(type[0] != 1)