Skip to content

Instantly share code, notes, and snippets.

@Ismael-VC
Ismael-VC / tets.jl
Created January 11, 2014 17:27
test
function test()
print("This is a test!")
end
@Ismael-VC
Ismael-VC / str_cat.jl
Created February 3, 2014 00:14
String concatenation demo in Julia with the *= operator.
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
ismaelvc@toybox ~> julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "help()" to list help topics
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.3.0-prerelease+1316 (2014-01-30 05:22 UTC)
#include <stdio.h>
#define MAX 5
int main(void)
{
int arreglo[] = {1, 2, 3, 4, 5};
int i;
for(i=0; i < MAX; i++) {
int numero = arreglo[i];
ismaelvc@toybox ~> python2
Python 2.7.6 (default, Feb 15 2014, 23:01:55)
[GCC 4.8.2 20140206 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> math.e
2.718281828459045
ismaelvc@toybox ~> python
Python 3.3.4 (default, Feb 11 2014, 16:14:21)
[GCC 4.8.2 20140206 (prerelease)] on linux
@Ismael-VC
Ismael-VC / guess_number.jl
Last active August 29, 2015 13:56
Example of 1 vs 0 based indexing.
#!/usr/bin/env julia
range = 1:100
big = range[end]
small = range[1]
function guess()
(small + big) >> 1
end
@Ismael-VC
Ismael-VC / valid_base_3.py
Last active August 29, 2015 13:56
Checks wheter a string is a valid base 3 number representation.
In [1]: valid_base_3_digits = ['0', '1', '2']
In [2]: for digit in '012':
...: if digit not in valid_base_3_digits:
...: print("That won't work!")
...: else:
...: print("Seems right!")
...:
Seems right!
Seems right!
@Ismael-VC
Ismael-VC / caras_cubo.jl
Last active August 29, 2015 13:56
caras de un cubo?
ismaelvc@toybox ~> julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "help()" to list help topics
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.3.0-prerelease+1672 (2014-02-22 04:00 UTC)
_/ |\__'_|_|_|\__'_| | Commit b2fea25* (0 days old master)
|__/ | i686-pc-linux-gnu
@Ismael-VC
Ismael-VC / sum_even_factorials.py
Last active August 29, 2015 13:56
Sum even factorials.
#!/usr/bin/env python3
def factorial(n):
"""
>>> factorial(20)
2432902008176640000
"""
if n < 2:
return 1
@Ismael-VC
Ismael-VC / Identidad_Trigonometrica.ipynb
Last active August 29, 2015 13:56
Identidad trigonometrica en Julia.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Ismael-VC
Ismael-VC / caras_rubik.py
Created February 23, 2014 21:45
caras rubik
[[[ 1, 2, 3],
[ 4, 5, 6],
[ 7, 8, 9]],
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]],
[[19, 20, 21],
[22, 23, 24],