Skip to content

Instantly share code, notes, and snippets.

@juanfal
juanfal / 07.nword.cpp
Created November 15, 2024 17:29
word n of a string
// 07.nword.cpp
// juanfc 2024-11-15
//
#include <iostream>
using namespace std;
int main()
{
string wordn(string s, int n);
@juanfal
juanfal / substrneg.cpp
Last active November 11, 2024 11:32
substrneg
// substrneg.cpp
// juanfc 2024-11-11
// https://gist.github.com/juanfal/fe6f9f7369ff4358c80725781949a6ca
#include <iostream>
using namespace std;
int main()
{
void tryThis(string s, int from, int end=-1);
@juanfal
juanfal / 00.basicArraySubprograms.cpp
Created November 4, 2024 10:02
basic array subprograms
// 00.basicArraySubprograms.cpp
// juanfc 2024-11-04
//
#include <iostream>
#include <array>
using namespace std;
// consts
const int N=5;
@juanfal
juanfal / 00.quickinit.cpp
Created October 30, 2024 16:30
array quick init
#include <iostream>
#include <array>
using namespace std;
//
const int N = 3;
typedef array<int,N> TList;
int sum(TList v);
@juanfal
juanfal / hanoi.cpp
Created October 23, 2024 20:02
Hanoi towers recursion
// hanoi.cpp
// juanfc 2024-10-23
//
#include <iostream>
using namespace std;
// prototypes
int main()
{
@juanfal
juanfal / t04e04.amicable.cpp
Last active October 27, 2024 20:12
amicable numbers
// t04e04.amicable.cpp
// juanfc 2024-10-23
// amicable numbers
// 284 220
// 1210 1184
// 2924 2620
// 5564 5020
// 6368 6232
// https://gist.github.com/juanfal/e235970d086c69b1d87db0a37c02c895
@juanfal
juanfal / t03e3.nprimes.cpp
Created October 23, 2024 12:59
primes first n function
// t03e3.nprimes.cpp
// juanfc 2024-10-23
//
#include <iostream>
using namespace std;
int main()
{
bool isPrime(int n);
@juanfal
juanfal / 04.fexp.cpp
Last active October 23, 2024 12:50
expr series with functions. Two ways
// 01.exp.cpp
// juanfc 2024-10-23
// expr series with functions. Two ways
// https://en.wikipedia.org/wiki/Taylor_series
// https://gist.github.com/juanfal/99504b4df2590c909b91a7ead0e96c5c
#include <iostream>
using namespace std;
@juanfal
juanfal / l04e01.trianglenum.cpp
Created October 23, 2024 12:28
triangle of numbers non-consecutive function
// l04e01.trianglenum.cpp
// juanfc 2024-10-23
//
//
// \Ej Build a procedure that receives from the main() program the height of the next numerical triangle and prints it:
// Height? 11
// 1
// 232
// 34543
@juanfal
juanfal / 02.exp.cpp
Last active October 22, 2024 18:46
exp n terms 3 calls
// 02.exp.cpp
// juanfc 2024-10-22
// calculate the factorial directly by adding n terms
// of its series development
// Look at https://en.wikipedia.org/wiki/Taylor_series
// https://gist.github.com/juanfal/2b9d94a665b6f730a79a84c98e2d62a6
#include <iostream>
using namespace std;