• Breaking News

    Wednesday, November 29, 2017

    Free coding exercises + videos for anyone learning Go (aka golang) learn programming

    Free coding exercises + videos for anyone learning Go (aka golang) learn programming


    Free coding exercises + videos for anyone learning Go (aka golang)

    Posted: 28 Nov 2017 10:56 AM PST

    I created a free course that is currently composed of 6 coding exercises, but will be around 20 when completed, and each is designed to teach specific things about coding in Go.

    For the most part you are expected to know how to write basic Go code, compile a program, etc. This is intended to help you level up your skills after learning the basics and to get you past that tutorial dependency that many beginners have.

    The basic way it works is I explain an exercise in a video overview, and I have a writeup of it on github (eg - https://github.com/gophercises/quiz). You don't have to, but I recommend going off on your own and spending a few hours trying to code a solution. It doesn't have to be perfect, but you should give it an honest shot before going back to the videos.

    After that you can watch the rest of the videos on the exercise where I code a solution and try to explain my thought process, where I found certain things in docs, etc.

    Each exercises is intended to design a few specific things - like how to use channels, or how to interact with files - and they are all designed to be challenging, but not so hard that you need to be a professional developer to get something working. Each exercise is also designed to take roughly 1hr or less for me to code from scratch, so they should all be something you can finish in an afternoon rather than needing to invest a week+ of time.

    Another example - we build a Choose Your Own Adventure book in the third exercise and this shows you some of the basics with the net/http package (used for building web servers), how to decode a JSON file, and introduces functional options which is a pretty cool configuration technique used in Go. You can actually see a demo of the final product here - https://gophercises.com/demos/cyoa/

    For anyone who is interested, the course website is here: https://gophercises.com/

    Disclaimer - I am the creator of the course, and while it is free you need to provide an email address to get access.

    submitted by /u/joncalhoun
    [link] [comments]

    Newbie to coding has Python question.

    Posted: 28 Nov 2017 03:20 PM PST

    Someone explain the purpose of boolean to me, please. Why do I have to declare if a value is True or False? What's the point of declaring it at all? I'm trying to learn this and I'm almost completely new to coding; please go easy on me.

    submitted by /u/jsurdybirdy
    [link] [comments]

    is it dumb to just give a project a go without having much of a foundation?

    Posted: 28 Nov 2017 05:59 PM PST

    there's a web app i've always wanted to use but nobody ever made, so i've decided i might as well. i have 0 programming experience, but i'm familiar enough with html/css/js/how to google to get a basic version of it going. i'm by no means proficient, and a lot of what i'm doing is just trial and error. i have no interest in making a career out of programming or even any money doing what i'm doing, i just want to make stuff that i'll use all the time.

    i feel like i should strike while the iron is hot and i feel energized and inspired and build this thing NOW. i've shown what i've done so far to a few friends that are really impressed, but i'm worried that i still don't really understand the complexity of what i'm trying to do. in a few months, i'll likely be in a position to be able to do a bootcamp or take a reputable course. is it better to just keep trying to get this thing going now before i have a structured learning environment that will teach me the actual fundamentals and practical stuff or will i hate myself for making the amateur hour thing i'm currently working on?

    submitted by /u/damamama12
    [link] [comments]

    Is the header file provided for this book broken, or am I doing something wrong?

    Posted: 28 Nov 2017 02:12 PM PST

    I'm attempting to read through the book Programming: Principles and Practices by Bjarne Stroustrup. The book suggests that I start out utilizing a header file he created, namely this one.

    As I understand it, the simplest way to include this would be to keep a copy of the file in the same directory as main.cpp, and to then include the line.

    #inclue "std_lib_facilities.h" 

    in the space before main().

    Otherwise, of course, you could point directly to the filepath, but currently since I'm just getting started I'll be lazy.

    I hardly need most of what's included in this header, but just to make sure it worked and to follow along with the book, I did this:

    #include "std_lib_facilities.h" using namespace std; int main() { cout << "Hello world!" << endl; return 0; } 

    I've tried figuring this out in both Visual Studio and Code::Blocks. Visual Studio's method of dealing with headers was just... confusing, but essentially the debugger continually made it known that it couldn't even open the header, even after I "added it to the project".

    Edit: Now Visual Studio is saying that cout is undefined, even though the only header in the project is now stdafx.h... sick of visual studio.

    In Code::Blocks, I ended up with a number of compilation errors, all pointing at std_lib_faciliites.h itself. I believe that these might have something to do with Code::Blocks not supporting C++11 too well, but I'm not quite sure.

    submitted by /u/Mummelpuffin
    [link] [comments]

    A curated list of Data Structures & Algorithms on Codechef (including links with their implementation on other popular forums)

    Posted: 28 Nov 2017 05:00 AM PST

    It is a very well curated list for data structures & Algorithms and open to contribute to as well. It includes the link to their solutions, question from geeksforgeeks.org and Top coder, explaining the details in the article. Link is following....

    https://discuss.codechef.com/questions/48877/data-structures-and-algorithms

    Hope it helps. please suggest better resources and suggestions too.

    submitted by /u/tapu_buoy
    [link] [comments]

    Best way to learn C

    Posted: 28 Nov 2017 11:11 PM PST

    What is the best way to learn C ? specifically linked lists. I have no trouble in other languages but it just wont click when I look at C

    submitted by /u/SpiritualMeaning
    [link] [comments]

    Help with merge sort

    Posted: 28 Nov 2017 06:27 PM PST

    I get an ArrayIndexOutOfBounds error on line 157 because the index j is 10 when the largest index is 9. Any ideas what I need to change to keep merge sort working while fixing this error? This code is from my virtual school class but doesn't seem to work.

    package assignment; import flvs.Movie; import java.util.concurrent.ThreadLocalRandom; public class MovieClient3 { static void traverseMovies(Movie[] movies) { for(flvs.Movie m : movies) { System.out.printf("Title: %s, Year: %d, Studio: %s%n", m.getTitle(), m.getYear(), m.getStudio()); } } public static void main(String[] args) { Movie[] movies = new Movie[] { new Movie("ABC", 2005, "Studio 03"), new Movie("DEF", 2006, "Studio 02"), new Movie("GHI", 2001, "Studio 01"), new Movie("JKL", 2003, "Studio 04"), new Movie("MNO", 2002, "Studio 05"), new Movie("PQR", 2007, "Studio 06"), new Movie("ST", 2010, "Studio 07"), new Movie("UV", 2009, "Studio 08"), new Movie("WX", 2008, "Studio 10"), new Movie("YZ", 2007, "Studio 09") }; jumbleArray(movies); System.out.println("Jumbling array..."); Movie[] jumbled = movies.clone(); System.out.println("Jumbled array:"); traverseMovies(movies); MergeSortByTitle(movies, 0, movies.length); System.out.println(); System.out.println("Sorted array using title:"); traverseMovies(movies); } static void jumbleArray(Object[] array) { int index; Object temp; ThreadLocalRandom random = ThreadLocalRandom.current(); for (int i = 0; i < array.length - 1; i++) { index = random.nextInt(i + 1); temp = array[index]; array[index] = array[i]; array[i] = temp; } } static boolean compare(Movie a, Movie b, String mode) { if(mode.equals("title")) return a.getTitle().compareTo(b.getTitle()) >= 0; else return true; } static void MergeSortByTitle(Movie[] array, int left, int right) { if(left == right) return; int mid = (left + right)/2; MergeSortByTitle(array, left, mid); MergeSortByTitle(array, mid + 1, right); merge(array, left, mid, right, "title"); } // Left run is A[iLeft :iRight-1]. // Right run is A[iRight:iEnd-1 ]. static void merge(Movie[] array, int left, int mid, int right, String mode) { Movie[] temp = new Movie[right - left + 1]; int i = left; int j = mid + 1; int n = 0; while(i <= mid || j <= right) // put elements (sorted) into temp { System.out.println("i: " + i + " j: " + j + " left: " + left + " right: " + right); if(i > mid) //we have emptied the left half, insert the right half { temp[n] = array[j]; j++; } else if(j > right) //we have emptied the right half, insert the left half { temp[n] = array[i]; i++; } else if(compare(array[i], array[j], "title")) { // both sections have values so we compare and see if // smallest is in i position − if so, pull from there temp[n] = array[i]; i++; } else { // smallest is in j position − pull from there temp[n] = array[j]; j++; } n++; } // put elements back into a in a[left] to a[right] for(int k = left; k <= right; k++) array[k] = temp[k - left]; } } 
    submitted by /u/ImTheTechn0mancer
    [link] [comments]

    What is a good formula resource for plotting or dealing with maths that I don't know how to do?

    Posted: 28 Nov 2017 07:55 PM PST

    I'm talking about things like plotting arcs, ellipse and circles, figuring linear distance on a grid, creating spline paths, things like that.

    I mean translating 10,10 from 1,1 on a grid puts you at 11,11. But how far is it if I go that same distance on y-axis only?

    Now I'm not wanting the answer directly to the example, I'd like to know what is a resource that has these kinds of formulas that I could then translate to my own code?

    submitted by /u/monsto
    [link] [comments]

    Help with finding guide/book for developing python software package development

    Posted: 28 Nov 2017 05:05 PM PST

    I did many tutorial but and I want to make my own python package. I looked at example on github and there are files like makefile, setup.py , requirements , certain folder structure and organization etc. Where can I learn all these things ? Is this more software development in general ? For example https://github.com/harmslab/gpmap

    submitted by /u/16theta16
    [link] [comments]

    It takes me multiple days to implement small features on my program

    Posted: 28 Nov 2017 04:43 PM PST

    Currently learning programming using an API in my software, and it always takes me days, or weeks just to add a small little detail onto my program.

    A renaming tool took me 1 week to implement for example. Also, most of the time I feel googling stack overflow solves my logic more then my own brain.

    Is it normal to create features at such a slow pace ? I just feel kind of dumb that I can't figure out simple logic on my own and have to resort to the stack overflow magicians.

    submitted by /u/gabenyolo
    [link] [comments]

    Look for feedback on a simple board game! (Python)

    Posted: 28 Nov 2017 08:26 PM PST

    I've been working on practicing classes and I spent some time recreating a simple board game I used to play when I was younger. Code here!! The rules are simple:

    • First player to make 5 in a row wins. This works diagonally as well.
    • First player to 5 captures wins. A capture is when you place a stone on each end of a segment of 2 of the other players' stones. You need 5 sets to win

    Right now I have it set up to manually input the coordinates of where each player will place a stone each turn. I know this is easily breakable by typing a letter or a number off the 19x19 board, but eventually I'm planning on using PyGame to make it so you have to click on a grid so in the future this won't be a problem. The visual board is more just for testing to make sure everything works, but you can play the game!

    The code for checking/executing a capture and checking for 5 in a row seems really messy or ugly to me with all the if's, but I can't think of a better/cleaner way to do it. I'm open to any and all advice!!

    edit: Title...I am not great at typing...

    submitted by /u/eatingflowers
    [link] [comments]

    In order to find a job as a web developer, what projects should I accomplish first? So employer may give me an interview.

    Posted: 29 Nov 2017 12:03 AM PST

    I am now studying JavaScript. But I don't know what projects I can do to put on the resume.

    As I searched the internet, I found this https://javascript30.com/. Is this enough? What other projects can I do?

    Thanks very much.

    submitted by /u/Getalliwant
    [link] [comments]

    Afraid I Might Switch Majors Again

    Posted: 28 Nov 2017 07:47 PM PST

    I've switched majors about 6 different times, with each thinking it would be my last switch and that I've found what I really like doing. I switched over to CS and I'm about to begin upper divisions, but I'm scared I'll somewhere down the line lose motivation as to why I'm in Computer Science like all the other majors. I make really impulsive decisions that I sometimes can't control, but this isn't the sub for that; I'm just trying to get guidance right now from people who might share a similar experience? Currently, I love programming, I like learning about data Structures and algorithms, writing clean code, and anything programming related. But how can I keep that drive alive, if I tend to always fall off eventually and turn to some other thing.

    Also, I'm not afraid of the work, I'm just afraid of losing that motivation and drive to stick with it.

    submitted by /u/ReignNFire
    [link] [comments]

    [Java] Web application - a few questions about session and cookies

    Posted: 28 Nov 2017 05:31 PM PST

    Hello, I am creating a single page application and so far so good. Everything works as intended but after reading about sessions and cookies some questions came up.

    So far a user can register a new account, and "login".

    my index.html only has a single div in which I insert the content. (Login , Registration, Registration success, and user account page.)

    I am generating all the content client side and my servlets only respond in json.

    I have 3 servlets( loginServlet, registration Servlet, UserManagementServlet)

    I also have classes for user , dataValiation(checking for empty, invalid inputs, or already existing username, email) JsonResponse (generate a json string response using gson), a Registrator(to create and store a user) and finaly a UserDB class that implements functions that interact with the database for my other "model" classes to use.

    All my servlets do is pass the request to the appropriate class and then choose how to respond, then with the help of JsonResponse methods send back the appropriate response.

    The client then decides which page needs to be created, based on the response and fills the blanks using the response json(e.x create the user page and fill in the user info from the returned user object.

    Besides not using JSP(i plan to learn about it but I would like to try and do this without it, or any other framework first), is my "architecture" okay? (3 servlets, separated logic, client view rendering)

    How can I have my user stay logged in after I refresh the page in the browser, and only redirect to login page when logged out? Is this possible with this approach? From my understanding I have to use cookies, or does the HttpSession provide a way to do this without cookies?

    Thank you so much for your time. I appreciate all feedback

    submitted by /u/_dude55
    [link] [comments]

    Help finding next step into programming.

    Posted: 28 Nov 2017 07:41 PM PST

    So, here is my situation: I'm a high school student who is very interested in the idea of coding, don't know anyone who does it and do not have access to structured classes, so I'm pretty much on my on.

    Right now I'm almost done with the book Think Python and have done a few problems from CodeAbbey, and feel pretty good about my progress so far.

    The problem is that I feel kind of lost, I just don't know where to go from this point. Should I read other books / take some MOOC about Python? Should I keep solving problems?

    I have interest in fields like AI and machine learning, and in participating in Catch the Flag competitions, besides using programming to build some simple yet fun robots (Arduino). Am I ready to get into these more specific fields? If so, how should I proceed? What previous math knowledge should I have?

    I know this type of question comes out quite often, but I have never found satisfactory answers, so really hope you guys could help me.

    submitted by /u/JBierS
    [link] [comments]

    Math script result displays wrong number as x

    Posted: 28 Nov 2017 11:20 PM PST

    #include <stdio.h> #include <conio.h> #include <math.h> main() { int a, b, c; printf ( "Input X to solve 3x^2 + 2x + 6 \n" ); scanf ( "%d", &a ); c = (3* pow((double)a,2) + 2*a + 6); printf ( "Result: (3*(%d^2)+2*%d+6) = %d \n", a, b, c ); getch(); } 

    Input X to solve 3x2 + 2x + 6
    2
    Result: (3 * (22) + 2 * 8 + 6) = 22

    +2*8+6
    8 should be 2 but it displays it as 8 for some reason.

    submitted by /u/LawsonBV
    [link] [comments]

    [JS] How would you go about writing event listeners that when clicking on any DOM element, it would check to see if it's been clicked before. If it has it would fire one listener, if it hasn't it would fire another

    Posted: 28 Nov 2017 07:07 PM PST

    I'm thinking it would just be two event listeners. Would you just set a variable like "clicked" and set it to true in a function?

    submitted by /u/hopelesso
    [link] [comments]

    How does XML document work with GTK to create user interface?

    Posted: 28 Nov 2017 10:35 PM PST

    I am working on a C/GTK+3 project right now. I have a little experience with front end but mostly only with Android. Even then that was VERY LITTLE experience.

    I notice that in the C code I place objects and set properties (like if a textview is editable etc). I also have been able to connect a .ui XML file to my program with the builder functions.

    I am wondering how the XML file gets linked to the C code defining the interface. Does it match by structure, by the name or ID properties? Why are properties like "visible" and "editable" present in both the C code and the XML? Do you need the XML file? Do you need to specify the properties in both the XML file and the C code or just one? Will I ever completely understand front end development?

    submitted by /u/pink_post-it
    [link] [comments]

    Regex Golf

    Posted: 28 Nov 2017 02:36 PM PST

    Hello, I'm doing the regex golf challenge (easy to find on google) and I was going strong until I got to the third level. yes, even I can't believe how far I didn't get. I need to match the words on the left, but not the words on the right

    fu futz tofu fusillade snafu functional discombobulated 

    with the only caveat being that I cannot use the $ character. I tried u[] but that didn't work. I tried u[^a-z]? but that's pretty much the same thing. And yeah I'm stuck as a duck in a truck of muck. I would appreciate some hints but only ask that you please don't spoil it if you know.

    Thanks

    submitted by /u/Protoss_Pylon
    [link] [comments]

    Where do I start with a Bar Code Maker? (language etc.)

    Posted: 28 Nov 2017 04:02 PM PST

    I need to make a barcode creator that works differently than all the ones online. there are a few requirements that I need to meet:

    -I want the program to open the csv file and grab the serial number

    -create a whole bunch of bar codes

    -and save each individual bar code as its own svg file

    -with the title being "serial number_title in a different column"

    -into a folder that i can designate.

    I don't really know where to start with this. I only know CSS and HTML and I have reached my limits with these.

    If I could get some help with deciding what language to start in or any advice for making it, that would be hugely appreciated.

    PS. (I have to do this by hand at work if I can't make it. so I thought that making something would be a fun way to learn something and do my work more efficiently.)

    submitted by /u/KingOfTheReds
    [link] [comments]

    How to keep track of stats in a text-based RPG?

    Posted: 28 Nov 2017 06:01 PM PST

    I've been able to make several beginner level programs during my first year of CS, but I'm completely stumped about this one question when it comes to stats in a game. Aside from making variables global, I don't know what to do.

    Because changes made to variables within a function do not apply to that same variable in other functions, I'm having a tough time figuring out how to make the player's stats carry throughout the program. For example, if I call a function, fightMonster(), the player should gain coins and experience points if they win, but if I were to do coins += 10, the amount of coins would only increase by 10 within the function and nowhere else.

    How is this most commonly dealt with? I suppose that I could either make variables global, or simply make the player's stats an array and pass that by reference from function to function, maybe make a million parameters for every function and pass them around every time. I don't feel like any of those would be the right answer though.

    Is this something that's generally written to file and pulled back up every time needed?

    edit: language is C++.

    submitted by /u/CyanGatorade
    [link] [comments]

    Need help with my C++ hangman homework

    Posted: 28 Nov 2017 08:01 PM PST

    I'm completely lost. This is what I have so far, but I am clueless how to go from what I have to something like this

    ----------- 10 incorrect guesses left. Guess: p Correct! p---------- 10 incorrect guesses left. Guess: m Correct! p-----mm--- 10 incorrect guesses left. Guess: e Incorrect! p-----mm--- 

    How do I replaces the dashes with updated correct guesses?

    #include <iostream> using namespace std; int main() { string dashes = "-----------"; string secret_word = "programming"; string guess; int guesses_left = 10; while (guesses_left > 0) { cout << dashes << endl; cout << guesses_left << " incorrect guesses left.\n"; cout << "Guess:"; getline(cin, guess); if (guess.length() != 1 ) { cout << "That is more than one character." << endl; } else if (guess[0] < 'a' || guess[0] > 'z') { cout << "Your guess must be a lowercase letter." << endl; } else { size_t index_found = secret_word.find(guess); if (index_found != string::npos) { for (int i = 0; i < secret_word.length(); i++) { for (int j = 0; j < 1; j++) { if (secret_word[i] != guess[j]) { cout << '-'; } else { cout << guess; } } } } else { cout << "Incorrect!\n"; guesses_left--; } } } } 
    submitted by /u/chipsahui
    [link] [comments]

    Currently studying code through the Odin project. Is it worth learning jquery through them or learning react or angular through someone else?

    Posted: 28 Nov 2017 12:25 PM PST

    I've been reading that react and angular are becoming the more popular frameworks ( or libraries...) for javascript. Shall I continue onto jquery or react/angular? My goal is to become a web developer and possibly being a full stack at some point.

    submitted by /u/RedFresne
    [link] [comments]

    Any suggestions on what book/courses to pick up for giving a good understanding of basic math.

    Posted: 28 Nov 2017 01:46 PM PST

    Hi all!

    I'm struggling sometimes with understanding statistics and basic math. I'm currently graduating in software engineering. But I don't feel like I have a good understanding on basic math. It's not that I don't know anything about math but I feel like I sometimes miss the basics. Any recommendations on a course or book(s) to refresh the basics from high school/ first year college

    submitted by /u/forfunc
    [link] [comments]

    No comments:

    Post a Comment