Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

26
LINES

< > BotCompany Repo | #1021187 // Year Calc Spike (find, check and generalize equation in script, OK)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (7554L/54K).

!7

sS text = [[
  i started 5 years ago
  current year is 2019
  2019-5 = 2014
  i started in 2014
]];

p-exp {
  S text, SS map = unpair replaceNumbersWithABCDollarVars(main.text);
  map = reverseMap(map);
  print(text);
  printStruct(map);
  new Matches m;
  for (S s : tlft(text))
    if (jmatch("*-* = *", s, m)) pcall {
      print(s);
      S a = getOrKeep(map, $1), b = getOrKeep(map, $2), c = getOrKeep(map, $3);
      print(a + " - " + b + " = " + c);
      if (eq(minus(bigint(a), bigint(b)), bigint(c))) {
        print("  correct!");
        print("  so: " + $3 + " = " + $1 + " - " + $2);
      }
    }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1021187
Snippet name: Year Calc Spike (find, check and generalize equation in script, OK)
Eternal ID of this version: #1021187/8
Text MD5: 6947e9b81dc2f79c976b3c794e263521
Transpilation MD5: 43739fd3897eaf2e9bc9f283832c183b
Author: stefan
Category: javax
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-02 15:37:26
Source code size: 643 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 223 / 644
Version history: 7 change(s)
Referenced in: [show references]