Ever played in casinos? Let us help you find the best places to play roulette online for the first time! Enjoy also a game with the free slots, blackjack, poker and win the jackpot!
FJOM On The Run
Mis Bookmarks
Textpattern Forums
Textpattern
Bloglines
Ask Metafilter
Metafilter
Probando Shoes 2 y también Emacs
Shoes.app :title => "Numeros para la loteria",
:width=>350, :height=>600 do
background tan
stack do
para "Numero maximo"
@max=edit_line()
@max.text="55"
para "Tamaño de grupo"
@qty=edit_line()
@qty.text="6"
button("Go"){
calcula
}
end
@display=stack{ }
def calcula
max=@max.text.to_i # Numero maximo a elegir
qty=@qty.text.to_i # Cantidad de numeros por combinacion
#generamos los numeros con orden aleatorio
x=Array.new(max) {|a| a+1}.sort_by{rand}
# hacemos grupos de QTY
y=Array.new(max/qty+1) {|a| x[a*qty,qty]}
# rellenamos el ultimo grupo
while y.last.length<qty do y.last.push(rand(max)+1).uniq! end
#Ordenamos cada grupo
y.map!{|a| a.sort}
#Generamos resultado que se imprimira
@result=""
y.each {|a|
a.each { |x|
@result+= "#{x}\t "
}
@result+= "\n"
}
display_result
end
def display_result
@display.clear do
para "Juega estos numeros:"
para @result
end
end
end
Participé en vivo por primera vez, y ya tenía el de 500 jalando en mi máquina pero no alcancé a subirlo porque me tardé mucho debugeando una tonteria en el de 250 y además el MSN no me dejó en paz.
class MegaCoolNumbersEasy
{
public static int count(int N)
{
string st = N.ToString();
int c=0;
for(int i=1;i<N+1;i++)
{
if (check(i.ToString()))
{
System.Diagnostics.Debug.WriteLine(i);
c++;
}
}
return c;
}
public static bool check(string st_n)
{
if (st_n.Length<3)
return true;
int dif = -10;
int last = -10;
foreach (char c in st_n)
{
if (last == -10)
{
last = (int)c;
}
else
{
if (dif==-10)
{
dif=(int)c-last;
last=(int)c;
}
else
{
int newdif = (int)c - last;
if (newdif != dif)
return false;
dif = newdif;
last = (int)c;
}
}
}
return true;
}
}
class FallingPoints
{
public static double[] getHeights(int[] X, int R)
{
List<double> l = new List<double>();
l.Add(0.0);
for (int i = 1; i < X.Length; i++)
{
int x1 = X[i-1];
double y1 = l.Last();
int x2 = X[i];
double discriminante=(R * R) - Math.Pow((x2 - x1), 2.0);
if (discriminante<0)
l.Add(0.0);
else
l.Add(Math.Sqrt(discriminante) + y1);
}
return l.ToArray();
}
}
Otro que en ruby habría sido más sencillo.
Enunciado
class Rochambo
{
static public int wins(string opponent)
{
int win = 0;
char ultima = '0';
char penultima = '0';
char[] opciones={'R','P','S'};
foreach (char turnoOp in opponent)
{
char prediccion=new char();
if (penultima.Equals('0'))
prediccion='S';
else if (penultima.Equals(ultima))
prediccion = ultima;
else
{
foreach (char op in opciones)
{
if (!op.Equals(ultima) && !op.Equals(penultima))
prediccion = op;
}
}
if (ganador(turnoYo(prediccion),turnoOp))
win++;
penultima = ultima;
ultima = turnoOp;
}
return win;
}
static char turnoYo(char prediccion)
{
if (prediccion.Equals('S')) return 'R';
if (prediccion.Equals('R')) return 'P';
if (prediccion.Equals('P')) return 'S';
return 'E';
}
static bool ganador(char yo, char op)
{
if (yo.Equals('R') && op.Equals('S'))
return true;
if (yo.Equals('S') && op.Equals('P'))
return true;
if (yo.Equals('P') && op.Equals('R'))
return true;
return false;
}
}
Aprendí varias cosas de la clase Array en C# es bastante diferente a ruby. Ruby sigue siendo mi lenguaje favorito pero ha sido más mi renuencia a aprender a usar un toolkit para la GUI. Shoes está super bien pero es má para dibujo y ordenar texto.
En fin, Aquí está el enunciado
using System;
using System.Collections.Generic;
using System.Text;
class MovieRating
{
public static double calculate(int[] marks, int lowCount, int highCount)
{
double valor=0.0;
Array.Sort(marks);
int[] slice = new int[marks.Length-lowCount-highCount];
Array.Copy(marks, lowCount, slice, 0, marks.Length - lowCount - highCount);
foreach (int num in slice)
{
valor += num;
}
return valor / slice.Length;
}
}
Esto lo implementé en Pascal para un proyecto de la universidad hace varios años (decodificar y desplegar archivos GIF).
class HuffmanDecoding
{
public static string decode(string archive, string[] dictionary)
{
StringBuilder decodificado = new StringBuilder();
StringBuilder st = new StringBuilder();
foreach (char car in archive)
{
st.Append(car);
//Array.Contains() jala en VC#2008 pero no en top coder creo que es algun using
//if (dictionary.Contains(st.ToString()))
if (!(Array.IndexOf(dictionary,st.ToString()).Equals(-1)))
{
decodificado.Append((char)(Array.IndexOf(dictionary,st.ToString())+'A'));
st.Remove(0, st.Length);
}
}
return decodificado.ToString();
}
}