Skip to content

Instantly share code, notes, and snippets.

View lnds's full-sized avatar

Eduardo Díaz lnds

View GitHub Profile
@lnds
lnds / gist:3862218
Created October 9, 2012 23:49
programa1 fortran
C --- PROGRAMA 1 -----
read 6, i,k,j
99 if(i .lt. j)goto 33
goto 55
33 i=j
goto 99
55 k=j+1
stop
@lnds
lnds / flor.lsys
Created September 16, 2012 16:15
Solucion a la flor
lar 20
ang 30
axi D
D:LALALALALALA
L:C++C++C++C++C++C++C
C:FFC
U:------
A:Uff+F+Fb-b-bb++++
iter 4
@lnds
lnds / ofhamming.c
Created July 8, 2012 20:15
Oscura, pero eficiente solución al problema de hamming
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/*
**
** Adaptación del código de Jed Davis
** En Lambda The Ultimate: http://lambda-the-ultimate.org/node/608#comment-5267
*/
@lnds
lnds / hamming0_lnds.py
Created July 8, 2012 18:08
Haming Solucion 0 en Python (www.programando.org)
def hamming(p1,p2,p3):
yield 1
m2 = times(p1, hamming(p1,p2,p3))
m3 = times(p2, hamming(p1,p2,p3))
m5 = times(p3, hamming(p1,p2,p3))
for h in merge(merge(m2, m3), m5):
yield h
@lnds
lnds / siracusa-2.c
Created May 5, 2012 14:05
Mejorando la solución al problema siracusa, segundo intento
INT orbita(INT n) {
INT largo = 0;
do {
if (n&0x01)
n = ((n<<1)|1)+n;
do {
n = n>>1;
largo++;
} while(!(n&0x01));
} while (n>1);
@lnds
lnds / siracusa-1.c
Created May 2, 2012 01:42
solución problema de Siracusa
#include <stdlib.h>
#include <stdio.h>
typedef unsigned long long INT;
INT orbita(INT n) {
INT largo = 0;
do {
n = (n % 2) == 0 ? n / 2 : n*3+1;
largo++;
@lnds
lnds / gist:2017018
Created March 11, 2012 16:26
Determinación si un año es bisiesto
// este es un ejemplo para www.programando.org
/* return 1 si el año es bisiesto, 0 si no lo es.
Esta función es muy simple y no considera hechos históricos asociados al calendario gregoriano.*/
int is_leap(int year)
{
return ((year % 4) == 0) && ( (year % 100) != 0 || (year % 400) == 0 );
}