-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add Integers into parser and solvers #36
Conversation
- added class CryptaConstant extending CryptaLeaf - test long multiplication - update all classes so that integers are treated as constants and in evaluation case are not added in the map of symbols - we can do long multiplications, there is a test for that taken from issue #22 ``` SEE * SO = ----- EMOO + MESS = ------ MIMEO ``` - test on long division - other thest have been taken from http://cryptarithms.awardspace.us/puzzles.html TODO : test for BigNum and add more tests for basic cases expecially negative tests
- Added method in CryptaConstant to convert decimal integer to integer in a given base in LittleEndian - BigNumModeler corrected method to add right integer to model in the wanted base (from config.arithBase) - Added tests on bignum with integers - Added tests with base change (both for bignum and normal solver)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- We must next check the formatting issue.
- Tests are good.
We must solve the issue related to constants:
- The word is enclosed by ticks.
- The number is not.
A simple solution is to define two methods :
getWord
without ticksformatWord
with ticks.
There may be more elegant solution
src/main/java/cryptator/solver/AbstractModelerNodeConsumer.java
Outdated
Show resolved
Hide resolved
|
||
@Override | ||
public void accept(ICryptaNode node, int numNode) { | ||
if (node.isLeaf() && !node.isConstant()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the helper function.
} | ||
|
||
private static void writeWord(ICryptaNode node, PrintWriter out) { | ||
if (node.isConstant()) out.write("'"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be the node that adds the ticks ?
try { | ||
BigInteger v = BigInteger.ZERO; | ||
final BigInteger b = BigInteger.valueOf(base); | ||
if (node instanceof CryptaConstant constant) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have chosen to add an attribute to the class.
Do not use both the attribute and instanceof.
I know that it allows to access the getConstant method, but we must find another way.
Breif summary:
Now we are able to parse and analyse long multiplications (see here) and long divisions (see here)