Skip to content

Instantly share code, notes, and snippets.

@juanfal
juanfal / t04e21.numwords.cpp
Created March 25, 2026 08:07
count words to . all in main
// t04e21.numwords.cpp
// juanfc 2026-03-25
//
#include <iostream>
using namespace std;
int main()
{
int wordCount = 0;
@juanfal
juanfal / t04e20.collatz.cpp
Created March 25, 2026 08:04
collatz sequence all in main
// t04e20.collatz.cpp
// juanfc 2026-03-25
//
#include <iostream>
using namespace std;
int main()
{
int n;
@juanfal
juanfal / t04e19.countdigits.cpp
Created March 25, 2026 08:02
count digits all in main
// t04e19.countdigits.cpp
// juanfc 2026-03-25
//
#include <iostream>
using namespace std;
int main()
{
int n;
@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;