Skip to content

Conversation

@crossopt
Copy link
Collaborator

No description provided.

return order[::-1]


def fix_incorrect(words):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should be very slow... we should think how to make it faster

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, probably just me weirdly interpreting the assignment.

"maximal (with as many words as possible) subset of the dictionary".

Actually though, on my second read-through I still think that means that we should leave the overall max possible amount of words.

In that case, the problem is actually NP-hard (https://en.wikipedia.org/wiki/Feedback_arc_set), so it's unlikely we'll be able to think of anything substantially faster:)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we should try out different combinations indeed, but maybe instead of different word/dictionary combinations, we can try to build up paths and remove the nodes etc... ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it looks like we can't really improve it asymptotically.
@epinar: Do you have any more specific idea about how to implement removing only words from cycles?
Currently, graph has an information about the "successors" of a given letter, but we don't have any info about words representing this dependency. We could have this relation in a graph, but many different pairs of words could represent it, so it would be a huge drop of memory-efficiency.

order.append(v)


def _find_cycle(graph, start):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this function? How finding a shortest cycle will help us to solve the problem?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I think this is me being confused about the assignment.

I read "minimal set of constraints on the alphabet" as "least amount of letters that can't be ordered", which is basically "shortest cycle".

Whereas it probably was "set of constraints such that removing any of them makes the problem solvable".

Ouch.

from find_alphabet import is_correct, find_one_alphabet, find_incorrect, fix_incorrect


class TestDictionary(unittest.TestCase):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice tests!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed !


def _topsort(v, graph, used, order):
""" computes topsort of acyclic graph """
used.add(v)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should try to find a way to find maximal and minimal constraints during topsort -> how can we detect the cycle here?

from find_alphabet import is_correct, find_one_alphabet, find_incorrect, fix_incorrect


class TestDictionary(unittest.TestCase):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed !

return order[::-1]


def fix_incorrect(words):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we should try out different combinations indeed, but maybe instead of different word/dictionary combinations, we can try to build up paths and remove the nodes etc... ?

Copy link
Collaborator

@randomUsernameAndPassword randomUsernameAndPassword left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just fix that part with minimal set of constraints.

return order[::-1]


def fix_incorrect(words):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it looks like we can't really improve it asymptotically.
@epinar: Do you have any more specific idea about how to implement removing only words from cycles?
Currently, graph has an information about the "successors" of a given letter, but we don't have any info about words representing this dependency. We could have this relation in a graph, but many different pairs of words could represent it, so it would be a huge drop of memory-efficiency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants