Skip to content

Instantly share code, notes, and snippets.

View shintakezou's full-sized avatar

Mauro Panigada shintakezou

View GitHub Profile
@shintakezou
shintakezou / test-json-p6-grammar.p6
Last active November 7, 2018 17:39
My first attempt to write and use Perl6 grammars; it seems to work (but it isn't tested extensively)
use v6.c;
# based on my original attempt, enhanced with protos
# and ideas from https://github.com/moritz/json
grammar JSON-Grammar
{
token TOP { \s* <json-value> \s* }
proto token json-value { * }
@shintakezou
shintakezou / susi948.f03
Last active February 11, 2018 12:36
Bruteforcing towards the solution for "Quesito con la Susi n. 948" from an Italian magazine.
! Find the solution for the problem
! "Quesito con la Susi n. 948"
! from Italian magazine "La Settimana Enigmistica".
! Brute force, as usual.
!
! Find
! n = 3*y0 + y1 + y2 + y3 + y4 + y5 + y6
! so that
! y(i) is between 4 and 10 included
! (hence n is between 36 and 90 included)
@shintakezou
shintakezou / susi946b.cpp
Created November 25, 2017 14:46
This is like another gist (https://gist.github.com/shintakezou/aab5d6c3a76689a6370ab6477f8cff2e) but it uses more lambdas...
/* This trivially solves a quiz on the Italian magazine
"La Settimana Enigmistica", namely
"Quesito con la Susi n. 946".
It uses, without any special reason, >C++11
features.
Problem:
There are four friends (Giovanni, Marco, Simone, Elisa)
sat down behind a desk; Susi must say who's the shortest
@shintakezou
shintakezou / susi946.cpp
Last active November 25, 2017 14:45
Solving "Quesito con la Susi n. 946"
/* This trivially solves a quiz on the Italian magazine
"La Settimana Enigmistica", namely
"Quesito con la Susi n. 946".
It uses, without any special reason, >C++11
features.
Problem:
There are four friends (Giovanni, Marco, Simone, Elisa)
sat down behind a desk; Susi must say who's the shortest
#include <iostream>
#include <iomanip>
std::string gimme_a_str(const std::string& s)
{
return "string(\"" + s + "\")";
}
template<typename T>
void action_a(T& a)

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:

"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).
@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) ->
@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 / 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);