|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
Well, the fastest way to learn Symfony (PHP) is googling for "[Tuts Plus] Build a CMS in Symfony 2 Video Tutorial-KTR" (you can find it in the "Good Stores"TM ). This shouldn't take you more than a couple of evenings and it'll be a lot easier to grasp the basics of the framework (and also lay some groundwork for most common stuff done in PHP outside of WP plugins - CMS). After that I'd focus on following the symfony website (switching to Symfony3) for the cookbooks. With those in hand your goal should be to try and create some of the same stuff you built in the Odin course, but on your own with Symfony. This way you'll have some sense of direction and do something worthwhile instead of following PHP 101 Tutorial #98375893475.
If you get lost or need any help just ask here.
It's not really possible to give you any definitive list of stuff you just have to read (apart from the general programming guides and books like Clean Code and Code Complete which are good for any language). Just let us know when you get stuck on some of the intermediate-advanced stuff like dynamic forms, data transformers etc. (or anything you get stuck on)
Some advice for starters:
RoR: RailsCasts is awesome. https://github.com/bbatsov/ruby-style-guide - learn it https://github.com/railsbp/rails_best_practices - use it https://github.com/bbatsov/rubocop - use it
PHP: https://github.com/squizlabs/PHP_CodeSniffer - use it
Will add more if you need it.
|
Okay, great, thank you so much! I'll get back to doing some serious studying now, bookmarking this to look into more during a break. ^^
edit: One more question I just thought of before going to bed. It has been stressed by many of the people I've talked with that I should specialize in something. What should be my overall methodology when specializing? When should I be looking at specializing? What are good options for specializing in? How do I decide which option to specialize in? How should I maintain this specialization?
By one more question... I meant... one more stream of questions. ^^'
|
On December 27 2016 11:39 3FFA wrote: Okay, great, thank you so much! I'll get back to doing some serious studying now, bookmarking this to look into more during a break. ^^
edit: One more question I just thought of before going to bed. It has been stressed by many of the people I've talked with that I should specialize in something. What should be my overall methodology when specializing? When should I be looking at specializing? What are good options for specializing in? How do I decide which option to specialize in? How should I maintain this specialization?
By one more question... I meant... one more stream of questions. ^^'
For now just focus on learning the ropes. Start thinking about specializing when you have several projects under your belt, preferably quite different ones, so that at least you know what brings you the most joy and what feels like a total chore 
If you have too much money on your hands you could always try something like Udacity's Nanodegrees: https://www.udacity.com/course/full-stack-web-developer-nanodegree--nd004
|
On December 27 2016 17:32 Manit0u wrote:Start thinking about specializing when you have several projects under your belt, preferably quite different ones, so that at least you know what brings you the most joy and what feels like a total chore  FWIW I agree with Mani big time on this. You don't need to worry about specializing in something just yet - spend a couple months figuring out what exactly it is you enjoy first. I feel like a lot of people focus way too much on 'what will be good for me?' when the real question should be 'what do I enjoy?'. If you find something you love developing in, and you can do great things with it, then you're set - doesn't really matter what it is.
|
|
ok, christmas visits from inlaws dying down so its back to working on my project
and, I need help, this is tough. I thought this would be easier than it is, haha
I need help conceptualizing how to write the pseudo code for a depth first search cycle of my graph. I am using an adjacency matrix, and every vertex connects to every other vertex (and technically they connect to theirselves). So, my code here is to do depth first searches to literally brute force every pathway.
But "just depth first searching" seems to be more complicated than I was anticipating.
Let's say I have adjacencymatrix[5][5] where each value is a weight, and it represents the edges of 5 vertices (just as an example)
Here is what I have been able to conceptualize so far (disclaimer, I am sorry this probably doesn't count as pseudocode, there is probably some standard that I am not meeting I haven't really ever learned anything about it)
1.)remove starting node from "unvisited" set, save it as a temporary vertex "startingVertex" 2.)push it's children onto a stack 3.)pop the top of the stack, remove it from "unvisited", push it's children onto stack 4.)repeat #3 until unvisited is empty 5.)add in the edge from the last visited edge back to "startingVertex", and save this path as temporary solution
//now is where things get fuzzy for me
6.)somehow put the last "visited" vertex (not counting startingVertex) back into the "unvisited" set - how do I do this?? 7.)go back to #4 8.)now when the last 2 levels of vertexes have been fully visited I am now going to somehow put 2 steps worth of vertexes back into "unvisited" set, again - I don't know how to mark my vertexes as unvisited 9.)back to #4, eventually having to put 3 steps worth of nodes as unvisited, and then finally 4 steps 10.)all done? I think this does every pathway? If I can figure out how to do that? I don't know how to backtrack.
|
Look up the proper algorithm on wikipedia. It probably uses concepts such as "get all children". Whenever something like that comes up, create a separate method for it which only does that one thing and makes sense even without the search algorithm.
Also there is no standard for pseudocode. People probably tend to write it a bit less prosaic and use common programming constructs in pseudocode, but in essence it's just about describing the general outline of an algorithm.
|
I think that the biggest question here is why do they even ask people to write down pseudocode for some of the most common algorithms?
I mean, you can straight out wikipedia it and you get pseudocode, actual code in several languages, links to implementations in other languages...
Why not instead introduce a problem that requires a specific algorithm to solve and see how people tackle it?
|
On December 28 2016 05:11 travis wrote:ok, christmas visits from inlaws dying down so its back to working on my project and, I need help, this is tough. I thought this would be easier than it is, haha I need help conceptualizing how to write the pseudo code for a depth first search cycle of my graph. I am using an adjacency matrix, and every vertex connects to every other vertex (and technically they connect to theirselves). So, my code here is to do depth first searches to literally brute force every pathway. But "just depth first searching" seems to be more complicated than I was anticipating. Let's say I have adjacencymatrix[5][5] where each value is a weight, and it represents the edges of 5 vertices (just as an example) Here is what I have been able to conceptualize so far (disclaimer, I am sorry this probably doesn't count as pseudocode, there is probably some standard that I am not meeting I haven't really ever learned anything about it) 1.)remove starting node from "unvisited" set, save it as a temporary vertex "startingVertex" 2.)push it's children onto a stack 3.)pop the top of the stack, remove it from "unvisited", push it's children onto stack 4.)repeat #3 until unvisited is empty 5.)add in the edge from the last visited edge back to "startingVertex", and save this path as temporary solution
//now is where things get fuzzy for me
6.)somehow put the last "visited" vertex (not counting startingVertex) back into the "unvisited" set - how do I do this?? 7.)go back to #4 8.)now when the last 2 levels of vertexes have been fully visited I am now going to somehow put 2 steps worth of vertexes back into "unvisited" set, again - I don't know how to mark my vertexes as unvisited 9.)back to #4, eventually having to put 3 steps worth of nodes as unvisited, and then finally 4 steps 10.)all done? I think this does every pathway? If I can figure out how to do that? I don't know how to backtrack.
1. add start node to visited set 2. push start node to stack 3. pop off an element in stack 4. for each child of element a. if child is not in visited set i. add child to visited set ii. push child on stack iii. set child's parent to element b. if child is node to find, go to step 6 // if searching for the path to a node 5. if stack is not empty go to step 3 6. if child has parent, return list of parents up to starting node // if searching for the path to a node
Your problem seems to be turning the DFS into real code, and you're mixing up the two pseudocodes, the math one that talks about visited and unvisited sets, and the code one that gives you the code.
In #6, the sets you're referring to are math specific terms, not a catch-all for sets in your programming language, because this is math pseudocode. You cannot always convert math pseudocode into real code 1-to-1. For example, a stack in mathematics is a completely different term, so no math pseudocode ever says "pop an element off the stack until there are no elements" - that is a code translation. A lot of the algorithms in Computer Science use this math pseudocode because CS is math, so trying to convert this pseudocode into real code requires you to actually understand the steps involved and conceptualize what data structures work together to solve the problem. In this same vein, moving a vertex from the unvisited set to the visited set just means marking the vertex as visited in the code. In a DFS you never unvisit visited nodes so you are mixing something up.
#8 and #10 are problems with your confusion between the two pseudocodes. For #10 however, what happens if your graph is not connected (you can't reach every node from every node). What happens if your chosen starting node has no children? How does that relate to the concept of picking from the unvisited set? Do you need to visit every pathway/edge in a DFS? How is backtracking taken care of in a DFS? What is backtracking? are questions you should be thinking about and know how to answer.
|
For the first time ever I've set up a server, and it's been an interesting experience. I do have a few questions, though.
Is it necessary to have both a static IP and a domain name? What if you have one and not the other? What if you have neither? I am aware that without a domain name it would be difficult/annoying to access your server, but you would still be able to, correct? What about when you have a domain name and a dynamic IP? Do you have to update the DNS with your new IP every time it changes? And if you don't have either you would have to let all of your users know what your new IP is every time it changes, right?
Also, I'm trying to teach my girlfriend a bit of it. She has OSX so I was thinking of setting up a MAMP server for her, which seems like everything except for PHP is already installed. Is that correct?
|
Hyrule18968 Posts
Set up a server how and where? A lot of home ISPs ban running servers on non-business accounts. If you're talking about a server hosted by someone else like Amazon or DigitalOcean, they take care of all the networking stuff, even for non-static IPs.
But anyway, for home servers, yes you'll have to push out DNS updates for your domain every time your IP changes, or you can get something like noip which is a program that does that for you.
|
If it's a server for less than 10 people it'll likely fall under the radar but don't come back here complaining if you get caught and have to face consequences for your actions. However, If you max out your bandwidth or have a lot of people using the server at once then you'll most certainly need a business account as tofu said. Few ISP's will allow it otherwise. Google is one of those that will allow it(only non-commercial servers). Some ISPs don't change the IP for months, others change it every few days. Business accounts have static IPs but of course they come with a much higher price in general.
|
These servers are going to be just for testing/fun. I am thinking of setting up a Fantasy Football site way down the road, but I'll use a domain and server host if I'm going to do that. Thanks for the warning though!
|
So, I've done some research now and found few truly brute force solutions to the TSP available.
I've only seen a couple options, actually. The first is to store completed pathways in lists and then look at your lists to see if you have gone through all the subpaths of a given vertex, so that you then know to backtrack. This sounds extremely inefficient to me, though.
So the option I am going with is what I came up with in the shower just now which I think is probably more efficient
Put starting node in a tree. Put all it's connected nodes as children in the tree. Repeat for all it's children, putting connected nodes as children only if that node isn't an ancestor.
Eventually the tree will contain all pathways, and I can just DFS it, stopping at every leaf as a completed pathway. This method should also be incredibly easy to put in a couple small measures to improve it's efficiency.
Maybe there is some sort of problem I am not thinking of
|
so you first convert graph to a tree and then traverse the tree?
not all graphs can be defined as a tree though, circle graphs, disconnected graphs...
|
On December 29 2016 04:09 mantequilla wrote: so you first convert graph to a tree and then traverse the tree?
not all graphs can be defined as a tree though, circle graphs, disconnected graphs... If I understood travis correctly he wants to construct a tree where each path from the root to a leaf is one possible path of the traveling salesman through the entire graph. I assume he then wants to iterate all of these paths to see which one is the cheapest. Constructing the tree correctly though will be just as expensive as all the other brute force algorithms.
|
travis, if you're looking for a very simple brute force solution to TSP and you have an adjacency list (and all nodes have paths between each other), you can actually forget about DFS completely. The idea is that any solution to TSP is just some ordering of the nodes, so if you check the length for all possible orderings, you'll find the minimum distance.
// This is pythony, but shouldn't be too complicated to make into Java permutations = all permutations of [0...n-1] // each element is a list with 0 to n-1 in a different order minLength = a gajillion // or some upper bound on TSP solution minWalk = None for perm in permutations: walkLength = sum([adjMatrix[perm[i]][perm[i+1]] for i in range(n-1)]) if walkLength < minLength: minLength = walkLength minWalk = perm return minWalk
Of course, since this is a side project, if you're doing it because you're interested in DFS in particular, then this solution isn't that interesting.
|
On December 29 2016 04:40 RoomOfMush wrote:Show nested quote +On December 29 2016 04:09 mantequilla wrote: so you first convert graph to a tree and then traverse the tree?
not all graphs can be defined as a tree though, circle graphs, disconnected graphs... If I understood travis correctly he wants to construct a tree where each path from the root to a leaf is one possible path of the traveling salesman through the entire graph. I assume he then wants to iterate all of these paths to see which one is the cheapest. Constructing the tree correctly though will be just as expensive as all the other brute force algorithms.
Yeah I figured it would be I just couldn't figure out how to do them lol 
On December 29 2016 04:54 raNazUra wrote:travis, if you're looking for a very simple brute force solution to TSP and you have an adjacency list (and all nodes have paths between each other), you can actually forget about DFS completely. The idea is that any solution to TSP is just some ordering of the nodes, so if you check the length for all possible orderings, you'll find the minimum distance. // This is pythony, but shouldn't be too complicated to make into Java permutations = all permutations of [0...n-1] // each element is a list with 0 to n-1 in a different order minLength = a gajillion // or some upper bound on TSP solution minWalk = None for perm in permutations: walkLength = sum([adjMatrix[perm[i]][perm[i+1]] for i in range(n-1)]) if walkLength < minLength: minLength = walkLength minWalk = perm return minWalk
Of course, since this is a side project, if you're doing it because you're interested in DFS in particular, then this solution isn't that interesting.
so this seems like the conceptually simple approach but the part I have trouble with is
//permutations = all permutations of [0...n-1] // each element is a list with 0 to n-1 in a different order
my trouble is that I can't figure out or find out a way to do all the permutations
though I just found one on stackoverflow that was actually really nice
Running output of string "abcd":
Step 1: Merge [a] and b: [ba, ab] Step 2: Merge [ba, ab] and c: [cba, bca, bac, cab, acb, abc] Step 3: Merge [cba, bca, bac, cab, acb, abc] and d: [dcba, cdba, cbda, cbad, dbca, bdca, bcda, bcad, dbac, bdac, badc, bacd, dcab, cdab, cadb, cabd, dacb, adcb, acdb, acbd, dabc, adbc, abdc, abcd]
Can you think of other ways to do it? The only way I could think of was basically just versions of DFS that involved backtracking based on checking a list to see if combinations had been completed already but clearly that would be insanely inefficient.
Like, someone highly upvoted on stackexchange said this (it's for string permutations but I imagine the logic is the same yes?)
Use recursion.
Try each of the letters in turn as the first letter and then find all the permutations of the remaining letters using a recursive call.
Now I don't understand how we actually do this. Let's just say we have nodes A, B, C, D
The main thing I don't see here is how we keep track of remaining letters
I guess we pass our method a container of nodes left to be explored (initially A, B, C, D)
So then our method will then explore the first one, put it into a container that keeps track of explored nodes, and then recursively pass the explored and unexplored nodes. then repeat and repeat until there are no more unexplored nodes
ohhh ok yeah I get this is does make sense lol that's not bad
|
Here's the PHP version of it (applicable for all procedural languages, it's not optimal with the backtracking but it works). Might be easier to understand for some:
function permute($ary, $it, $len) { if ($it === $len) { print implode($ary) . PHP_EOL; }
for ($i = $it; $i < $len; $i++) { swap($ary, $it, $i); permute($ary, $it + 1, $len); swap($ary, $it, $i); // backtrack } }
function swap(&$ary, $x, $y) { $temp = $ary[$x]; $ary[$x] = $ary[$y]; $ary[$y] = $temp; }
$letters = ['a', 'b', 'c', 'd'];
echo permute($letters, 0, count($letters));
// => abcd abdc acbd acdb adcb adbc bacd badc bcad bcda bdca bdac cbad cbda cabd cadb cdab cdba dbca dbac dcba dcab dacb dabc
Required reading: https://en.wikipedia.org/wiki/Permutation
|
If you can add a marked flag onto your nodes then depth first traversals are straight forward. The following codes leaves the data structures up to you. You need a stack that can push, peek and pop. You need an iterator to loop over all possible starting nodes (if applicable) You need an iterator to loop over all adjacent nodes from a node.
// This assumes you have at least one node on the stack. All nodes on stack are marked and all off stack are unmarked. void dfs(void) { Node *node = peek(); Node *otherNode; bool found = false;
forEachAdjacentNode(node, otherNode) { if(otherNode->marked == false) { found = true; otherNode->marked = true; //This can be part of push if you like push(otherNode); //If you want all paths from starting node to any node then do something in push or here. dfs(); pop(); otherNode->marked = false; // This can be part of pop if you like. } if(found == false) { //Your stack now contains one of the paths from your starting node to a node with no unreached adjacent nodes. } }
//This calls dfs from each node. void alldfs(void) { Node *node;
forEachNode(node) { node->marked = true; push(node); dfs(); pop(); node->marked = false; } }
|
|
|
|