• Breaking News

    Friday, October 26, 2018

    Need help with grasping "for" and "while" loops. learn programming

    Need help with grasping "for" and "while" loops. learn programming


    Need help with grasping "for" and "while" loops.

    Posted: 25 Oct 2018 02:40 PM PDT

    Hi,

    So I only just started learning code and familiarised myself with C. However, I'm struggling to solve tasks involving "for" and "while" loops.

    I fully understand the concept on how both work, but what I struggle with is implementing them into code.

    E.g. Get first 1000 numbers starting with 11 that can be divided by 7 or their last two digits add up to 5, and calculate their SUM. (Have the solution, so don't waste time typing :P)

    Any tips on how to sharpen up my logic?

    Thanks in advance.

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

    Building flashcards for python developers

    Posted: 25 Oct 2018 08:39 AM PDT

    Hi /r/learnprogramming,

    I've been building a collection of flashcards for common programming topics and we've recently added a group of python topics. This is a small project that grew out of support from reddit so hopefully you find them helpful!

    Link: Flashcards for Python Developers

    GitHub: https://github.com/nlaz/flashcards-for-developers

    I really love this community of programmers so I hope you find them useful. Feedback and suggestions are appreciated :) Cheers!

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

    More courses!!!

    Posted: 25 Oct 2018 07:01 PM PDT

    How to deal with unrealistic goals

    Posted: 25 Oct 2018 09:50 PM PDT

    A fair number of posts here have the form:

    I want to use [AI / ML / blockchain] to develop an application like [facebook / google / etc]. I know a little CSS and HTML. Please offer guidance.

    What is the best way to explain that OP's expectations are unrealistic but still encourage them to pursue learning to program?

    The typical approach is to explain you have to crawl before you can walk or run. But, OP seldom accepts this valid observation at face value. So, the programmer in me wants to say "I have 30 years experience. You are in way over your head and have _zero_ chance." but this isn't real constructive. What has worked for others?

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

    Should I delve more into the language I'm learning (C++), or should I do more challenges?

    Posted: 25 Oct 2018 11:09 PM PDT

    I'm currently on classes, and I though, since I plan on generic programming, I shouldn't be needing anything further than this to solve coding challenges (on Reddit and CodeWars, I've heard of Foobar but I googled it and nothing came up). In fact, I can read the three books that I've got and it won't help me doing more complex challenges. They require intelligence rather than knowledge, I assume. Am I right? Should I put a virtual bookmark on my book and get codin'? I can't do both, it's confusing.

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

    How do I treat accuracy in contradictory one hot encoded data?

    Posted: 26 Oct 2018 01:03 AM PDT

    So, I've been working with neural nets recently and I've encountered a problem: My data is essentially a text. My network is supposed to learn and guess what the next character will be based on the last two. The latest version is not yet recurrent, but that's something I want to do as well. As far as I understand accuracy is the fraction of total test/validation data that has been classified correctly. Now, with my dataset that's kind of hard to determine. My data is contradictory. As a result a perfectly accurate network might be wrong in a less likely case.

    For example:

    Input: [[1, 0, 0, 0], [0, 1, 0, 0]

    Valid Output: [0, 0, 0, 1]

    Now the net could have guessed based on a lot of data the result is [0, 0, 1, 0]. But, because this case was seen and based on some loss function the actual output would be something like: [0.1, 0.1, 0.45, 0.35]. It's obviously neither correct nor as bad as [0, 0, 1, 0]. So, the accuracy shouldn't be 100% but not 0% either. What is an accuracy function that can be computed easily but still have this kind of representation? My idea was to sort the values, or at least the highest n. Then I could say if the highest value is the correct character it's 100%, the second it's 75%, the third it's 50%, the fourth it's 25% and anything below is 0. Unfortunately, something like this isn't computed as fast with arrays as a difference or a mean.

    So, can anyone explain which accuracy function I should use?

    Sincerely, Viktor Relda

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

    Help needed on this programming Problem

    Posted: 26 Oct 2018 01:01 AM PDT

    Hello friends of r/learnprogramming! I am a freshman majoring in Computer Science and recently we were given a problem to code as part of my intro to computer science class. We are using PYTHON 3.6 to code this problem. So far i've gotten 100% on most assignments until now that we are required to write the programs using functions. I am having a hard time grasping functions and how to integrate them into the solution for this problem. Can I get help on how to proceed with this problem? I'm really getting beat on understanding how to integrate functions into the solution. I do not want people to write the code for me but rather to provide advice on how to proceed with this problem. How should I start developing a solution that integrates functions? Maybe you could even include clarification on the use of functions. The image for the problem can be seen here: https://imgur.com/a/CXvYtZl. Thank you for taking the time out of your busy day to help a student like myself.

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

    [C++] Singleton class

    Posted: 26 Oct 2018 12:50 AM PDT

    I've read a bit here and there on different singleton class designs and wanted to ask here and see what you guys thought. Am I A.) implementing it correctly and B.) using it correctly?

    Game.h

    class Game { public: static Game& getInstance() { static Game instance; return instance; } Game(const Game&) = delete; Game& operator=(const Game&) = delete; Game(Game&&) = delete; Game& operator=(Game&&) = delete; static void updateDelta(); static bool Init(); static void processinput(); static void Update(); static void Draw(); inline static GameStateMachine gameStateMachine = GameStateMachine(); inline static SDL_Window* Window = nullptr; inline static SDL_Renderer* Renderer = nullptr; inline static const char* Title = "Keep it Alive!!"; inline static unsigned int screenWidth = 1280; inline static unsigned int screenHeight = 720; inline static bool isRunning = false; inline static Uint64 currentTime = 0ULL; inline static Uint64 lastTime = 0ULL; inline static double deltaTime = 0.0; inline static int mouseX = 0; inline static int mouseY = 0; private: Game() = default; ~Game(); }; 

    main.cpp

    #include <cstdio> #include "Game.h" int main(int argc, char* args[]) { (void*)argc; (void*)args; Game& game = Game::getInstance(); if (game.Init()) { while (game.isRunning) { game.processinput(); game.Update(); game.Draw(); } } else { printf("Error starting Game. Please Restart!\n"); return(-1); } return(0); } 

    One thing I've noticed is that I can completely get rid of the reference to the Game object (game) and just use Game::init or Game::Update, etc, etc and access the methods directly, so should I be doing that or is creating a reference the best way to access/use it here?

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

    [JAVA] Put multiple integers into one variable

    Posted: 26 Oct 2018 12:34 AM PDT

    Hey there, I have a problem with my Java code. I use a library which gives me a Funktion that can take any number of integers as parameters (I hope that's the right word, it's the translation of what we use in german).
    Now in my code I want to call that function but in the moment I write the code I don't know how many (and which) integers I will give to the function.
    That's why I want to use a variable but I don't know how I can do that because one variable can only contain one integer (right?) and I also can't use an array for example because the function expects an (or multiple) integers.
    Is there any way to (I think you call it) parse multiple integers with one variable?

    Edit: I forgot to say: I already tried to google, but all I was able to find was how to have multiple variables have the same value.

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

    Guidelines for developing market-worth desktop applications?

    Posted: 25 Oct 2018 07:52 PM PDT

    Hello everyone,

    I'm a C# developer with a 2 year background maintaining apps for a university project, our apps are used in-house by teachers and researchers and therefore don't need high standards as they are not going to be sold or made public. Now that I'm finishing my undergrad, I was thinking in opening a startup to develop desktop apps for a niche but I found myself a bit lost in certain topics:

    • is there a good book/course for developing desktops apps? I can only find books/courses on developing backend, REST services and the sort, never about desktop apps.

    • Where can I learn more about implementing licenses and DRM? The niche I'm interested is known for corporative piracy so would like to learn more about how to not allow people to pirate my desktop app.

    • Is there a architectural pattern preferred for desktop development? Are the usual architectures like MVC, MVP or MVVM applicable in desktop dev?

    • How can I learn more about developing a drawing interface for my desktop app? I don't want to code a tool like Microsoft Paint but would like to do something like the Proteus drawing interface(You can place electronic components in a drawing board and connect the components and such). How can I even call this type of interface?

    • Is there some good practice/programming standard for developing desktop apps that are focused on data processing? For example, I heard once that the strategy design pattern is good for data processing apps because you can change the strategy deployed and not break everything, does.this still holds up? Is there any other good practice to follow?

    Thanks!

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

    [Help] How to convert .json files to something readable by a pleb like me

    Posted: 25 Oct 2018 07:40 PM PDT

    Dear programmers of Reddit,

    Instagram allows people to download their data as .json files. I need to read the contents of the direct messages .json file for a message I sent to someone many months ago and we text a lot so scrolling will take hours if not a day.

    Please teach me. I don't know anything about programming so if there is a way I can convert it to a word or txt file it would be great!

    Thanks in advance!

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

    Any recommended books about JavaScript?

    Posted: 25 Oct 2018 11:00 PM PDT

    I have some experience with HTML5, CSS3 and programming languages such as C, C++, Python. I heard there is the JavaScript book, known as "ANSI C for JavaScript". What is properly the book? Can anyone recommend books about JavaScript?

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

    At what point do you include programming on your resume?

    Posted: 25 Oct 2018 01:47 PM PDT

    I'm just starting out learning programming (self-taught). I was just wondering at what point should you include it on your resume? Would it be better to sign up for online classes that provide some sort of certificate that proves your skills? Or would you include it when you are able to comfortable completely several projects in order to show actual results? Thanks!

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

    Looking for material to help write better code

    Posted: 25 Oct 2018 10:17 PM PDT

    I'm an iOS Developer who is looking to write better code, and having a difficult time finding material to help me improve. Here are some of my goals:

    • Identify how I can improve existing API design/architecture, how objects interact, when to use enums, etc.
    • I'm not so much focusing on Design Patterns (though I'm fine with learning more about them) -- I'm less looking to identify a clear problem with the code, and more to identify ok code that can be significantly improved
    • I've learned SOLID and OOP principles but I'm hoping to have a deeper dive so I have a better sense of how to use them day to day

    Books I'm considering:

    • Clean Code - Some of the stuff seems obvious (keep functions short, name variables properly) but I hear people swear by this book so I'm willing to give it a go
    • Refactoring: Improving the Design of Existing Code - This book seems to be closer to what I'm aiming for. Improving bad code might help me get a better idea of what good code looks like

    Does anyone have any resources they can add? It's difficult for me to explain what my goal is, but essentially if I'm given new requirements to code from scratch, or if I'm thrown into a legacy code base, I want to be able to make the most robust/flexible code with clean API design as much as possible.

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

    [Java] Don't understand the "super" keyword

    Posted: 25 Oct 2018 09:58 PM PDT

    So I understand that each class has a default, implicit super(), so if I had this code:

    class A { public A() { // maybe there is a super here too but I don't know what it does System.out.println("Class A"); } } class B extends A { public B() { // there is an implicit "super()" here System.out.println("Class B"); } } 

    If I tried to make an instance of B, like if I did var b = B();, I'd actually get Class A printed and then Class B, because of that implicit super().

    But what is the purpose of super? Constructors are for creating? instances of classes, so we get an object's identity, right? Even if I am wrong, it does have something to do with creating the objects. So if I said that whenever we make an instance of B, inside of that instance, there is some form of A (or an instance) of it?

    If the super() is called, and it calls upon the parent constructor, it's like making an object inside the object you want to make? I know there is something I am getting wrong, since the new objects are only ever made by the keyword new, like new B(). Can someone explain my confusions? Thank you.

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

    coding environment

    Posted: 25 Oct 2018 09:29 PM PDT

    im looking for a coding environment that i can share with a few people at once and have live testing of the code. i have found a few places already but the ones i've found only allow you to run one maybe two at once i'm looking for something that will allow around 4, maybe 5 at once. or things that have at least python and the discord.js installed by default. has anyone come across this?

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

    (C) (Linux) Having an issue with implementing sockets using the necessary header files. Getting weird "redefinition" errors. More info below.

    Posted: 25 Oct 2018 05:39 PM PDT

    Here's the code I have so far.

    #include <stdio.h> #include <string.h> #include <sys/socket.h> #include <arpa/inet.h> //To connect to a server, we need 2 things: ip address and port number //First create a sockaddr_in struct struct sockaddr_in { short sin_family; //e.g. AF_INET unsigned short sin_port; struct in_addr sin_addr; char sin_zero[8]; //memset this if you want to }; struct in_addr { unsigned long s_addr; }; struct sockaddr { unsigned short sa_family; char sa_data[14]; //14 byte protocol address }; int main(int argc, char const *argv[]) { //For the data having directly to do with the spell checking(except the dictionary), make sure to wrap it into a struct int socket_desc; struct sockaddr_in server; socket_desc = socket(AF_INET, SOCK_STREAM, 0); //socket() creates a socket and returns a socket descriptor /*AP_INET = IP version 4 SOCK_STREAM = TCP protocol 0 means IP protocol */ if (socket_desc == -1) { printf("Could not create socket\n"); } server.sin_addr.s_addr = inet_addr("127.0.0.1"); //this is the loopback address, which will be default //note: later on, you will have to let the user pass in an IP address on the command line server.sin_family = AF_INET; server.sin_port = htons(1900); //Connect tot remote server if(connect(socket_desc, (struct sockaddr *)&server, sizeof(server)) < 0){ puts("connect error"); return 1; } puts("Connected"); return 0; } 

    And here are the error messages

    spchecker.c:10:8: error: redefinition of 'struct sockaddr_in' struct sockaddr_in { ^ In file included from /usr/include/arpa/inet.h:22:0, from spchecker.c:4: /usr/include/netinet/in.h:239:8: note: originally defined here struct sockaddr_in ^ spchecker.c:17:8: error: redefinition of 'struct in_addr' struct in_addr { ^ In file included from /usr/include/arpa/inet.h:22:0, from spchecker.c:4: /usr/include/netinet/in.h:31:8: note: originally defined here struct in_addr ^ spchecker.c:21:8: error: redefinition of 'struct sockaddr' struct sockaddr { ^ In file included from /usr/include/x86_64-linux-gnu/sys/socket.h:38:0, from spchecker.c:3: /usr/include/x86_64-linux-gnu/bits/socket.h:153:8: note: originally defined here struct sockaddr ^ spchecker.c: In function 'main': spchecker.c:55:26: warning: passing argument 2 of 'connect' from incompatible pointer type [-Wincompatible-pointer-types] if(connect(socket_desc, (struct sockaddr *)&server, sizeof(server)) < 0){ ^ In file included from spchecker.c:3:0: /usr/include/x86_64-linux-gnu/sys/socket.h:137:12: note: expected 'const struct sockaddr *' but argument is of type 'struct sockaddr *' extern int connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len); ^ 

    There seems to be an issue with the socket header files I included. How can I fix this?

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

    Need to learn programming for scientific applications

    Posted: 25 Oct 2018 09:18 PM PDT

    I've discovered the hard way that when you're on the low end of the physics ladder you can't just hire an engineer to handle this stuff for you because they only give you the budget of a ham sandwich to work with. The guy in charge recommends Python, Java, or C. Okay, so... ... ... What's the difference between C and C++? Which is quickest for a noobie to pickup? I've found Python 3.x easily enough, but what about Java and C?

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

    Best IDE for a beginner?

    Posted: 25 Oct 2018 07:42 AM PDT

    Hi, im new and i want to know which is the best IDE for C and Python, Thanks

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

    Deeper programming concepts

    Posted: 25 Oct 2018 03:05 PM PDT

    Hello, I am here to ask a question about how well I need to know the inner workings of programming languages before being able to say I "know" a programming language.

    I can successfully code programs from start to finish with very few language related google searches, but when it comes to stuff like concurrency, knowing all the design patterns etc I am pretty new to it all.

    I will of course be learning these asap, but Is there any important advanced topics you guys could reccomend, thanks.

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

    Having a hard time fitting all my code into workable functions. C++

    Posted: 25 Oct 2018 09:03 PM PDT

    Hello, I've been wracking my brain for hours/days and scouring tutorials on YouTube and beyond to try and remedy my issue. This is for my Intro to Programming class. And no I'm not looking for straight answers, but at least, please a point me in the correct direction.

    You see, my teacher requires that we write all of our programs using this thing called Flowgorithm. Easy enough? There's no literal "coding" per se, but alas I'm still hitting a road block. Basically what Flowgorithm does is utilize flowcharts to then export it into actual code. Alright, on to my problem!...

    I have to create a program that assumes somebody makes a penny on the first day of their job, then double the next, doubled the next, and so on. Ok got it.. no problem. But, I need to put the different sections of my program into functions. This is where I've come to a full stop. There must be some sort of obvious thing I'm missing. In my very first function, I can not figure out how to get the user's input to return the value back into main, to my designated variable.

    This program worked beautifully!! until I tried to put things neatly into functions.

    Flowchart of the entire program: (Image 1) (Image 2) & the Google Doc for C++ code (Link)

    First function I made "getDays" (Image 3)

    What I need to figure out is how to get the value from the user into the variable numDays, because that in turn sets the max times the for loop will run. Then I need to output each day and the total days on screen. Please help.

    If you're wondering why I've created strange variables like "space" and "line", it's because Flowgorithm is finicky and won't let me create a fancy table output any other way.

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

    in ML, what does the high-dimension mean on the face extraction and reconstruction

    Posted: 25 Oct 2018 09:01 PM PDT

    Hi all,

    I don't understand the following statement.

    "project the entire training set onto the 1000-dimensional space formed by the top 1,000 eigenvectors "

    especially the 1000-dimensional space. how to do that?

    also

    "reconstruction error in L2 norm"

    what is the L2 norm?

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

    Binary Search Tree Help (C++)

    Posted: 25 Oct 2018 08:43 PM PDT

    /* Function: to_vector

    Description: creates a vector and populates it with the

    elements of the tree (in-order) and returns the vector

    as a pointer

    Runtime: O(n) where n is the number of elements in the tree.

    */

    std::vector<T> * to_vector()

    /* Function: num_geq

    Description: returns the number of elements in tree which are

    greater than or equal to x.

    Runtime: O(h) where h is the tree height

    */

    int num_geq(const T & x)

    /* Function: num_range

    Description: returns the number of elements in tree which are

    between min and max (inclusive).

    Runtime: O(h) where h is the tree height

    */

    int num_range(const T & min, const T & max)

    How would I go about incorporating the run time instructions for these functions?

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

    MySQL Lock wait timeout exceeded

    Posted: 25 Oct 2018 04:57 PM PDT

    I am inserting the results of a query into a table.

    The error occurs when I try to run a second query while the first is still running.

    The first query is JOINing Table A to Table B and Inserting INTO Table C.

    The second query is JOINing Table A to Table D and inserting INTO Table C.

    Once the first query finishes, I can run the second query, jsut not in parallel: this is what throws the error in MySQL:

    ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction 

    I understand that the error is telling me the process is locked (most likely because it's in use with the first query). Is there a way to run both queries at once without the error throwing?

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

    No comments:

    Post a Comment