-
Notifications
You must be signed in to change notification settings - Fork 0
Crossopt 5 #29
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
base: master
Are you sure you want to change the base?
Crossopt 5 #29
Conversation
| return order[::-1] | ||
|
|
||
|
|
||
| def fix_incorrect(words): |
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.
This function should be very slow... we should think how to make it faster
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.
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:)
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.
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... ?
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.
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): |
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.
What is the purpose of this function? How finding a shortest cycle will help us to solve the problem?
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.
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): |
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.
Nice tests!
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.
Indeed !
|
|
||
| def _topsort(v, graph, used, order): | ||
| """ computes topsort of acyclic graph """ | ||
| used.add(v) |
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.
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): |
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.
Indeed !
| return order[::-1] | ||
|
|
||
|
|
||
| def fix_incorrect(words): |
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.
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... ?
randomUsernameAndPassword
left a comment
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.
I would just fix that part with minimal set of constraints.
| return order[::-1] | ||
|
|
||
|
|
||
| def fix_incorrect(words): |
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.
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.
No description provided.