Skip to content

Commit d460849

Browse files
authored
Merge pull request #44 from arnaud-m/words
Add more word lists and scripts close #40 close #43
2 parents 3b16e66 + 8a7d0b4 commit d460849

35 files changed

+3151
-43
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,15 @@
148148
<prurl>${project.url}</prurl>
149149
</properties>
150150
<mapping>
151+
<R>SCRIPT_STYLE</R>
152+
<g4>DOUBLESLASH_STYLE</g4>
151153
<template>JAVADOC_STYLE</template>
152154
</mapping>
153155
<includes>
154156
<include>src/*/java/**/*.java</include>
157+
<include>src/*/antlr4/**/*.g4</include>
158+
<include>src/*/shell/**/*.sh</include>
159+
<include>src/*/R/**/*.R</include>
155160
<include>**/pom.xml</include>
156161
</includes>
157162
</configuration>

src/main/R/sample-words.R

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#!/usr/bin/Rscript
2+
#
3+
# This file is part of cryptator, https://github.com/arnaud-m/cryptator
4+
#
5+
# Copyright (c) 2022, Université Côte d'Azur. All rights reserved.
6+
#
7+
# Licensed under the BSD 3-clause license.
8+
# See LICENSE file in the project root for full license information.
9+
#
10+
211

312

413
ScanWords <- function(file) scan(file = file, what = character(), quiet = TRUE)

src/main/antlr4/Cryptator.g4

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
//
2+
// This file is part of cryptator, https://github.com/arnaud-m/cryptator
3+
//
4+
// Copyright (c) 2022, Université Côte d'Azur. All rights reserved.
5+
//
6+
// Licensed under the BSD 3-clause license.
7+
// See LICENSE file in the project root for full license information.
8+
//
9+
110
grammar Cryptator;
211

312
@header{

src/main/shell/clean-words-list.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/main/shell/demo-generate.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#!/bin/sh
2+
#
3+
# This file is part of cryptator, https://github.com/arnaud-m/cryptator
4+
#
5+
# Copyright (c) 2022, Université Côte d'Azur. All rights reserved.
6+
#
7+
# Licensed under the BSD 3-clause license.
8+
# See LICENSE file in the project root for full license information.
9+
#
10+
211
## sh demo-generate.sh > demo-generate-output.md
312
JAR="../../../target/cryptator-*-with-dependencies.jar"
413
DIR="../words"
@@ -12,7 +21,7 @@ function solve() {
1221
echo "# Search cryptarithms with a UNIQUE solution"
1322

1423
######
15-
echo -e "\n## Generate from a word list\n"
24+
echo -e "\n## Generate from a words list\n"
1625

1726
echo "- Planets"
1827
solve $DIR/planets.txt

src/main/shell/demo-play.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#!/bin/sh
2+
#
3+
# This file is part of cryptator, https://github.com/arnaud-m/cryptator
4+
#
5+
# Copyright (c) 2022, Université Côte d'Azur. All rights reserved.
6+
#
7+
# Licensed under the BSD 3-clause license.
8+
# See LICENSE file in the project root for full license information.
9+
#
10+
211
JAR="../../../target/cryptator-*-with-dependencies.jar"
312

413
java -cp $JAR cryptator.Cryptamancer 'send+more=money'

src/main/shell/demo-solve.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
#!/bin/sh
2+
#
3+
# This file is part of cryptator, https://github.com/arnaud-m/cryptator
4+
#
5+
# Copyright (c) 2022, Université Côte d'Azur. All rights reserved.
6+
#
7+
# Licensed under the BSD 3-clause license.
8+
# See LICENSE file in the project root for full license information.
9+
#
10+
211
JAR="../../../target/cryptator-*-with-dependencies.jar"
312
CMD="java -cp $JAR cryptator.Cryptator -c TRUE -g TRUE"
413

src/main/shell/format-word-list.sh

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/bin/sh
2+
#
3+
# This file is part of cryptator, https://github.com/arnaud-m/cryptator
4+
#
5+
# Copyright (c) 2022, Université Côte d'Azur. All rights reserved.
6+
#
7+
# Licensed under the BSD 3-clause license.
8+
# See LICENSE file in the project root for full license information.
9+
#
10+
11+
#--------------------------------------------------------------------
12+
# Setup Global Variables
13+
#--------------------------------------------------------------------
14+
15+
PROG=`basename $0`
16+
OVERWRITE=0
17+
#--------------------------------------------------------------------
18+
# Version and help messages
19+
#--------------------------------------------------------------------
20+
21+
22+
version() {
23+
cat <<EOF
24+
$PROG 0.1
25+
26+
This file is part of cryptator, https://github.com/arnaud-m/cryptator
27+
28+
Copyright (c) 2022, Université Côte d'Azur. All rights reserved.
29+
30+
Licensed under the BSD 3-clause license.
31+
See LICENSE file in the project root for full license information.
32+
EOF
33+
}
34+
35+
help() {
36+
cat <<EOF
37+
$PROG formats a word list.
38+
39+
$PROG formats a word list and output its results into a file.
40+
It removes diacritics, non-alphanumeric and whitespace characters, and then sort the word list while eliminating duplicates.
41+
By default, the output file is renamed by adding the suffix '.clean', but an option can force overwrite..
42+
43+
Usage: $PROG [OPTION] FILES...
44+
45+
Options:
46+
-f force overwriting the original file instead of adding it a suffix.
47+
48+
-h display this help and exit
49+
-v output version information and exit
50+
51+
Example:
52+
$PROG planets.txt
53+
54+
Report bugs to <arnaud (dot) malapert (at) univ-cotedazur (dot) fr>."
55+
EOF
56+
}
57+
58+
#--------------------------------------------------------------------
59+
# Test for prerequisites
60+
#--------------------------------------------------------------------
61+
62+
while getopts ":hvf" opt; do
63+
case $opt in
64+
f)
65+
OVERWRITE=1
66+
;;
67+
h)
68+
help
69+
exit 0
70+
;;
71+
v)
72+
version;
73+
exit 0
74+
;;
75+
\?)
76+
echo "Invalid option: -$OPTARG" >&2
77+
exit 1
78+
;;
79+
:)
80+
echo "Option -$OPTARG requires an argument." >&2
81+
exit 1
82+
;;
83+
esac
84+
done
85+
86+
shift $((OPTIND-1))
87+
#--------------------------------------------------------------------
88+
# Do something
89+
#--------------------------------------------------------------------
90+
91+
## Create temporary filenames
92+
TMP1=`mktemp`
93+
TMP2=`mktemp`
94+
95+
96+
97+
for FILE in $* ; do
98+
if [ -f $FILE ] && [ -r $FILE ] ; then
99+
echo "Process $FILE"
100+
## Set output filename
101+
if [ $OVERWRITE -ne 0 ] ; then
102+
echo "Overwrite $FILE"
103+
OUTFILE=$FILE
104+
else
105+
OUTFILE=$FILE.clean
106+
fi
107+
## Remove all diacritics
108+
## https://stackoverflow.com/questions/10207354/how-to-remove-all-of-the-diacritics-from-a-file
109+
cat $FILE | iconv -f utf8 -t ascii//TRANSLIT//IGNORE > $TMP1
110+
## Convert to lowercase
111+
cat $TMP1 | tr '[:upper:]' '[:lower:]' > $TMP2
112+
## Remove non alphanumerics and blank lines
113+
sed -e 's/[^a-z0-9]//g' -e '/^[[:space:]]*$/d' $TMP2 > $TMP1
114+
## Remove duplicates
115+
sort -u $TMP1 > $OUTFILE
116+
else
117+
echo "Ignore $FILE"
118+
fi
119+
120+
121+
done
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Doubly true cryptarithms between 1 and 100
2+
- en
3+
- one + two + five + nine + eleven + twelve + fifty = ninety
4+
- one + five + ten + eleven + nineteen + fortyfive = ninetyone
5+
- one + nine + twenty + fifty = eighty
6+
- five + seven + eleven + twelve + fifteen + twenty = seventy
7+
- three + seven + ten + twenty + thirty = seventy
8+
- one + seven + nine + fifteen + sixteen + seventeen = sixtyfive
9+
- two + fourteen + fifteen + twenty = fiftyone
10+
- three + nine + ten + fourteen + fifteen = fiftyone
11+
- six + nine + eleven + sixteen + nineteen = sixtyone
12+
- six + seven + nine + twelve + sixteen + twenty = seventy
13+
- five + six + sixteen + nineteen + twenty = sixtysix
14+
- eight + ten + sixteen + seventeen + eighteen = sixtynine
15+
- hi
16+
- सात + सैंतीस + चालीस = चौरासी
17+
- तीन + सात + बीस + उनतीस + तीस = नवासी
18+
- सात + बीस + पच्चीस + बत्तीस = चौरासी
19+
- एक + बीस + उनतीस + तीस = अस्सी
20+
- चार + बीस + चौबीस + छत्तीस = चौरासी
21+
- चार + चौबीस + छब्बीस + तीस = चौरासी
22+
- चार + सात + चौबीस + उनचास = चौरासी
23+
- सात + बारह + बीस + तैंतीस = बहत्तर
24+
- सात + बारह + छब्बीस + बत्तीस = सतहत्तर
25+
- सात + बारह + सत्रह + छत्तीस = बहत्तर
26+
- तीन + छह + सात + उन्नीस + बीस + बत्तीस = सत्तासी
27+
- तीन + छह + सात + सत्रह + छत्तीस = उनहत्तर
28+
- छह + बीस + चौबीस + तीस = अस्सी
29+
- छह + तेरह + छब्बीस + बत्तीस = सतहत्तर
30+
- तीन + तेरह + बीस + छत्तीस = बहत्तर
31+
- छह + तेरह + बत्तीस + छत्तीस = सत्तासी
32+
- पाँच + सात + पच्चीस = सैंतीस
33+
- सात + आठ + सड़सठ = बयासी
34+
- चार + चालीस + बयालीस = छियासी
35+
- बीस + बाईस + बयालीस = चौरासी
36+
- तीन + चार + तेईस + पचपन = पचासी
37+
- छह + तेईस + छब्बीस + बत्तीस = सत्तासी
38+
- तीन + उन्नीस + उनतीस + बत्तीस = तिरासी
39+
- छह + सात + बारह + छब्बीस + बत्तीस = तिरासी
40+
- चार + सात + पैंतीस + सैंतीस = तिरासी
41+
- तीन + चार + सात + उनतीस + चालीस = तिरासी
42+
- चार + सत्रह + तीस + बत्तीस = तिरासी
43+
- चार + सात + बत्तीस + चालीस = तिरासी
44+
- सत्रह + तीस + छत्तीस = तिरासी
45+
- चार + सात + सत्रह + पच्चीस + तीस = तिरासी
46+
- तीन + नौ + तेरह + सत्रह + तीस = बहत्तर
47+
- नौ + सत्रह + बीस + छब्बीस = बहत्तर
48+
- तीन + नौ + तीस + चालीस = बयासी
49+
- तीन + इक्कीस + इकतीस + बत्तीस = सत्तासी
50+
- चार + बीस + तीस + इकतीस = पचासी
51+
- बीस + इक्कीस + बत्तीस = तिहत्तर
52+
- सात + दस + बीस + चौबीस + छब्बीस = सत्तासी
53+
- तीन + छह + दस + सत्रह + छत्तीस = बहत्तर
54+
- दस + छब्बीस + छत्तीस = बहत्तर
55+
- दस + इक्कीस + पच्चीस + इकतीस = सत्तासी
56+
- सात + नौ + बत्तीस + उनतालीस = सत्तासी
57+
- es
58+
- seis + catorce + setenta = noventa
59+
- tres + seis + siete + catorce + sesenta = noventa
60+
- tres + seis + siete + once + trece + veinte + treinta = noventa
61+
- dos + cinco + siete + doce + catorce + treinta = setenta
62+
- dos + once + trece + catorce + treinta = setenta
63+
- uno + dos + tres + cuatro + once + doce + trece + catorce = sesenta
64+
- uno + cuatro + cinco + seis + once + trece + treinta = setenta
65+
- cuatro + cinco + siete + catorce + treinta = sesenta
66+
- tres + cinco + seis + ocho + once + trece + catorce = sesenta
67+
- cero + seis + siete = trece
68+
- cero + uno + tres + cuatro + cinco + trece + catorce + treinta = setenta
69+
- cero + tres + seis + siete + once + trece + veinte = sesenta
70+
- cero + seis + siete + trece + catorce + veinte = sesenta
71+
- cero + seis + siete + trece + catorce + veinte + treinta = noventa
72+
- cero + uno + tres + veinticinco = veintinueve
73+
- fr
74+
- zero + un + trois + onze + quinze = trente
75+
- ar
76+
- ru
77+
- pt
78+
- cinco + seis + sete + oito + catorze + trinta = setenta
79+
- sete + oito + onze + catorze + trinta = setenta
80+
- seis + sete + oito + onze + dezoito + trinta = oitenta
81+
- cinco + oito + treze + catorze + vinte + trinta = noventa
82+
- onze + doze + treze + catorze + trinta = oitenta
83+
- zero + doze + dezoito + vinte + trinta = oitenta
84+
- nove + onze + doze + dezoito + trinta = oitenta
85+
- cinco + oito + dez + doze + treze + catorze + dezoito = oitenta
86+
- id
87+
- de
88+
- eins + zwei + sieben + sechzig = siebzig
89+
- tr
90+
- bes + on + oniki + elliuc = seksen
91+
- yedi + dokuz + onyedi + ondokuz = elliiki
92+
- iki + uc + oniki + otuz + otuzuc = seksen
93+
- sıfır + iki + bes + on + onbir + oniki + kırk = seksen
94+
- onbir + kırkbir = elliiki
95+
- oniki + ondokuz = otuzbir
96+
- sıfır + iki + oniki = ondort
97+
- iki + bes + sekiz + oniki + onsekiz = kırkbes
98+
- bir + iki + sekiz + oniki + onsekiz = kırkbir
99+
- dokuz + otuziki = kırkbir
100+
- sıfır + bir + iki + on + oniki + onbes + kırk = seksen
101+
- sıfır + iki + onbir + oniki + onbes + kırk = seksen
102+
- bes + sekiz + on + oniki + onbes + otuz = seksen
103+
- iki + on + onbes + elliuc = seksen
104+
- iki + bes + onbir + oniki + elli = seksen
105+
- bir + iki + oniki + onbes + elli = seksen
106+
- uc + oniki + onbes + elli = seksen
107+
- it
108+
- zero + sei + sette + otto + nove = trenta
109+
- due + sette + dieci + undici = trenta
110+
- tre + sei + dieci + undici = trenta
111+
- otto + nove + tredici + venti + trenta = ottanta
112+
- uno + due + tre + otto + undici + dodici + tredici + trenta = ottanta
113+
- uk
114+
- pl
115+
- ro
116+
- el
117+
- ενα + επτα + εννεα + εντεκα + δωδεκα = σαραντα
118+
- ενα + οκτω + εννεα + δωδεκα = τριαντα
119+
- μηδεν + ενα + εννεα + δεκα = εικοσι
120+
- ενα + τρια + πεντε + εντεκα + εικοσι = σαραντα
121+
- τρια + τεσσερα + δεκα + εντεκα + δωδεκα = σαραντα
122+
- τρια + τεσσερα + πεντε + επτα + εντεκα = τριαντα
123+
- ενα + τεσσερα + πεντε + εικοσι = τριαντα
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
#
3+
# This file is part of cryptator, https://github.com/arnaud-m/cryptator
4+
#
5+
# Copyright (c) 2022, Université Côte d'Azur. All rights reserved.
6+
#
7+
# Licensed under the BSD 3-clause license.
8+
# See LICENSE file in the project root for full license information.
9+
#
10+
11+
12+
## sh generate-doubly-true.sh > generate-doubly-true-output.md
13+
JAR="../../../target/cryptator-*-with-dependencies.jar"
14+
LANGUAGES=language-codes.csv
15+
MIN=1
16+
MAX=100
17+
18+
## Execute the command.
19+
## Filter the output: print only the cryptarithm.
20+
function solve() {
21+
java -cp $JAR cryptator.Cryptagen -c TRUE $* | sed -n 's/\(.*+.*=.*\)/ - \1/p'
22+
}
23+
24+
echo "# Doubly true cryptarithms between $MIN and $MAX"
25+
# Read the csf files with a list of country codes, and languages codes
26+
while IFS="," read ctry lang ; do
27+
echo "- $lang"
28+
# Search doubly true cryptarithms in the given language
29+
solve -ctry $ctry -lang $lang $MIN $MAX
30+
done < <(grep -v "^#\|^$" $LANGUAGES)

0 commit comments

Comments
 (0)