Skip to content

Instantly share code, notes, and snippets.

@spetroll
spetroll / fib.py
Created December 6, 2014 17:10
Fast Fibonacci
import math
from itertools import product
def fib(n):
F = [1, 1]
T = [[0, 1],
[1, 1]]
if n == 1:
return 1
using System;
namespace GuessTheNumber
{
internal class Program
{
private static void Main()
{
Random rng = new Random();
int min = 0, guess = 0, tries = 0, max = 100, number = rng.Next(1, 100);
using System;
namespace GuessTheNumber
{
class Program
{
static Random rng = new Random();
static int min=0;
static int max=100;
static int guess = 0;
0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 1
5 5 5 5 6 6 7 7 1
5 5 5 5 6 6 7 7 1
5 5 5 5 6 6 7 7 1
5 5 5 5 6 6 . . 1
2 2 2 2 2 2 3 3 3
2 2 2 2 2 2 3 3 3
2 2 2 2 2 2 3 3 3
0 0 28 30
0 30 28 30
0 60 18 30
0 90 12 30
0 120 28 29
12 90 27 29
18 60 25 29
0 149 21 29
0 178 26 28
21 149 19 29
@spetroll
spetroll / EnumerableExtensions.cs
Last active December 10, 2015 09:28
Shuffle Enumeration
public static class EnumerableExtensions
{
private static readonly Random rng = new Random();
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source)
{
if (source == null)
throw new ArgumentNullException("source");
if (rng == null)
throw new ArgumentNullException("rng");
public static long encode(IEnumerable<int> cards)
{
long result = 0;
foreach(int c in cards)
{
result |= encode(new Card(c));
}
return result;
}
public static readonly int[] HR = new int[32487834];
private static unsafe void Init()
{
var lutFileInfo = new FileInfo(@"C:\Handranks.dat");
if (!lutFileInfo.Exists)
{
GenerateFile();
}
CDBCommand::CRow *newrow = NULL;
int wv = row->Field("wiedervorlage")->GetInt();
if (wv > 0) {
CDBCommand swv = CDBCommand(format("SELECT * FROM swvtab WHERE id=%d", wv));
if (swv.Execute())
newrow = swv.FetchRow(CDBCommand::FETCH_NOSELECT);
}
if (newrow == NULL){
CDBCommand swv = CDatastorage::GetActiveDatabase()->SimpleTable("swvtab");
public static void Main(String[] args)
{
Console.WriteLine("\n\nStarting Test");
var evals = new List<EvaluationResult>
{
StartNewTest("PST", new PSTLooper(intHands), RUNS),
StartNewTest("SteveBrecher", new SteveBrecherLooper(longHands), RUNS),
StartNewTest("2p2", new TwoPlusTwoLooper(intHands), RUNS)
};