Skip to content

Add more word lists and scripts #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Nov 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,15 @@
<prurl>${project.url}</prurl>
</properties>
<mapping>
<R>SCRIPT_STYLE</R>
<g4>DOUBLESLASH_STYLE</g4>
<template>JAVADOC_STYLE</template>
</mapping>
<includes>
<include>src/*/java/**/*.java</include>
<include>src/*/antlr4/**/*.g4</include>
<include>src/*/shell/**/*.sh</include>
<include>src/*/R/**/*.R</include>
<include>**/pom.xml</include>
</includes>
</configuration>
Expand Down
9 changes: 9 additions & 0 deletions src/main/R/sample-words.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#!/usr/bin/Rscript
#
# This file is part of cryptator, https://github.com/arnaud-m/cryptator
#
# Copyright (c) 2022, Université Côte d'Azur. All rights reserved.
#
# Licensed under the BSD 3-clause license.
# See LICENSE file in the project root for full license information.
#



ScanWords <- function(file) scan(file = file, what = character(), quiet = TRUE)
Expand Down
9 changes: 9 additions & 0 deletions src/main/antlr4/Cryptator.g4
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
//
// This file is part of cryptator, https://github.com/arnaud-m/cryptator
//
// Copyright (c) 2022, Université Côte d'Azur. All rights reserved.
//
// Licensed under the BSD 3-clause license.
// See LICENSE file in the project root for full license information.
//

grammar Cryptator;

@header{
Expand Down
16 changes: 0 additions & 16 deletions src/main/shell/clean-words-list.sh

This file was deleted.

11 changes: 10 additions & 1 deletion src/main/shell/demo-generate.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#!/bin/sh
#
# This file is part of cryptator, https://github.com/arnaud-m/cryptator
#
# Copyright (c) 2022, Université Côte d'Azur. All rights reserved.
#
# Licensed under the BSD 3-clause license.
# See LICENSE file in the project root for full license information.
#

## sh demo-generate.sh > demo-generate-output.md
JAR="../../../target/cryptator-*-with-dependencies.jar"
DIR="../words"
Expand All @@ -12,7 +21,7 @@ function solve() {
echo "# Search cryptarithms with a UNIQUE solution"

######
echo -e "\n## Generate from a word list\n"
echo -e "\n## Generate from a words list\n"

echo "- Planets"
solve $DIR/planets.txt
Expand Down
9 changes: 9 additions & 0 deletions src/main/shell/demo-play.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#!/bin/sh
#
# This file is part of cryptator, https://github.com/arnaud-m/cryptator
#
# Copyright (c) 2022, Université Côte d'Azur. All rights reserved.
#
# Licensed under the BSD 3-clause license.
# See LICENSE file in the project root for full license information.
#

JAR="../../../target/cryptator-*-with-dependencies.jar"

java -cp $JAR cryptator.Cryptamancer 'send+more=money'
9 changes: 9 additions & 0 deletions src/main/shell/demo-solve.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#!/bin/sh
#
# This file is part of cryptator, https://github.com/arnaud-m/cryptator
#
# Copyright (c) 2022, Université Côte d'Azur. All rights reserved.
#
# Licensed under the BSD 3-clause license.
# See LICENSE file in the project root for full license information.
#

JAR="../../../target/cryptator-*-with-dependencies.jar"
CMD="java -cp $JAR cryptator.Cryptator -c TRUE -g TRUE"

Expand Down
121 changes: 121 additions & 0 deletions src/main/shell/format-word-list.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!/bin/sh
#
# This file is part of cryptator, https://github.com/arnaud-m/cryptator
#
# Copyright (c) 2022, Université Côte d'Azur. All rights reserved.
#
# Licensed under the BSD 3-clause license.
# See LICENSE file in the project root for full license information.
#

#--------------------------------------------------------------------
# Setup Global Variables
#--------------------------------------------------------------------

PROG=`basename $0`
OVERWRITE=0
#--------------------------------------------------------------------
# Version and help messages
#--------------------------------------------------------------------


version() {
cat <<EOF
$PROG 0.1

This file is part of cryptator, https://github.com/arnaud-m/cryptator

Copyright (c) 2022, Université Côte d'Azur. All rights reserved.

Licensed under the BSD 3-clause license.
See LICENSE file in the project root for full license information.
EOF
}

help() {
cat <<EOF
$PROG formats a word list.

$PROG formats a word list and output its results into a file.
It removes diacritics, non-alphanumeric and whitespace characters, and then sort the word list while eliminating duplicates.
By default, the output file is renamed by adding the suffix '.clean', but an option can force overwrite..

Usage: $PROG [OPTION] FILES...

Options:
-f force overwriting the original file instead of adding it a suffix.

-h display this help and exit
-v output version information and exit

Example:
$PROG planets.txt

Report bugs to <arnaud (dot) malapert (at) univ-cotedazur (dot) fr>."
EOF
}

#--------------------------------------------------------------------
# Test for prerequisites
#--------------------------------------------------------------------

while getopts ":hvf" opt; do
case $opt in
f)
OVERWRITE=1
;;
h)
help
exit 0
;;
v)
version;
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done

shift $((OPTIND-1))
#--------------------------------------------------------------------
# Do something
#--------------------------------------------------------------------

## Create temporary filenames
TMP1=`mktemp`
TMP2=`mktemp`



for FILE in $* ; do
if [ -f $FILE ] && [ -r $FILE ] ; then
echo "Process $FILE"
## Set output filename
if [ $OVERWRITE -ne 0 ] ; then
echo "Overwrite $FILE"
OUTFILE=$FILE
else
OUTFILE=$FILE.clean
fi
## Remove all diacritics
## https://stackoverflow.com/questions/10207354/how-to-remove-all-of-the-diacritics-from-a-file
cat $FILE | iconv -f utf8 -t ascii//TRANSLIT//IGNORE > $TMP1
## Convert to lowercase
cat $TMP1 | tr '[:upper:]' '[:lower:]' > $TMP2
## Remove non alphanumerics and blank lines
sed -e 's/[^a-z0-9]//g' -e '/^[[:space:]]*$/d' $TMP2 > $TMP1
## Remove duplicates
sort -u $TMP1 > $OUTFILE
else
echo "Ignore $FILE"
fi


done
123 changes: 123 additions & 0 deletions src/main/shell/generate-doubly-true-output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Doubly true cryptarithms between 1 and 100
- en
- one + two + five + nine + eleven + twelve + fifty = ninety
- one + five + ten + eleven + nineteen + fortyfive = ninetyone
- one + nine + twenty + fifty = eighty
- five + seven + eleven + twelve + fifteen + twenty = seventy
- three + seven + ten + twenty + thirty = seventy
- one + seven + nine + fifteen + sixteen + seventeen = sixtyfive
- two + fourteen + fifteen + twenty = fiftyone
- three + nine + ten + fourteen + fifteen = fiftyone
- six + nine + eleven + sixteen + nineteen = sixtyone
- six + seven + nine + twelve + sixteen + twenty = seventy
- five + six + sixteen + nineteen + twenty = sixtysix
- eight + ten + sixteen + seventeen + eighteen = sixtynine
- hi
- सात + सैंतीस + चालीस = चौरासी
- तीन + सात + बीस + उनतीस + तीस = नवासी
- सात + बीस + पच्चीस + बत्तीस = चौरासी
- एक + बीस + उनतीस + तीस = अस्सी
- चार + बीस + चौबीस + छत्तीस = चौरासी
- चार + चौबीस + छब्बीस + तीस = चौरासी
- चार + सात + चौबीस + उनचास = चौरासी
- सात + बारह + बीस + तैंतीस = बहत्तर
- सात + बारह + छब्बीस + बत्तीस = सतहत्तर
- सात + बारह + सत्रह + छत्तीस = बहत्तर
- तीन + छह + सात + उन्नीस + बीस + बत्तीस = सत्तासी
- तीन + छह + सात + सत्रह + छत्तीस = उनहत्तर
- छह + बीस + चौबीस + तीस = अस्सी
- छह + तेरह + छब्बीस + बत्तीस = सतहत्तर
- तीन + तेरह + बीस + छत्तीस = बहत्तर
- छह + तेरह + बत्तीस + छत्तीस = सत्तासी
- पाँच + सात + पच्चीस = सैंतीस
- सात + आठ + सड़सठ = बयासी
- चार + चालीस + बयालीस = छियासी
- बीस + बाईस + बयालीस = चौरासी
- तीन + चार + तेईस + पचपन = पचासी
- छह + तेईस + छब्बीस + बत्तीस = सत्तासी
- तीन + उन्नीस + उनतीस + बत्तीस = तिरासी
- छह + सात + बारह + छब्बीस + बत्तीस = तिरासी
- चार + सात + पैंतीस + सैंतीस = तिरासी
- तीन + चार + सात + उनतीस + चालीस = तिरासी
- चार + सत्रह + तीस + बत्तीस = तिरासी
- चार + सात + बत्तीस + चालीस = तिरासी
- सत्रह + तीस + छत्तीस = तिरासी
- चार + सात + सत्रह + पच्चीस + तीस = तिरासी
- तीन + नौ + तेरह + सत्रह + तीस = बहत्तर
- नौ + सत्रह + बीस + छब्बीस = बहत्तर
- तीन + नौ + तीस + चालीस = बयासी
- तीन + इक्कीस + इकतीस + बत्तीस = सत्तासी
- चार + बीस + तीस + इकतीस = पचासी
- बीस + इक्कीस + बत्तीस = तिहत्तर
- सात + दस + बीस + चौबीस + छब्बीस = सत्तासी
- तीन + छह + दस + सत्रह + छत्तीस = बहत्तर
- दस + छब्बीस + छत्तीस = बहत्तर
- दस + इक्कीस + पच्चीस + इकतीस = सत्तासी
- सात + नौ + बत्तीस + उनतालीस = सत्तासी
- es
- seis + catorce + setenta = noventa
- tres + seis + siete + catorce + sesenta = noventa
- tres + seis + siete + once + trece + veinte + treinta = noventa
- dos + cinco + siete + doce + catorce + treinta = setenta
- dos + once + trece + catorce + treinta = setenta
- uno + dos + tres + cuatro + once + doce + trece + catorce = sesenta
- uno + cuatro + cinco + seis + once + trece + treinta = setenta
- cuatro + cinco + siete + catorce + treinta = sesenta
- tres + cinco + seis + ocho + once + trece + catorce = sesenta
- cero + seis + siete = trece
- cero + uno + tres + cuatro + cinco + trece + catorce + treinta = setenta
- cero + tres + seis + siete + once + trece + veinte = sesenta
- cero + seis + siete + trece + catorce + veinte = sesenta
- cero + seis + siete + trece + catorce + veinte + treinta = noventa
- cero + uno + tres + veinticinco = veintinueve
- fr
- zero + un + trois + onze + quinze = trente
- ar
- ru
- pt
- cinco + seis + sete + oito + catorze + trinta = setenta
- sete + oito + onze + catorze + trinta = setenta
- seis + sete + oito + onze + dezoito + trinta = oitenta
- cinco + oito + treze + catorze + vinte + trinta = noventa
- onze + doze + treze + catorze + trinta = oitenta
- zero + doze + dezoito + vinte + trinta = oitenta
- nove + onze + doze + dezoito + trinta = oitenta
- cinco + oito + dez + doze + treze + catorze + dezoito = oitenta
- id
- de
- eins + zwei + sieben + sechzig = siebzig
- tr
- bes + on + oniki + elliuc = seksen
- yedi + dokuz + onyedi + ondokuz = elliiki
- iki + uc + oniki + otuz + otuzuc = seksen
- sıfır + iki + bes + on + onbir + oniki + kırk = seksen
- onbir + kırkbir = elliiki
- oniki + ondokuz = otuzbir
- sıfır + iki + oniki = ondort
- iki + bes + sekiz + oniki + onsekiz = kırkbes
- bir + iki + sekiz + oniki + onsekiz = kırkbir
- dokuz + otuziki = kırkbir
- sıfır + bir + iki + on + oniki + onbes + kırk = seksen
- sıfır + iki + onbir + oniki + onbes + kırk = seksen
- bes + sekiz + on + oniki + onbes + otuz = seksen
- iki + on + onbes + elliuc = seksen
- iki + bes + onbir + oniki + elli = seksen
- bir + iki + oniki + onbes + elli = seksen
- uc + oniki + onbes + elli = seksen
- it
- zero + sei + sette + otto + nove = trenta
- due + sette + dieci + undici = trenta
- tre + sei + dieci + undici = trenta
- otto + nove + tredici + venti + trenta = ottanta
- uno + due + tre + otto + undici + dodici + tredici + trenta = ottanta
- uk
- pl
- ro
- el
- ενα + επτα + εννεα + εντεκα + δωδεκα = σαραντα
- ενα + οκτω + εννεα + δωδεκα = τριαντα
- μηδεν + ενα + εννεα + δεκα = εικοσι
- ενα + τρια + πεντε + εντεκα + εικοσι = σαραντα
- τρια + τεσσερα + δεκα + εντεκα + δωδεκα = σαραντα
- τρια + τεσσερα + πεντε + επτα + εντεκα = τριαντα
- ενα + τεσσερα + πεντε + εικοσι = τριαντα
30 changes: 30 additions & 0 deletions src/main/shell/generate-doubly-true.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh
#
# This file is part of cryptator, https://github.com/arnaud-m/cryptator
#
# Copyright (c) 2022, Université Côte d'Azur. All rights reserved.
#
# Licensed under the BSD 3-clause license.
# See LICENSE file in the project root for full license information.
#


## sh generate-doubly-true.sh > generate-doubly-true-output.md
JAR="../../../target/cryptator-*-with-dependencies.jar"
LANGUAGES=language-codes.csv
MIN=1
MAX=100

## Execute the command.
## Filter the output: print only the cryptarithm.
function solve() {
java -cp $JAR cryptator.Cryptagen -c TRUE $* | sed -n 's/\(.*+.*=.*\)/ - \1/p'
}

echo "# Doubly true cryptarithms between $MIN and $MAX"
# Read the csf files with a list of country codes, and languages codes
while IFS="," read ctry lang ; do
echo "- $lang"
# Search doubly true cryptarithms in the given language
solve -ctry $ctry -lang $lang $MIN $MAX
done < <(grep -v "^#\|^$" $LANGUAGES)
Loading