Code Monkey home page Code Monkey logo

Comments (4)

ivanseed avatar ivanseed commented on July 17, 2024

Sorry, it is a bit hard to follow the code - also my Python is not the best.

There is a way you can figure out what inputs you are getting though; you probably already tried to use something like print m but whenever that line is executed it would throw back an error.

What you should do is try and figure out some properties of the matrix that is causing you to fail. If you were to put:

if (false)
   print 'Hello World'

It would not throw an error because that line of code will never be executed. So what you can do is;

if (m.length == 1)
    return NULL

This will cause all tests to fail where the map is a 1x1, see if you still have the same passing and failing tests as you did before.

If the same tests are failing then put;

if (m.length == 1)
    print 'I will cause an error'

Now if you get an error when you run this, then you know that the failing test is a 1x1 matrix. You can do this for NxN matrix to figure out what is causing your code to fail.

My advice is that most people forget about the case where the matrix is 1x1 (already in terminal state) and 2x2.

from google-foobar-help.

jimismash avatar jimismash commented on July 17, 2024

@ivanseed

I ran:
if len(m) == N:
return 0
or
if len(m) == N:
raise Exception("I will cause and error")
I cycled N from 0 through 10.
Using the return 0 I identified the length of every other test, and then using the "Exception" I was able to determine that the test I'm failing was not a unique length(unless it is longer than 10) test, i.e. I don't think my code has an issue with a specific size of matrix. I have the intuition that the test I'm failing involves a 10x10, but that's only based on tests 5 and 7-10 being 10x10.

I'm storing all of the numbers using the built in Fraction variable type which automatically handles the fraction reduction; I don't know if this could cause any issues with denominators being stored as signed 32-bit integer. I'm trying to think of other exception cases, but this is outside of my area of expertise.

You've been very helpful, thank you for your time!

If it helps at all, one of my previous attempts involved solving systems of multiple equations. The best I could do with that approach was passing 7/10 tests.

from google-foobar-help.

ivanseed avatar ivanseed commented on July 17, 2024

Mmm you could also test if that the Matrix at m[0] is of terminal state. Meaning that the first state is the terminal state. It should be all zeros. If it is not that then maybe it is just how you are storing fractions. But check if m[0] contains only 0s.

from google-foobar-help.

jimismash avatar jimismash commented on July 17, 2024

@ivanseed ,

I still didn't pass test six, but detecting S0 as a terminal state was something that my code was not doing. It's probably for the best, classes are starting on Monday so I won't have time to fool around with the harder challenges anyway.

I appreciate all the help you have provided, especially the rundown on Markov Chains.

from google-foobar-help.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.