• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

Somnid

Member
I think for work, I am going to convert our website from Angular 1.6 -> 2+.

I don't want to learn TypeScript -_-

It's not that bad. It's 90% an ES20XX transpiler with some type stuff you may or may not bother with. If you know C# you pretty much don't even need to look up the syntax.
 
It's not that bad. It's 90% an ES20XX transpiler with some type stuff you may or may not bother with. If you know C# you pretty much don't even need to look up the syntax.

Typescript >>>>>>>>>>>>>>> js. IMHO.

I'm a C# guy though.

I've come from a Java background but I enjoy how free JavaScript is. No types, modifying objects/functions on the fly. It is fantastic. I will give Typescript a shot tho. Let me really get in it before making an opinion.
 
I've come from a Java background but I enjoy how free JavaScript is. No types, modifying objects/functions on the fly. It is fantastic. I will give Typescript a shot tho. Let me really get in it before making an opinion.

These things about JavaScript are fun and then you work on a team and they stop being so fun.
 

DBT85

Member
Hey guys. Just checking in really. Thought I'd give Codecademy a go.

This was something I should have stuck with when I was playing with VB when I was 10 (21 years ago!) but I drifted off. My brother got the bug and is completely self taught from 12 to now 28 and doing very very well for himself.

I did a tiny bit in C# about 8 years ago making a timecode calculator for the TV station I worked in at the time. Nothing fancy, but adding in bases of 24, 25 and 60 at the same time gives people headaches so it was useful at least.

Apart from that my only experience is with HTML, CSS and a tiny tiny bit of Java. which all came from personal projects 3-5 years ago. Around the time the Vita came out I was exploring what I could do with that and a mockup news site. I never got to the stage of actually adding the content (or how that would even happen) for articles and stuff but I'd gotten comfortable with the CSS and HTML bits I'd been using.

My whole working life has been in TV and while there is loads where I lived in London, there's a lot less in Worcester where I live now. So with that, a baby on the way and a job in TV that leaves me with nothing to do for 11 hours of my 12 hour shifts and unlimited access to a PC, I thought why not give it a whirl again.

Anyway, we'll see how it goes. I might just be back!
 

Ashes

Banned
Seeing you guys go to code academy made me feel like I was missing out. Especially as I'm learning Javascript too.

Right now, I'm liking that you jump right in. And you go through stuff from point to point in a very logical coherent manner. All course do it to a degree, but this seems to be doing it the right way.
 
What in the world is this "O"? It was in my php book (this is JS inside a php file):

if (user.value == '')
{
O('info').innerHTML = ''
return
}
 

D4Danger

Unconfirmed Member
What in the world is this "O"? It was in my php book (this is JS inside a php file):

if (user.value == '')
{
O('info').innerHTML = ''
return
}

that person has created or assigned a function to O. It looks like a shorthand for document.getElementById or something

whatever it is it should be explained in the book because it's not a standard thing
 
that person has created or assigned a function to O. It looks like a shorthand for document.getElementById or something

whatever it is it should be explained in the book because it's not a standard thing

Some function. By looks of it an alias or implementation of document.getQuerySelector()

Knowing this inspired me to look back into the JS section of the book which I skipped because I'm fairly comfortable with JS and it turns out he has this "OCS" system where he makes a method for grabbing an element by id, by class name, and then changing a style on either to save typing.

The book had been very clear up until this last chapter and then nothing is explained properly, including that. Thanks guys for letting me know this is not some strange JavaScript shorthand.
 

Lister

Banned
What in the world is this "O"? It was in my php book (this is JS inside a php file):

if (user.value == '')
{
O('info').innerHTML = ''
return
}

Knowing this inspired me to look back into the JS section of the book which I skipped because I'm fairly comfortable with JS and it turns out he has this "OCS" system where he makes a method for grabbing an element by id, by class name, and then changing a style on either to save typing.

The book had been very clear up until this last chapter and then nothing is explained properly, including that. Thanks guys for letting me know this is not some strange JavaScript shorthand.

Also called spaghetti code. Don't do this. People reading your code should be able to understand what it's doing. Suprised the author actually did that.
 

Ashes

Banned
The loop section of code academy needs a little work. I'm not sure why when teaching while loops, they complicated it by having a meaningless function. I kept thinking we had to work the function out.

They should had just had while loops on its own like they allow for after learning loops.
 

endre

Member
Does anyone know how to change the look and feel of a GUI project in Neatbens?

Changing the statement below to Windows does not make any difference.

Code:
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("[B]Windows[/B]".equals(info.getName())) {  //if ("Nimbus".equals(info.getName())) {  //changed from nimbus
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(EK_Creo_Add_In.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(EK_Creo_Add_In.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(EK_Creo_Add_In.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(EK_Creo_Add_In.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
 
Hey guys, I'm looking to get better at testing in general as I'm reasonably new to it. You have seen one or two previous posts in this thread from me asking questions about testing.

At the moment an old college exercise we have (not graded) is to create a simple clock class. The purpose I think is to familiarize the class with objects and OOP.

I'm not too concerned with that element of it or the exercise itself as I could do it easily enough. I'm more interested in applying a TDD approach to it and following good testing guidelines or best practices. Testing is not required or even suggested for this exercise, I just decided it would be a good way to try to apply what I know about testing so far.

So we were given an assignment to make a clock class with various functionality, I won't bore you with the exact spec as it's not super important or interesting. I have it around 65% complete in terms of functionality.

I will include my code below and my test suite. I guess what I'm trying to determine is: Are my tests too specific/redundant? Am I heading in the right/wrong direction with my approach/philosophy to testing?

Code:
Code:
class StringLengthError(Exception):

    def __init__(self):
        error_msg = "'input_str' must be exactly 8 characters in length."
        super().__init__(error_msg)

class MissingDelimiterError(Exception):

    def __init__(self):
        error_msg = "'input_str' must contain ':' delimiter between values."
        super().__init__(error_msg)

class Clock():

    def __init__(self, hours=0, minutes=0, seconds=0):
        self.hours = hours
        self.minutes = minutes
        self.seconds = seconds
        self.input_validator()

    def input_validator(self):
        if self.hours > 23:
            self.hours = 23
        elif self.hours < 0:
            self.hours = 0

        if self.minutes > 59:
            self.minutes = 59
        elif self.minutes < 0:
            self.minutes = 0

        if self.seconds > 59:
            self.seconds = 59
        elif self.seconds < 0:
            self.seconds = 0

    def printClock(self):
        formatted_clock = '{:02d}:{:02d}:{:02d}'.format(self.hours, self.minutes, self.seconds)
        return formatted_clock

    def strUpdate(self, input_str):
        if len(input_str) != 8:
            raise StringLengthError()
        if (input_str[2] != ':') or (input_str[5] != ':'):
            raise MissingDelimiterError()
        values = input_str.split(':')
        for i in range(len(values)):
            values[i] = int(values[i])
        self.hours = values[0]
        self.minutes = values[1]
        self.seconds = values[2]
        self.input_validator()


Test Suite:
Code:
import unittest
from clocks import Clock, StringLengthError, MissingDelimiterError


class TestClockDefault(unittest.TestCase):

    def setUp(self):
        self.clock = Clock()

    def test_input_validator_ignores_hours_greater_than_twenty_three(self):
        self.clock.hours = 24
        self.clock.input_validator()
        self.assertEqual(23, self.clock.hours)

    def test_input_validator_ignores_hours_less_than_zero(self):
        self.clock.hours = -1
        self.clock.input_validator()
        self.assertEqual(0, self.clock.hours)

    def test_input_validator_ignores_minutes_greater_than_fifty_nine(self):
        self.clock.minutes = 60
        self.clock.input_validator()
        self.assertEqual(59, self.clock.minutes)

    def test_input_validator_ignores_minutes_less_than_zero(self):
        self.clock.minutes = -1
        self.clock.input_validator()
        self.assertEqual(0, self.clock.minutes)

    def test_input_validator_ignores_seconds_greater_than_fifty_nine(self):
        self.clock.seconds = 60
        self.clock.input_validator()
        self.assertEqual(59, self.clock.seconds)

    def test_input_validator_ignores_seconds_less_than_zero(self):
        self.clock.seconds = -1
        self.clock.input_validator()
        self.assertEqual(0, self.clock.seconds)

    def test_print_clock_with_default_values(self):
        self.assertEqual('00:00:00', self.clock.printClock())

    def test_str_update_raises_exception_with_long_string(self):
        self.assertRaises(StringLengthError, self.clock.strUpdate, input_str='01:00:000')

    def test_str_update_raises_exception_with_short_string(self):
        self.assertRaises(StringLengthError, self.clock.strUpdate, input_str='01:00:0')

    def test_str_update_raises_exception_without_colons(self):
        self.assertRaises(MissingDelimiterError, self.clock.strUpdate, input_str='01000000')

    def test_str_update_raises_exception_without_first_colon(self):
        self.assertRaises(MissingDelimiterError, self.clock.strUpdate, input_str='01000:00')

    def test_str_update_raises_exception_without_second_colon(self):
        self.assertRaises(MissingDelimiterError, self.clock.strUpdate, input_str='010:0000')

    def test_str_update_raises_exception_with_only_alphabetical_characters(self):
        self.assertRaises(ValueError, self.clock.strUpdate, input_str='ab:cd:ef')

    def test_str_update_raises_exception_with_mixed_alphabetical_and_numeric_characters(self):
        self.assertRaises(ValueError, self.clock.strUpdate, input_str='a0:1d:3f')

    def test_str_update_raises_exception_with_only_non_alphanumeric_characters(self):
        self.assertRaises(ValueError, self.clock.strUpdate, input_str='!*:$%:&+')

    def test_str_update_raises_exception_with_mixed_characters(self):
        self.assertRaises(ValueError, self.clock.strUpdate, input_str='a!:4*:e}')



if __name__ == '__main__':
    unittest.main()
 
Kind of hitting my head over this, but I am trying to compare two numbers, say 000045 and 45. These numbers are kept in an array, so like [000, 045] and [45]. These numbers are equal, but I can't seem to get the syntax down. I guess the easiest solution would be to get rid of all the zeroes that precede the similar term. I could hard code it but it is a little difficult if the number is like 674 and 000674 or even 674 and 6740, since the last number is of the 1 slot. I am writing it in Java. I apologize if this sounded confusing.
 
Kind of hitting my head over this, but I am trying to compare two numbers, say 000045 and 45. These numbers are kept in an array, so like [000, 045] and [45]. These numbers are equal, but I can't seem to get the syntax down. I guess the easiest solution would be to get rid of all the zeroes that precede the similar term. I could hard code it but it is a little difficult if the number is like 674 and 000674 or even 674 and 6740, since the last number is of the 1 slot. I am writing it in Java. I apologize if this sounded confusing.

Convert them to *actual* numbers instead of trying to compare them as text.

Code:
Integer.parseInt(X) == Integer.parseInt(Y);
 
Hey guys, I'm looking to get better at testing in general as I'm reasonably new to it. You have seen one or two previous posts in this thread from me asking questions about testing.

At the moment an old college exercise we have (not graded) is to create a simple clock class. The purpose I think is to familiarize the class with objects and OOP.

I'm not too concerned with that element of it or the exercise itself as I could do it easily enough. I'm more interested in applying a TDD approach to it and following good testing guidelines or best practices. Testing is not required or even suggested for this exercise, I just decided it would be a good way to try to apply what I know about testing so far.

So we were given an assignment to make a clock class with various functionality, I won't bore you with the exact spec as it's not super important or interesting. I have it around 65% complete in terms of functionality.

I will include my code below and my test suite. I guess what I'm trying to determine is: Are my tests too specific/redundant? Am I heading in the right/wrong direction with my approach/philosophy to testing?

Code:<snip>

Those tests actually look pretty good to me. I'd add another one for "str update raises exception with too many colons".

BTW, idk if you've learned about regexes yet, but your updateStr function would be better like this:

Code:
def strUpdate(self, input_str):
    m = re.fullmatch("([0-9]{2}):([0-9]{2}):([0-9]{2})", input_str)
    if m is None:
        raise "Invalid String!"
    (self.hours, self.minutes, self.seconds) = [int(x) for x in m.groups[1:]]
 
Those tests actually look pretty good to me. I'd add another one for "str update raises exception with too many colons".

BTW, idk if you've learned about regexes yet, but your updateStr function would be better like this:

Code:
def strUpdate(self, input_str):
    m = re.fullmatch("([0-9]{2}):([0-9]{2}):([0-9]{2})", input_str)
    if m is None:
        raise "Invalid String!"
    (self.hours, self.minutes, self.seconds) = [int(x) for x in m.groups[1:]]

Thanks! I'm glad I'm going in the right direction with testing, I always second guess myself and my code to try to make the "right" decision.

Regex I'm familiar with the basics but never even thought about using it here for whatever reason. Most of the time I just default to the string.format() syntax. I normally only think about Regex if I have a much more complex pattern or a huge amount of text to parse through.

But I really like your solution, very elegant and easy to read. I think I'll replace my default implementation with yours if you don't mind. Thanks for the help and taking the time to read my large block of code!
 

Somnid

Member
Just had a phone interview, it went okay but this is another big fish so maybe not. Basically I flubbed an optimization question at the end because my brain would not let me see an O(log(n) * n) solution. Basically, for all real and practice problems I've seen, anything more than a constant * n is no good except for well-known domains. Very irritating.
 

JaMarco

Member
Just had a phone interview, it went okay but this is another big fish so maybe not. Basically I flubbed an optimization question at the end because my brain would not let me see an O(log(n) * n) solution. Basically, for all real and practice problems I've seen, anything more than a constant n is no good except for well-known domains. Very irritating.
Are you currently working?
 
Hey guys I had to do a recursive algorithm to solve mazes in ruby. I'm having trouble thinking of how to change my method to recognize if a maze has no solution.

my program opens a text file that looks something like this for instance

9a6031cebd.png


it takes the file reads through it and splits it into an array.

Then it essentially iterates through all possible paths to the end like so

e4408caaf6.png



until a path touches the F, then it's backtracked and replaced with asterisks. Then all other numbers are cleared. leaving only the shortest solution path.

I've tried a few different things without much luck, anyone have a hint they can throw my way? I thought if maybe I could have it so when all possible expansions begin to repeat it will alert the user that there is no solution. But frankly I don't know how I would do that. I'm still working through it, but I'm frazzled at this point.
 

Somnid

Member
Hey guys I had to do a recursive algorithm to solve mazes in ruby. I'm having trouble thinking of how to change my method to recognize if a maze has no solution.

my program opens a text file that looks something like this for instance

it takes the file reads through it and splits it into an array.

Then it essentially iterates through all possible paths to the end like so

until a path touches the F, then it's backtracked and replaced with asterisks. Then all other numbers are cleared. leaving only the shortest solution path.

I've tried a few different things without much luck, anyone have a hint they can throw my way? I thought if maybe I could have it so when all possible expansions begin to repeat it will alert the user that there is no solution. But frankly I don't know how I would do that. I'm still working through it, but I'm frazzled at this point.

If you are checking off possible paths then you just need to run until you no longer can move to an unchecked area.

A simple solution would be to check all four directions and if none of them match, mark them and add them to a queue if they were not marked. Then dequeue the next in line and try again until you hit F. This will give the shortest distance. If you want to get more efficient you might want to explore dijkstra's algorithm and A* as well as running search from both S and F and stopping when they meet in the middle.
 
The simplest way is to just do something like this:

1) Store in each square a number which is the least number of moves it takes to reach that square. Each square starts uninitialized.

2) Start at the beginning, and each step of the recursion does the following action:
  • Take the length of your current path and add 1 to it. Call this number N.
  • For each adjacent cell X, If N is greater than or equal to the number in X, ignore X. Otherwise go to step 2 with X as the new node.

Nothing will ever repeat this way. Once your algorithm terminates, look in the cell that represents the exit. If the number is uninitialized, there is no solution.
 
If you are checking off possible paths then you just need to run until you no longer can move to an unchecked area.

A simple solution would be to check all four directions and if none of them match, mark them and add them to a queue if they were not marked. Then dequeue the next in line and try again until you hit F. This will give the shortest distance. If you want to get more efficient you might want to explore dijkstra's algorithm and A* as well as running search from both S and F and stopping when they meet in the middle.

Yea, sorry I should have clarified, the program I have written achieves everything I want it to, iterates out, finds the shortest path etc. There's more code to what I have than just that, but I do have all that working. I just can't figure out what to change/add to check and see if it meets a "cannot be solved" condition.

Or am I missing what you guys are saying. I have a hard time conceptualizing. I need it to flag and return a statement to the user telling them it could not be solved.
 
Yea, sorry I should have clarified, the program I have written achieves everything I want it to, iterates out, finds the shortest path etc. There's more code to what I have than just that, but I do have all that working. I just can't figure out what to change/add to check and see if it meets a "cannot be solved" condition.

Or am I missing what you guys are saying. I have a hard time conceptualizing. I need it to flag and return a statement to the user telling them it could not be solved.

Did you see my post? There's a simple test at the end that determines whether it was unsolvable
 
The simplest way is to just do something like this:

1) Store in each square a number which is the least number of moves it takes to reach that square. Each square starts uninitialized.

2) Start at the beginning, and each step of the recursion does the following action:
  • Take the length of your current path and add 1 to it. Call this number N.
  • For each adjacent cell X, If N is greater than or equal to the number in X, ignore X. Otherwise go to step 2 with X as the new node.

Nothing will ever repeat this way. Once your algorithm terminates, look in the cell that represents the exit. If the number is uninitialized, there is no solution.

Did you see my post? There's a simple test at the end that determines whether it was unsolvable

Sorry, I didn't see it before. I was out helping a friend move and only glanced at my phone.

What do you mean store in each square the number of what takes the least moves? So after I've completed the first stage of tracing the route, during the recursion I should store whatever index value was found as a new variable. Then test to see if each adjacent cell >= to the number, if not proceed on the recursion?

Doesn't that cause a problem insofar as that the initial step of tracing the path won't technically end?
 
Code:
for(i = 0; i < buffersize; i++){
     message[i] = buffer[i];
}

I want to ask, does this piece of code store a sequence of strings in the message array? When I assign buffer to message, it prints the message I've been expecting. But when I print the message somewhere else even though message variable is declared within the main function, it prints out undefined characters. Any ideas or is this unclear?
 
I posted a question in the Web Development thread, but it may also be relevant here. Basically I am having trouble setting up a rails application to connect to a database, and I am wondering if there is something I am missing.

For a general gist of what is happening:

rails new AppName -d mysql

cd AppName

sudo mysql.server start

Which ends up giving me this error message:

ERROR! The server quit without updating PID file (/usr/local/var/mysql/MacBook-Pro.local.pid).

and when I try to start the rails server it gives me:

Mysql2::Error (Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)):

edit:

For a bit more information, this is the full message that comes up when I try to run the server:

Starting MySQL
./usr/local/Cellar/mysql/5.7.17/bin/mysqld_safe: line 586: /usr/local/var/mysql/mysqld_safe.pid: Permission denied
awk: i/o error occurred while closing /dev/stdout
input record number 1, file
source line number 1
ERROR! The server quit without updating PID file (/usr/local/var/mysql/########.local.pid).
 

Somnid

Member
Code:
for(i = 0; i < buffersize; i++){
     message[i] = buffer[i];
}

I want to ask, does this piece of code store a sequence of strings in the message array? When I assign buffer to message, it prints the message I've been expecting. But when I print the message somewhere else even though message variable is declared within the main function, it prints out undefined characters. Any ideas or is this unclear?

All this does is take buffer and copies all elements up to index buffersize into message (assuming message is longer than buffersize). As far as what type of data and whether they can be expected to work in a full program, you'll have to post more of it.
 
Sorry, I didn't see it before. I was out helping a friend move and only glanced at my phone.

What do you mean store in each square the number of what takes the least moves? So after I've completed the first stage of tracing the route, during the recursion I should store whatever index value was found as a new variable. Then test to see if each adjacent cell >= to the number, if not proceed on the recursion?

Doesn't that cause a problem insofar as that the initial step of tracing the path won't technically end?

So your maze is represented as a grid probably, and at each cell there's some information about which directions you can go. Just store an extra number. This grid is global state so that when you're on one path and you update a number, then later go to a different path, it will see the update from the earlier path

It will always end because the only time you recurse into a cell is if either you've never been there, or the current path is your best so far. The only way it could ever not end is if it kept going into the same squares over and over, but this is prevented by that shortest path check

I'm not sure what you mean by "the first step of tracing the route". There's only one step here: enter a node, update its number, Look at neighbors, decide which ones to enter, recurse ". This handles finding the shortest path and determining if it was solvable in one step
 

Slo

Member
Want to learn a new language? Try https://codefights.com, specifically the Arcade section. The site is built around challenging another real life coder and building your reputation, but the Arcade is essentially the single player mode.

I'm using it to learn Scala. They give you progressively harder functions to write and unit tests to run before submitting your work.

Here's an example:

Code:
Given the string, check if it is a palindrome.

Example

For inputString = "aabaa", the output should be
checkPalindrome(inputString) = true;
For inputString = "abac", the output should be
checkPalindrome(inputString) = false;
For inputString = "a", the output should be
checkPalindrome(inputString) = true.
Input/Output

[time limit] 20000ms (scala)
[input] string inputString

A non-empty string consisting of lowercase characters.

Constraints:
1 &#8804; inputString.length &#8804; 10.

[output] boolean

true if inputString is a palindrome, false otherwise.
 
So your maze is represented as a grid probably, and at each cell there's some information about which directions you can go. Just store an extra number. This grid is global state so that when you're on one path and you update a number, then later go to a different path, it will see the update from the earlier path

It will always end because the only time you recurse into a cell is if either you've never been there, or the current path is your best so far. The only way it could ever not end is if it kept going into the same squares over and over, but this is prevented by that shortest path check

I'm not sure what you mean by "the first step of tracing the route". There's only one step here: enter a node, update its number, Look at neighbors, decide which ones to enter, recurse ". This handles finding the shortest path and determining if it was solvable in one step

Can't I just set a flag somewhere that says if it runs into a fixnum instead of a space for the possible avenues it fails?

I'm not understanding you and it's not because you aren't clear. It's because I'm an idiot and I just can't visualize it.
 
Code:
____________
|  _________B
| |   | | |
| | | | | |_
|___________A

Imagine this is your maze. You start at A, and you want to find the shortest path to B, and also determine if there is a solution. You start by representing the maze as a grid. There are 6 columns and 4 rows, so we'll use a 6x4 matrix.
Code:
-------------------
|  |  |  |  |  | B|
-------------------
|  |  |  |  |  |  |
-------------------
|  |  |  |  |  |  |
-------------------
|  |  |  |  |  | A|
-------------------
The value of each cell is some kind of Node structure that you can store information in. In C++ it might look something like this:

Code:
struct Node {
  int Shortest = -1;  // uninitialized
  bool Left = false;  // Can we go left from here?
  bool Right = false; // Can we go right from here?
  bool Up = false;    // Can we go up from here?
  bool Down = false;  // Can we go down from here?
};

when you read it in from the file, you create this matrix and initialize all the Left, Right, Up, and Down values. It might look something like this after you're done initializing.
Code:
-------------------------------
| D R|  LR|  LR|  LR|  LR|   L| <--finish
-------------------------------
|UD  | D R| DL |D   | D  |    |
-------------------------------
|UD  |UD  |UD  |UD  |UD  |    |
-------------------------------
|U L |U LR|U LR|U LR|U LR|   L| <--start
-------------------------------

with the Shortest flag set to -1 in every node.

Now you call your recursive function with the node marked start. First thing it does is say "my current path has length 0. The value in this cell says -1. -1 means uninitialied, so I'm just going to write 0 here and proceed.". then it updates Shortest to be 0.

Now, since it's going to proceed, it looks at which moves are possible. It sees that only Left is possible. So it blindly recurses into the left node. Then this process repeats. Let's assume that we always try to expand into adjacent nodes in the order up -> right -> down -> left. Continuing this a few times you can see that it will make the first right and then reach a dead end. What does our grid of shortest path numbers look like at this point? Something like this.

Code:
-------------------
|-1|-1|-1|-1|-1|-1|
-------------------
|-1|-1|-1|-1| 3|-1|
-------------------
|-1|-1|-1|-1| 2|-1|
-------------------
|-1|-1|-1|-1| 1| 0|
-------------------

But we've got nowhere to go, so our function returns. Up to the node with 2, then up to the node with 1. So now it tried U, but there are still L and R left to try. Because of the ordering I specified earlier, it will try right. Note that this is the same direction we came from. Pointless right? But our algorithm doesn't care, it just recurses into it anyway. Now recall what the very step that happened when we began the algorithm was. Quoting exactly, I said earlier "my current path has length 0. The value in this cell says -1. -1 means uninitialied, so I'm just going to write 0 here and proceed." But the valeu in that cell doesn't say -1 anymore, it says 0. And our current path is of length 1 (since that's what we wrote into this cell earlier). So when we add 1 to it, we've now got a length of 2. Indeed, moving left once and then right is two steps. So it compares 2 against 0, finds out that it's greater, so it immediately returns. There is no point revisiting that node.

So now it's back in the cell marked 1. Only 1 direction left to go now, to the left. So it repeats this process again. Let's take a few more steps forward. It goes left, then it goes right and reaches another dead end, then backs up, goes left again, eventually makes it into that loopy area. After it proceeds all the way through that loop, it will look like this:

Code:
-------------------
|-1|-1|-1|-1|-1|-1|
-------------------
|-1| 6| 5| 4| 3|-1|
-------------------
|-1| 7| 4| 3| 2|-1|
-------------------
|-1| 8| 3| 2| 1| 0|
-------------------

Again, it looks to the right to see where to go next, and since 9 is greater than 3, it doesn't even bother. Instead it goes to the left. Eventually it makes it to the end of the maze, and your grid looks like this.

Code:
-------------------
|12|13|14|15|16|17|
-------------------
|11| 6| 5| 4| 3|-1|
-------------------
|10| 7| 4| 3| 2|-1|
-------------------
| 9| 8| 3| 2| 1| 0|
-------------------

So there you go! We're done right? Not quite. The algorithm doesn't even know that's the end. it just knows it can't go any further on that path. As always, it just keeps backing up looking for other paths it hasn't explored. Eventually it gets back to the place where it went Up into that loop area, and realizes it hasn't tried left yet. So it tries left. Now the distance would be 4, but we've already visited that path with a distance of 8. Since 4 < 8, we've found a better path! So it proceeds. It then goes up into that loop area again, once it's no longer the shortest path. Then it backs up, makes a left at the 4, and proceeds to the end. Finally you have this grid.

Code:
-------------------
| 8| 9|10|11|12|13|
-------------------
| 7| 6| 5| 4| 3|-1|
-------------------
| 6| 5| 4| 3| 2|-1|
-------------------
| 5| 4| 3| 2| 1| 0|
-------------------

Now it backs up again, but this time it's tried everything. There's nowhere else to go. Your algorithm completely returns from the recursive call, all the way up to the top. You look at the value stored in the ending square and it says 13. So the shortest path is 13, and it is solvable.

The same analysis works even for an unsolvable maze. Your algorithm will still terminate, but when you look at that cell in the grid, the value will just say -1.
 

DBT85

Member
While working my way through the tail end of the first Codecademy course, I found out (while experimenting) about inline-block and the whitespace that comes with it. How annoying.

I've been doing each little section and then making a page up each time with the info I got from it and while using the things it was teaching specifically. 95% was stuff I'd used before but there have been some useful bits I've learned already and its getting me back in to it.
 

Ashes

Banned
Currently on 68% of code academy's java script course. It has become clear to me that this python project that I've been working on, might need wholesale changes if I am to try and emulate it on a browswer.

That code is basically a script that goes through a thread, and collects all the posts that have the word: #entry in it, and then creates a post with links to those entries.

I guess I can try and go for a grease monkey script or something...
 

JesseZao

Member
Anyone use/have experience with Docker? I've used Heroku for the same sort of functionality, but I think learning Docker would be useful for enterprise stuff. How did you get a handle on the tools? I've found a few pluralsight courses, but I'll probably just end up getting my hands dirty with some toy apps/services.

Dev ops can be quite overwhelming at first glance. Hoping to get a better handle on it and using aws soon.
 
Currently on 68% of code academy's java script course. It has become clear to me that this python project that I've been working on, might need wholesale changes if I am to try and emulate it on a browswer.

That code is basically a script that goes through a thread, and collects all the posts that have the word: #entry in it, and then creates a post with links to those entries.

I guess I can try and go for a grease monkey script or something...
You could probably simplify the Python code by a lot with a scraping library like Scrapy or even just BeautifulSoup (an HTML parser). If you want it to run in the browser, it'll have to be Greasemonkey, but you could also use Node.js if you want to run it outside of a browser.
 

Ashes

Banned
You could probably simplify the Python code by a lot with a scraping library like Scrapy or even just BeautifulSoup (an HTML parser). If you want it to run in the browser, it'll have to be Greasemonkey, but you could also use Node.js if you want to run it outside of a browser.

Node.js? Any big advantage of doing so? Except of course being able to run code outside of a browser? Is learning it worth it for the sake of learning do you think?
 

Aomber

Member
Hi guys &#8211; I'm applying for an entry level job that wants Salesforce experience. I don't have Salesforce experience but from what I'm reading they use a language called SOQL

How similar is this to SQL? I understand the functional differences but I mean in terms of the actual language. I've been seeing some similarities from my brief research but just wondering because I do know SQL

I know this isn't a "programming" question so to speak but didn't know where else to ask on gaf
 

Somnid

Member
Hi guys – I'm applying for an entry level job that wants Salesforce experience. I don't have Salesforce experience but from what I'm reading they use a language called SOQL

How similar is this to SQL? I understand the functional differences but I mean in terms of the actual language. I've been seeing some similarities from my brief research but just wondering because I do know SQL

I know this isn't a "programming" question so to speak but didn't know where else to ask on gaf

Just browsing through a bit of documentation It looks like it uses SQL syntax for Saleforce Objects. Since this is entry level it would be unreasonable to ask you to know a domain specific language so I'm sure you're fine.
 

Aomber

Member
Just browsing through a bit of documentation It looks like it uses SQL syntax for Saleforce Objects. Since this is entry level it would be unreasonable to ask you to know a domain specific language so I'm sure you're fine.
That's what I thought, I'm sure I could learn quickly on the job, it's not even really a tech role and I know Java, SQL, HTML/CSS, etc. so I don't think I'd have a hard time selling that. Thanks for your response :)

These terms should be mutually exclusive

Haha I hear you, they say "0-2 years of experience" so I suppose it does apply to some applicants
 

danthefan

Member
Guys looking for some general advice. I've got some sports data in a MySQL database, and I want to be able to access it via a simple website where hopefully it can be sliced at different levels like you could do using SQL. The data is in three tables with player stats, match stats and general match details.

For example, you go to the website and select a player (or team or whatever) from a drop down or something, and then you can see the stats on a match by match basis, on a season by season basis etc, as per a user selection.

I really know nothing about web development so I'm just wondering what kind of language or platform could I use to go about it? I've made very early steps into looking at PHP, would it be suitable? On the other hand I'm half decent at Python so wound Django be an option?

Basically the question I have is how do I access this data in a MySQL DB in an interactive manner via a website. Any high level advice appreciated.
 
Guys looking for some general advice. I've got some sports data in a MySQL database, and I want to be able to access it via a simple website where hopefully it can be sliced at different levels like you could do using SQL. The data is in three tables with player stats, match stats and general match details.

For example, you go to the website and select a player (or team or whatever) from a drop down or something, and then you can see the stats on a match by match basis, on a season by season basis etc, as per a user selection.

I really know nothing about web development so I'm just wondering what kind of language or platform could I use to go about it? I've made very early steps into looking at PHP, would it be suitable? On the other hand I'm half decent at Python so wound Django be an option?

Basically the question I have is how do I access this data in a MySQL DB in an interactive manner via a website. Any high level advice appreciated.

Haven't worked with Python but in PHP using mysqli it should be super easy. Just... be careful with variables in queries, validate and escape all values.
 
Top Bottom