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
/* | |
bison test 1 (single file), | |
widely based on examples in the bison manual at | |
http://www.gnu.org/software/bison/manual/ | |
It should compile with | |
$ bison mcalcpp.yy | |
$ g++ mcalcpp.tab.cc | |
or alike. (bison v>3.0; any C++98 compiler should go) | |
*/ |
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
incdir "include:" | |
include "exec/exec.i" | |
include "exec/exec_lib.i" | |
include "dos/dos_lib.i" | |
opt p=68020 | |
_start |
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
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
% 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
{- | |
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
/* | |
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
#! /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
#! /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
#include <iostream> | |
#include <numeric> | |
#include <vector> | |
using namespace std; | |
int main() | |
{ | |
vector<int> array = {1, 2, 3, 4, 5}; |
OlderNewer