5
waldz
5y

!rant
Backward chaining algorithm in less than 20 lines, any bidder?

Comments
  • 1
    I read "blockchain algorithm" Oo
  • 2
    @Fast-Nop lol, i just noticed that, damn it "blockchain" everywhere
  • 1
    @irene hmmm didn't hear of that one as far as i can remember, my algo was just a "mini-project" AI teacher gave us, it's about expert systems... Anyway that sounds interesting, can you explain the riddle?
  • 1
    @irene yep it should solve it, in fact im gonna put to the test and see
  • 1
    @irene did it in python, so no, one statement, one line
  • 3
    @irene i heard of that, but the teacher is too lazy and a big asshole to let us use whatever tool we want, he said "do it in c or java only" (since he just copy/paste problems with solutions from the ancient history of other universities, got in a fight to finally use python
  • 2
    @irene he doesn't care since he has the solution (that i bet he doesn't even understand)
  • 1
    @irene i will for sure if he gives it to us
  • 2
    Bool backward(array<truth> truths, array<rule> rules, hypothesis) {
    Bool result = false;

    // Check if hypotesis is true
    For(truth:truths)
    If (truth(hypotesis))
    Return true;

    For(rule:rules)
    If(rule.isThen(hypothesis))
    // Remove rule to avoid circular logic
    If (Result = backward(truths, rules.remove(rule), rule.getIs()))
    Return true;
    Return result;
    }

    Sorry for:
    Phone
    Coding something i just read for 5 minutes about
    Not knowing terminology
    Bad coding
  • 1
Add Comment