Skip to content

Instantly share code, notes, and snippets.

@juanfal
juanfal / calendariolaboralaño.sh
Last active February 16, 2026 06:03
CAlendario laboral y festivo de Málaga (le he puesto yo!)El año se lo puedes pasar como argumento. La ciudad (Málaga es fácil de cambiar en el script por la que haga falta)
#!/bin/sh
# calendariolaboralaño.sh
# juanfal 2026-02-15
#https://gist.github.com/juanfal/c71b92a92c03a7584958fb9cc32ff667
cd ~/Desktop/
curryear=${1:-$(date +%Y)}
filename="calendario-laboral-malaga-${curryear}-PDF.pdf"
// t12e13.chemicalmolecules.cpp
// juanfc 2025-11-18
// Chemical compounds are made of many identical molecules. A molecule consists
// of a sequence (an array) of elements. These elements are atoms (e.g., Fe, H,
// Ni) repeated in the molecule. An integer indicates how many times that atom
// appears in the molecule. Each element (|TElement|) can therefore be a
// structure storing a string representing the atom (the letter Fe, H, etc.)
// together with its frequency (an integer in the range 1–9). A molecule
// (TMolecule) is then an open array of TElement of these .
// Write a function |TMolecule string2Molec(string s);| that parses the input
@juanfal
juanfal / t14e14.rotate.cpp
Last active December 16, 2025 07:44
rotate matrix
// t14e14.rotate.cpp
// juanfc 2025-12-16
// https://gist.github.com/juanfal/66dafa705d5fac43f1672315047d1d63
#include <iostream>
#include <iomanip>
#include <array>
using namespace std;
const int MAX = 5;
@juanfal
juanfal / primeDecomp.cpp
Created November 4, 2025 11:46
prime decomposition
// primeDecomposition.cpp
// juanfc 2025-11-04
// https://gist.github.com/juanfal/958a9859df5b0452e2063a100f91bb1f
#include <iostream>
#include <array>
using namespace std;
const int N = 10;
struct TPrime {
@juanfal
juanfal / 30.sumtwogreatests.cpp
Last active November 4, 2025 11:11
sum of two greatests
// 30.sumtwogreatests.cpp
// juanfc 2025-11-04
// https://gist.github.com/juanfal/303dd42d4919d12e1a181373c3053c31
#include <iostream>
#include <array>
using namespace std;
const int N = 5;
typedef array<int,N> TVec;
@juanfal
juanfal / 99.ordenarSelectInsertBub.cpp
Created November 4, 2025 11:08
SelectSort BubbleSort BubbleSortOpt ShakeSort InsertSort SelectSortIndex
// 99.ordenarSelectInsertBub.cpp
// juanfc 2025-11-04
//
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <array>
using namespace std;
@juanfal
juanfal / t9e06.minVec.cpp
Created November 3, 2025 17:39
min of an array
// t9e06.minVec.cpp
// juanfc 2023-11-14
//
#include <iostream>
#include <array>
using namespace std;
// consts
const int N=3;
@juanfal
juanfal / binomial.cpp
Created November 1, 2025 13:12
binomial numbers
// binomial.cpp
// juanfc 2025-11-01
//
#include <iostream>
using namespace std;
typedef long long unsigned TLong;
int main()
@juanfal
juanfal / ackerman.cpp
Last active November 1, 2025 12:50
Ackermann, heavily recursive function
// ackerman.cpp
// juanfc 2025-11-01
// ackermann(4, 0) -> 13
// ackermann(4, 1) -> 65533
// ackermann(4, 2) -> … 19,729 digits …
//
// https://gist.github.com/juanfal/79ca4e73649a5a0b3fe3fd82923f3e4e
#include <iostream>
using namespace std;
@juanfal
juanfal / gcdr.cpp
Created November 1, 2025 12:46
gcd recursive
// gcdr.cpp
// juanfc 2025-11-01
// Recursive solution of gcd
// gcd(a,b) = gcd(b,a) = gcd(a, a-b)
// gcd(a, 0) = a
// https://en.wikipedia.org/wiki/Euclidean_algorithm
//
#include <iostream>
using namespace std;