This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
typedef struct { | |
double x; | |
double y; | |
} vec2d; | |
#define sum(X, Y) _Generic((X), \ | |
int: sum2l((X), (Y)), \ | |
long: sum2l((X), (Y)), \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{- | |
This code answers to "Un quesito con la Susi n. 923" | |
(a puzzle on an italian magazine). | |
Brute force, no optimization (and no Haskell guru here). | |
-} | |
import Data.List | |
checkSol :: [Int] -> Bool | |
checkSol a = | |
5*susi == gianni && (sum a) == (susi + gianni + tavolo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% gprolog: nth | |
% swi prolog: nth0 | |
vicino(List, A, B) :- | |
nth(IndexA, List, A), | |
nth(IndexB, List, B), | |
abs(IndexA - IndexB) =:= 1. | |
chi(Luca, Aldo, Berto) :- | |
vicino([4, 0, 2, 1, 3], Luca, Aldo), | |
vicino([1, 2, 3, 0, 4], Berto, Aldo), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
io "bufio" | |
"fmt" | |
"os" | |
"unicode" | |
) | |
type ControlFlow struct { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
io "bufio" | |
"fmt" | |
"os" | |
"sync" | |
"unicode" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern printf | |
extern getchar | |
extern isalpha | |
section .data | |