Skip to content

Instantly share code, notes, and snippets.

View shintakezou's full-sized avatar

Mauro Panigada shintakezou

View GitHub Profile
@shintakezou
shintakezou / generic.f90
Last active August 7, 2018 18:51
Type-generic functions' example in Fortran90
program generic_example
use my_sum_module
implicit none
print *, my_sum(1.0, 3.0) ! 1 + 1.5
print *, my_sum(1, 5) ! 1 + 2
print *, my_sum(2, 3.0) ! 2 + 1.5
print *, my_sum(1.5, 7) ! 1.5 + 3.5
@shintakezou
shintakezou / dudeney_miller.cpp
Last active August 29, 2015 14:26
This code solves Dudeney's "The Miller's puzzle"
/*
this code solves one of the Dudeney's Canterbury Puzzles,
namely The Miller's Puzzle.
My input was an italian blog, i.e.
http://rudimatematici-lescienze.blogautore.espresso.repubblica.it/2015/06/07/lenigma-del-mugnaio/
But you can find all the puzzles (thus even the miller's puzzle)
here:
@shintakezou
shintakezou / susi927.py
Last active September 13, 2015 17:05
Python(3) code to sieve solution(s) for “A quiz with Susi” n. 927
#! /usr/bin/python3
#
# italian magazine "La Settimana Enigmistica",
# quiz "Quesito con la Susi" n. 927
#
# R, B, S: prices of one bottle of red, white and sparkling wine
# a, b, c: number of sparkling (a), white (b) and red (c) wine in a
# box of seven bottles
#
# R = 3B
@shintakezou
shintakezou / susi927bis.py
Last active September 26, 2015 10:43
Solve Susi's puzzle n. 927 using logilab.constraint
#! /usr/bin/python
#
# see https://gist.github.com/shintakezou/666a96e63b0c01be2f78#file-susi927-py
# The problem is the same, but here we use logilab.constraint
# https://www.logilab.org/project/logilab-constraint
# and of course we take into account the fact that prices are integer
# positive numbers.
#
from logilab.constraint import *
@shintakezou
shintakezou / susi932.mf
Last active April 9, 2016 21:34
Find the solution of "Un quesito con la Susi 932" in METAFONT
%
% Problem from the Italian weekly magazine "La Settimana Enigmistica"
%
%
% Three couples divided their earnings (1000euro) from their
% second-hand clothes shop.
%
% The sum of the shares of the wives is 396.
%
% Giovanna (g) had 10e more than Carla (c);
@shintakezou
shintakezou / susi934.c
Created July 20, 2016 21:38
Solving Susi's problem 934 in the Italian magazine "La settimana enigmistica"
/*
A quiz with Susi 934 (in the Italian magazine
La settimana enigmistica)
Alfio, Biagio, Carlo and Dino are four children,
one of them broke the window of a building while
all four were playing with slingshots.
Questioned to know who did it,
@shintakezou
shintakezou / solve937.erl
Created November 5, 2016 23:50
solve A problem with Susi 937 from Italian magazine "La Settimana Enigmistica"
-module(solve937).
-export([solve/0]).
% This solve the following problem:
% find that number X < 54, so X^2 = A + B,
% where A is the number made of the first
% 2 digits of X^2 and B is the number made
% of the last 2 digits of X^2.
check(X) ->
"This solves an Italian magazine's quiz, n. 939;
you need an implementation for permutationsDo,
see miscellanea/gnusmalltalk/permutationsDo.st."
|p1 p2 p3 names perm0 bl1 bl2 bl3|
p1 := #(2 1 4 3 5).
p2 := #(3 4 5 1 2).
p3 := #(1 5 3 2 4).

Keybase proof

I hereby claim:

  • I am shintakezou on github.
  • I am shintakezou (https://keybase.io/shintakezou) on keybase.
  • I have a public key whose fingerprint is 33C0 6022 DBE2 3B53 1815 AA92 A3D2 1F30 08B6 929F

To claim this, I am signing this object:

#include <iostream>
#include <iomanip>
std::string gimme_a_str(const std::string& s)
{
return "string(\"" + s + "\")";
}
template<typename T>
void action_a(T& a)