Skip to content

Instantly share code, notes, and snippets.

juanfal

Block or report user

Report or block juanfal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@juanfal
juanfal / embalses.rb
Last active Jun 18, 2019
embalses.net for a province
View embalses.rb
#!/usr/bin/env ruby -KU
# embalses.rb
# 2019-06-18
# https://gist.github.com/d159f4344fc23385a5f6b90d99603c11
require 'fileutils'
require 'nokogiri'
require 'open-uri'
require 'date'
@juanfal
juanfal / DistributionStatistics.py
Last active Feb 24, 2019
distributionStatistics.py
View DistributionStatistics.py
from numpy import *
from time import sleep
g_nitems = 1000
g_ncells = 10
g_nsamples = 100000
def genDist(nitems, ncells):
r = sort(random.randint(0, nitems+1, ncells-1))
r = concatenate((r, [nitems]))-concatenate(([0],r)) # the problem was here
@juanfal
juanfal / genDist.py
Created Feb 23, 2019
distributing a number of items between a number of cells, randomly. Most efficient way
View genDist.py
from numpy import *
def genDist(nitems, ncells):
r = sort(random.randint(0, nitems, ncells, dtype=int))
r[-1] = nitems
r = delete(concatenate((r, [nitems]))-concatenate(([0],r)), -1)
return r
r = genDist(800, 10)
@juanfal
juanfal / sieveOfRepeated.cpp
Last active Jan 10, 2019
Sieve a list picking up the elements repeated a certain number of times
View sieveOfRepeated.cpp
// sieveOfRepeated.cpp
// juanfc 2019-01-10
// https://gist.github.com/079916adc1420f95017328d1f04797e7
// We are going to work with lists of integer numbers of up to a \texttt{MAX}
// (any constant) size. Define the data type \texttt{TList} and design a
// subprogram \texttt{sieve()} that receives as input parameter a
// \texttt{TList} list of integers \texttt{list1} and a integer number
// \texttt{n}. The procedure will return another \texttt{TList} \texttt{list2}
// that will just contain only those numbers from \texttt{list1} that are
// repeated exactly \texttt{n} times. In the list \texttt{list2} there will
@juanfal
juanfal / magicsquareSTL.cpp
Created Jan 10, 2019
Coxeter Magic Squares algorithm using STL arrays
View magicsquareSTL.cpp
// magicsquareSTL.cpp
// juanfc 26/1/02, 2006-12-14, 2019-01-10
//
// \ej\label{magicsq}\dificil\dificil\textbf{Magic Squares}\\
// A \href{https://en.wikipedia.org/wiki/Magic_square}{magic square} is a
// \texttt{TSqMat} of $N\times N$ distinct integer numbers (i.e. each number
// used once), where the numbers in each row, and in each column, and the
// numbers in the main and secondary diagonals, all add up to the same number,
// a \emph{magic constant} (that magically is $ (n(n^2 + 1))/2$.
// A more general formula can be found
@juanfal
juanfal / pob.txt
Created Jan 8, 2019
Población en España a 1jul2018
View pob.txt
1jul2018 Valor Variación semestral
Población total 46733038 0.16
Hombres 22914086 0.14
Mujeres 23818952 0.18
Extranjeros 4663726 2.21
@juanfal
juanfal / happynumbers.cpp
Created Jan 2, 2019
Happy numbers in C+- Each new sum-of-sqared-digit is saved in an open array to check for it not being repeated. Finish either when repeated or when this sum is 1
View happynumbers.cpp
// happynumbers.cpp
// juanfc 2019-01-02
//
#include <iostream>
#include <array>
using namespace std;
struct TOpenVec {
int n;
@juanfal
juanfal / feliznumero.py
Last active Jan 1, 2019
Is a number happy? Print happy numbers up to 3000
View feliznumero.py
#!/usr/bin/env python3
# encoding: utf-8
# feliznumero.py
# juanfc 2019-01-01
def sumcuaddig(n):
s = 0
for dig in str(n):
dign = int(dig)
s += dign * dign
@juanfal
juanfal / tempsmaxmalaga.txt
Created Dec 18, 2018
Temperaturas en málaga
View tempsmaxmalaga.txt
2018-12-17T12:00:00 18.1
2018-12-17T13:00:00 17.7
2018-12-17T14:00:00 17.2
2018-12-17T15:00:00 17.0
2018-12-17T16:00:00 17.1
2018-12-17T17:00:00 16.7
2018-12-17T18:00:00 15.7
2018-12-17T19:00:00 15.3
2018-12-17T20:00:00 15.1
2018-12-17T21:00:00 14.8
@juanfal
juanfal / elipseImplicita.cpp
Last active Nov 7, 2018
Plot the implicit curve 9x2 + 4y2 = 3600
View elipseImplicita.cpp
// elipseImplicita.cpp
// juanfc 2016-11-04
// Plot the implicit curve:
// 9x2 + 4y2 = 3600
// It approximates as part of the curve, dots in the
// range of ALLOWANCE
// https://gist.github.com/fb15ff4fead7621813aa99c2f76c0152
#include <iostream>
You can’t perform that action at this time.