• Breaking News

    Thursday, December 7, 2017

    Tic-Tac-Toe game made using Python 3 (UPDATED) learn programming

    Tic-Tac-Toe game made using Python 3 (UPDATED) learn programming


    Tic-Tac-Toe game made using Python 3 (UPDATED)

    Posted: 06 Dec 2017 09:18 PM PST

    I took to heart what all of you guys commented from my last post last night and tried to implement literally everything you guys advised that I do. So here is the new and improved Tic-Tac-Toe game, and once again, please leave criticism and feedback.

    https://github.com/Johnmancini30/Tic-Tac-Toe

    Original Post: https://www.reddit.com/r/learnprogramming/comments/7hw9du/i_made_a_basic_tictactoe_game_using_python_3_and/

    Download Python 3: https://www.python.org/downloads/

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

    Trying to learning how to learn C++. What is the best website for learning how to code with C++?

    Posted: 06 Dec 2017 04:26 AM PST

    Guys I am very interested in learning how to code, and learning this language specifically. SO it would be really appreciated if someone gives me advice about a website I could use to learn the programming language.

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

    I built a web app where you compete against a machine learning algorithm in buying/selling stocks

    Posted: 06 Dec 2017 05:45 PM PST

    web app can be found here: http://stockitgame.herokuapp.com

    source code is here: https://github.com/austintackaberry/stocks

    Looking forward to questions, comments, and criticism!

    EDIT: I used React/D3 on the frontend and python/flask/scikit learn on the backend

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

    Where should I start?

    Posted: 06 Dec 2017 06:00 PM PST

    I hope to program small games but I know I have to start by learning a language. I can afford books but not courses. What language should I learn?

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

    Looking to Mentor a beginner-intermediate programmer with potential/natural talent

    Posted: 06 Dec 2017 08:08 PM PST

    I'm a self-taught developer, It's still kind of a hobby for me but I've been programming for 12-13 years and am pretty good at it. My best skills are learning new things and problem solving, which are pretty good skills to pass on to someone trying to learn to program.

    I'm doing this because I don't have any developer/programmer friends IRL, or online for that matter. It'd be nice to have someone to talk to about this stuff and maybe work on a project with or discuss ideas. I want someone who has a natural ability for learning things quickly and solving programming-type problems(if you are good at solving world problems in math and can easily see how the world problem translates into a formula, then you will be good at solving coding/algorithm problems).

    Message me if you are interested or comment here if you have questions/want specific details

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

    Javascript calculator Help!

    Posted: 06 Dec 2017 08:16 PM PST

    Hey guy, I'm new to progamming and need help with some questions. I'm trying to code a calculator but ran into some problems, can anyone help me debug the code

    Mozilla Thimble

    So, I want to code a calculator and ran into some problem with javascript. Here is basically how I want the code to be.

    • When I press a number on the calculator, it will display it on the screen then store it to var num1;

    • Then when pressing a operation function ( +,-, /, x), it's store in var operation;

    • Then the screen will clear to null.

    • Then Pressing another number and store it into var num2;

    • Then I Wrote a code with the operation (+) to test if my code work.

    • Code goes something like this ( num1 + num 2) and return the answer.

    (Basically like a real calculator without the build in evaluation function from java)

    It didn't return back an answer. Can someone help me debug this? Did I store the number and operation correctly?

    Edit- I know the code is really basic, new to programming.

    Thanks at advance.

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

    How to do network latency test on API calls?

    Posted: 06 Dec 2017 08:06 PM PST

    I'm doing a python script that makes API calls to IBM Bluemix and Google Cloud service. Both of the servers for the API are located far from my country (Malaysia). Is there any way to do network latency test to compare the performance of the API calls? Also, is there any way to do a speedtest based on the server location?

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

    How to learn back-end web hands-on?

    Posted: 06 Dec 2017 07:45 PM PST

    I like to learn programming hands on, for example building webpages with HTML, CSS, and JavaScript, or making little text based games with Java, but what is the equivalent of this for learning back end web development without having to pay for servers, etc.

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

    Why is this rule introduced in our C coding standard?

    Posted: 06 Dec 2017 09:29 PM PST

    Hello

    I encountered a coding standard which requires a space between your if statement and the first following bracket, like so:

    If (some_variable > something) .... 

    Rather than:

    If(...) 

    I simply can't understand what benefit one gets from adding that single space. In case it is purely for readability reasons, that to me seens really like overkill knowinh your ide also colors the keyword.

    Does anybody know why one would absolutely want that space?

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

    Understanding how classes work

    Posted: 06 Dec 2017 10:49 PM PST

    Hi I've been trying to wrap my head around classes in C# for the last week. So far I am unable to tell exactly what is going on in the classes. Most of it is looking as though to me that I am just moving my methods I'd use elsewhere into these classes so that I can use it there and its just the same as me writing everything in one big program. But the thing that has me stump is when I am using the accessor and the mutator, I'm unsure of how they're declared or used.

    For example so far things to me are looking like I am using the accessor to choose what I am wanting to use and the mutator as how I want it to change. But to me I want to know a away I can make it so the user is able to input a value to be able to change. Most of the examples I am able to find from my notes or online look as though its showing me just how to use a preset value and not the one a user would input.

    Any help you can give me to push me in the right direction would be really appreciated!

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

    [C] Finished the Crack problem of CS50. It works, but I can't help but feel it's poorly/inefficiently designed. What are some ways to make it cleaner/more compact? Am I asking the program to loop more times than necessary?

    Posted: 06 Dec 2017 09:47 PM PST

    Hello everyone. I'm doing CS50 right now (I'm not familiar with this sub, not sure if you guys are sick of CS50 people yet lol), and I just finished the Week 2 project. The 'Crack' problem asked us to write a program that would crack a password that was hashed with C's crypt function, where the password was assumed to only contain up to four characters (and only A-z). Keep in mind I'm still really new to programming, and C in particular, so the syntax of stuff (especially raw, non-CS50-library C) is sometimes really confusing.

    The way I completed it was writing four separate scenarios, for passwords with one, two, three and four characters in them. For those last three, I just nested the loop for the first one inside of the if/else statement. So first bit checks A-z, then AA-zz, AAA-zzz and then AAAA-zzzz.

    I know this code is very sloppy, so any critique of it is much appreciated. I wanted to write a function, something like iterate_and_check (basically the function for the 1-digit passwords), that I could call back to and nest again and again, but I'm still not comfortable with writing custom functions.

    1. Any sort of tips or guides you could give me on making this program better designed? What redundancies can I get rid of? I know direct solutions aren't allowed on this sub, and I wouldn't want it either, but any sort of advice would be very helpful.
    2. Now in terms of the logic of the code. Am I asking the computer to loop/iterate characters more times than necessary? When running it on 4-character passwords, it sometimes takes quite a bit of time, which is understandable, but I'm not sure if there is any way that I can decrease the amount of times it has to loop, while still checking every possible combination.

    Oh and to be clear, I know that I'm asking it to check more types of characters than necessary (everything from Z to a), but I just did 'A' < j < 'z' for simplicity's sake.

    #include <stdio.h> #include <cs50.h> #include <string.h> #define _XOPEN_SOURCE #include <unistd.h> string crypt(); int main(int argc, string argv[]) { if (argc == 2) { char password[5]; string coded = crypt(password, argv[1]); // 1 CHARACTER CODE // iterate 1st char for(char j = 'A'; j <= 'z'; j++) { password[0] = j; coded = crypt(password, argv[1]); // check 1st char if(strcmp(coded, argv[1]) == 0) { printf("%s\n", password); return 0; } } // 2 CHARACTER CODE // iterate 1st char for(char j = 'A'; j <= 'z'; j++) { password[0] = j; coded = crypt(password, argv[1]); // check 1st char if(strcmp(coded, argv[1]) == 0) { printf("%s\n", password); return 0; } else { // iterate 2nd char for(char k = 'A'; k <= 'z'; k++) { password[1] = k; coded = crypt(password, argv[1]); // check 2nd char if(strcmp(coded, argv[1]) == 0) { printf("%s\n", password); return 0; } } } } // 3 CHARACTER CODE // iterate 1st char for(char j = 'A'; j <= 'z'; j++) { password[0] = j; coded = crypt(password, argv[1]); // check 1st char if(strcmp(coded, argv[1]) == 0) { printf("%s\n", password); return 0; } else { // iterate 2nd char for(char k = 'A'; k <= 'z'; k++) { password[1] = k; coded = crypt(password, argv[1]); // check 2nd char if(strcmp(coded, argv[1]) == 0) { printf("%s\n", password); return 0; } else { // iterate 3rd char for(char l = 'A'; l <= 'z'; l++) { password[2] = l; coded = crypt(password, argv[1]); // check 3rd char if(strcmp(coded, argv[1]) == 0) { printf("%s\n", password); return 0; } } } } } } // 4 CHARACTER CODE // iterate 1st char for(char j = 'A'; j <= 'z'; j++) { password[0] = j; coded = crypt(password, argv[1]); // check 1st char if(strcmp(coded, argv[1]) == 0) { printf("%s\n", password); return 0; } else { // iterate 2nd char for(char k = 'A'; k <= 'z'; k++) { password[1] = k; coded = crypt(password, argv[1]); // check 2nd char if(strcmp(coded, argv[1]) == 0) { printf("%s\n", password); return 0; } else { // iterate 3rd char for(char l = 'A'; l <= 'z'; l++) { password[2] = l; coded = crypt(password, argv[1]); // check 3rd char if(strcmp(coded, argv[1]) == 0) { printf("%s\n", password); return 0; } else { // iterate 4th char for(char m = 'A'; m <= 'z'; m++) { password[3] = m; coded = crypt(password, argv[1]); // check 4th char if(strcmp(coded, argv[1]) == 0) { printf("%s\n", password); return 0; } } } } } } } } } else { printf("Usage: ./crack hash\n"); return 1; } } 
    submitted by /u/mcheisenburglar
    [link] [comments]

    What do I use "dim" for?

    Posted: 06 Dec 2017 11:48 PM PST

    Due to personal issues I have missed a bit of school and want to catch up. There has been a help sheet given to the whole class and the first thing on it is:

    ' this is how to declare a variable

    Dim first_name As String ' string means text

    Dim age As Interger ' interger means whole number

    Dim speed As Single ' single means decimal number

    I mainly want to know what dim actually does, but an explanation for the other things would also be great. From this I think dim is meant to class something as a variable

    There are a few more things I don't understand on the sheet, so if anyone has the time to help me with them that would be really helpful.

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

    Do You Need To Be Good At Math To Pursue Programming?

    Posted: 06 Dec 2017 03:01 AM PST

    19-year-old figuring out careerpath. Sounds naive i know, but I had a horrible teacher from grade 6-10 who ruined math for me. What are the career paths or programming jobs that dont require high-level math?

    I'm very interested in app development, but some people are saying its going to be dead soon or theres no money in it anymore.

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

    Is CS50 worth pursuing even after an introductory C++ class?

    Posted: 06 Dec 2017 09:45 AM PST

    I'm almost done with an introductory C++ class at city college I need to take for my major and next semester I need to take an 'intermediate' object-oriented C++ class. The first 3 or 4 weeks of CS50 in the summer and had tons of fun, but in hindsight that all seems pretty simple now. Is the latter half of CS50 still worth pursuing even with 2 semester of C++ or would my time be better spent learning something else?

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

    [ASP.NET Core] MVC Web Applications: Simple Authorization

    Posted: 07 Dec 2017 12:20 AM PST

    I created this model from a Windows MVC tutorial.

    I was following the Authorization tutorial for creating admin, user, etc, but it requires an "Authorization folder" which I never created (as it's not in the original MVC tutorial). However, my application currently allows user to register new accounts and log in, so that's a start.

    Basically, I am trying to setup very simple authorization on my MVCMoive. I want my Movie.cshtml View to check if the current user is "admin@aol.com" (or something simple) so I can hide (set visibility to false for) the delete, edit, and create buttons from anonymous users.

    However, I understand from the tutorial (sort of, lol) that I want to do these sort of things in my MovieController.cs

    Am I over thinking this or is there an easy way to check:

    var userID = User.Check.UserOrSomething; if(User != "admin") { set visibility of delete, edit, create = false; } 
    submitted by /u/RnBesus
    [link] [comments]

    How to find errors in a predictive parsing table?

    Posted: 06 Dec 2017 11:24 PM PST

    Hello,

    How do I know where an error occurs in a predictive parsing table if the input is incorrect? For example, if the input is "(a+b;", the right parentheses is missing. I've tried removing random tokens and seeing where in the table I land on a blank, however I feel like this is tedious and won't allow me to cover all bases for error. Is there a better method than trial and error?

    Thanks

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

    Best backend language for a creative person

    Posted: 06 Dec 2017 07:18 PM PST

    I'm a creative person who is a visual learner. I'm currently looking into taking classes in coding, and while these classes all teach the foundations of front-end, they require you to pick a backend language as well. What would you recommend for someone who is more on the creative side? I have a background in the visual arts, if that helps you understand my brain a little more. Thanks for the advice.

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

    [C++] I really need help in trying to figure something out.

    Posted: 06 Dec 2017 10:53 PM PST

    So I have been given a project to recreate a sorting function. I basically have a .txt file that has a bunch of data entries. I have to import those entries and then sort them without using a sort function. All the information has to stay with each other. (i.e. Name, ID#, Hours worked). I've been trying to figure out how to make a list of these entries to start sorting them. Unfortunately I don't really know how to make an array of arrays of character arrays. My teacher doesn't really like strings but not sure if it's possible to do this without strings. Any help would be appreciated.

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

    Learning Bare Metal Embedded Programming

    Posted: 06 Dec 2017 04:24 PM PST

    Hello,

    I need to learn how to write bare metal software and was wondering what the best resources for that would be.

    1. I need to learn how to load the code onto memory with a boot loader.

    2. Start the bootstrap core.

    3. Have the bootstrap core start other cores or another way to start other cores.

    4. Access the other cores and send commands from the bootstrap core.

    All of this needs to be done without an operating system controlling the CPU. Any resources would be appreciated or even courses that might help me.

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

    convert multilevel nested array using into json using javascript

    Posted: 06 Dec 2017 10:21 PM PST

    I have written the code, where I load data from a csv file and the data is obtained by using D3 nest. What I am trying to do isconvert the obtained result to json format in the following code:

    d3.csv("data/data2.csv", function(data1) { var workStation = {"key":"Data","values": d3.nest() .key(function(d) { return d.WorkStation_Id; }) .key(function(d) { return d.Order_Id; }) .rollup(function(v) { return v.map(function(c){ return { "actualStart": convertscheduledtime(c.ScheduledTime),"rowHeight": 30, "actualEnd":c.Duration*1000+convertscheduledtime(c.ScheduledTime), "name":c.Order_Id}; }); }).entries(data1)}; var d2= [{"name":"Data", "children":workStation.values.map( function(major){ return { "name": major.key, "children":major.values.map( function(Order_Id){ return{ "name" : Order_Id.key, "actualStart" : Order_Id.values.actualStart, //this is where I am not getting the actualStart "actualEnd" : Order_Id.values.actualEnd //this is where I am not getting the actualEnd }; }) }; }) }]; }); 

    I am trying to get the Start Time End Time. I am calculating the Start time by adding the Duration. 2) The array that is obtained is coming as nested key values pair. I am trying to convert them to JSON data so that I can just pass this into the var treeData Gantt chart of anychart.js

    The following is the JSON data what I am trying to achieve: parent : 10A, children:[{ name:1, actualStart:18332233333, actualEnd:12343434444}, { name:2, actualStart:18332233898, actualEnd:12343434998}, .... ], parent : 10B, children: [{ name:1, actualStart:18332233333, actualEnd:12343434444}, { name:2, actualStart:18332233898, actualEnd:12343434998}, .... ] ....

    I got the data that I want till children's name:1 and for 'actualStart' and 'actualEnd' I am getting undefined as the value. Could someone kindly suggest what I need to change to get the actualStart and actualEnd data. I am completely clueness right now and it would help me learn from my mistakes.

    Thank you.

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

    Why does my shuffling function create duplicates of elements when it shouldn't?

    Posted: 06 Dec 2017 10:20 PM PST

    For example, if the starting (unshuffled) vector was {1, 2, 3, 4}, while I would expect the result to be something like {3, 1, 2, 4}, I am instead getting something like {2, 1, 4, 2}.

    I know this is something that I'm going to feel like an idiot for not catching, but it's just escaping me at the moment.

    #include <cstdlib> #include <iostream> #include <ctime> #include <vector> int main(int argc, char *argv[]) { srand(time(NULL)); static const int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52}; std::vector<int> deckVector (arr, arr + sizeof(arr) / sizeof(arr[0]) ); //debug for(int x=0; x<deckVector.size(); x++){ std::cout << "Before shuffling, Deck::deckVector[" << x << "] is " << deckVector[x] << "\n"; } //debug std::vector<int> tempDeckForShuffling; std::vector<int> splitDeck1; std::vector<int> splitDeck2; int differenceInSplitDeckSize; int deckSize = 52; int splitDeckSize1; int splitDeckSize2; int counter; int splitDeck1Counter; int splitDeck2Counter; for(int x=0; x<deckVector.size(); x++){ tempDeckForShuffling.push_back(deckVector[x]); } for(int x=0; x<10/*rand()%10+10*/; x++){ //start loop here with counter to rand? counter = 0; differenceInSplitDeckSize = rand()%8; splitDeckSize1 = 26 - differenceInSplitDeckSize; //TO DO: magic number splitDeckSize2 = 26 + differenceInSplitDeckSize; //TO DO: magic number while(counter<splitDeckSize1){ splitDeck1.push_back(tempDeckForShuffling[counter]); counter++; } while(counter<deckSize){ splitDeck2.push_back(tempDeckForShuffling[counter]); counter++; } //debug for(int x=0; x<splitDeck1.size(); x++){ std::cout << "During shuffling, splitDeck1[" << x << "] is " << splitDeck1[x] << "\n"; }for(int x=0; x<splitDeck2.size(); x++){ std::cout << "During shuffling, splitDeck2[" << x << "] is " << splitDeck2[x] << "\n"; } //debug counter = 0; splitDeck1Counter = 0; splitDeck2Counter = 0; tempDeckForShuffling.clear(); while(counter<deckSize){ for(int x=0; x<rand()%3+1; x++){ if(splitDeck1Counter<splitDeck1.size()){ tempDeckForShuffling.push_back(splitDeck1[splitDeck1Counter]); } splitDeck1Counter++; counter++; } for(int x=0; x<rand()%3+1; x++){ if(splitDeck2Counter<splitDeck2.size()){ tempDeckForShuffling.push_back(splitDeck2[splitDeck2Counter]); } splitDeck2Counter++; counter++; } } splitDeck1.clear(); splitDeck2.clear(); //here, we cut counter = 0; splitDeck1Counter = 0; splitDeck2Counter = 0; differenceInSplitDeckSize = rand()%14; splitDeckSize1 = 26 - differenceInSplitDeckSize; //splitDeckSize2 = 26 + differenceInSplitDeckSize; while(counter<splitDeckSize1){ splitDeck1.push_back(tempDeckForShuffling[counter]); counter++; } while(counter<deckSize){ splitDeck2.push_back(tempDeckForShuffling[counter]); counter++; } tempDeckForShuffling.clear(); for(int x=0; x<splitDeck2.size(); x++){ tempDeckForShuffling.push_back(splitDeck2[splitDeck2Counter]); splitDeck2Counter++; } for(int x=0; x<splitDeck1.size(); x++){ tempDeckForShuffling.push_back(splitDeck1[splitDeck1Counter]); splitDeck1Counter++; } //end cut //debug for(int x=0; x<tempDeckForShuffling.size(); x++){ std::cout << "During shuffling, shufflingVector[" << x << "] is " << tempDeckForShuffling[x] << "\n"; } //debug } deckVector.clear(); for(int x=0; x<deckSize; x++){ deckVector.push_back(tempDeckForShuffling[x]); } //debug for(int x=0; x<deckVector.size(); x++){ std::cout << "After shuffling, Deck::deckVector[" << x << "] is " << deckVector[x] << "\n"; } //debug std::cin.get(); return 1; } 
    submitted by /u/ungulateCase
    [link] [comments]

    How does downloading works?

    Posted: 06 Dec 2017 10:18 PM PST

    hello, so I tried to search that on google and base on what I found, you simply copy paste a file from a server (of course this is not perfect), now I would like to ask for some more specific step-by-step ("tutorial") meaning of downlaoding. I mean something like,

    first: have a succesful connection to the server(what kind of connection(protocol)? how to achieve that succesful connection? what process are made by the machine(and the OS)?)

    something like that? do you have any links that would bring me on this?

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

    Bootstrap 3 or 4 to learn?

    Posted: 06 Dec 2017 10:12 PM PST

    Hi All,

    I am learning web design and development. So far I have completed HTML, CSS, JS and jQuery. My next learning step is Bootstrap. Need help in choosing which version to learn and it's advantages and disadvantages.

    Thanks, Rahul

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

    [android] what are the general benefits of Resource Strings over hardcoding them in layout?

    Posted: 06 Dec 2017 05:39 PM PST

    specfically, is there any reason to care, other than good practice, about warnings when I don't intend to access those strings, or change them at any point? I can imagine there's optimisation benefits, or workflow benefits if there was either of those intentions there, but otherwise it escapes me.

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

    Super lost just trying to figure out where to add a single line to a script

    Posted: 06 Dec 2017 09:07 PM PST

    Any help would be really appreciated. I am trying to get this script

    https://pastebin.com/aFnZsP1m

    To run this document.querySelector('#logged_tbody > tr:nth-child(1) > td:nth-child(4) > a').click() after the original script finishes. Sorry for how nooby this is!

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

    No comments:

    Post a Comment