• Breaking News

    Monday, October 1, 2018

    How to generate permutations for a list of numbers in python? Ask Programming

    How to generate permutations for a list of numbers in python? Ask Programming


    How to generate permutations for a list of numbers in python?

    Posted: 01 Oct 2018 06:49 PM PDT

    I want to generate a list of possible permutations in python. For ex: [1,2] = [1,2], [2,1] [1,2,3] = [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]

    The program below works fine if the list has different elements but doesn't work when at least one of the numbers is repeated. So [1,2,3] works fine but [1,2,1] does not.

    How do i fix this?

    def perms(x): if x==[]: return x elif len(x)==1: return [x] l=[] for element in x: l=l+[[element]+ d for d in perms([i for i in x if x.index(i)!=x.index(element)])] return l print(perms([1,2,3])) 
    submitted by /u/metalloidica
    [link] [comments]

    What are some realistic expectations for learning programing? How do I better teach myself?

    Posted: 01 Oct 2018 09:15 PM PDT

    Hey all. Just some background.

    I have 0 programming experience (yeah I know, but I'm trying to educate myself). To better myself in my field (IT), I've taken on the task of learning Ruby to connect to APIs, parsing data from the API based on the documentation etc.

    However, I feel I'm putting the horse, way, way, way before the cart. I have a great amount of difficulty just reading the code and trying to figure out what everything is. Obviously, without the basics, every line of code I'm reading I'm trying to dissect the different commands, or modes, that are being used just to setup a HTTP connection to an API, then request the data, etc.

    For every term I encounter, it leads me down a rabbit hole of terms or concepts that seem to be way over my head.

    I'm trying to attack the problem by building my foundation of programming knowledge in Ruby (Learn Ruby the Hardway) while also researching on open stack.

    However, after 3-4 days, I still feel completely lost, and no closer to figuring out how to do simple stuff in Ruby, nevermind connecting to an API and parsing for data out of it.

    I originally thought taking on the task would be a good way to force myself to learn programming, however, I probably bit off more than I could chew.

    I will say this - the whole experience has been humbling. I'm pretty worried I may not be smart enough to learn programming in general.

    Any advice, not necessarily on what solves my immediate problem, but on ways of learning, or searching sources, or understanding code better to help me to learn the overall language and programming basics?

    Was this task too advanced for me to take on, or what would be a reasonable timeline expectation to go from 0 programming knowledge, to solving problems like this?

    Thanks for your time.

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

    C# Keeping the console open and related exception

    Posted: 01 Oct 2018 07:01 PM PDT

    Hello,

    Background info: I have 2 classes, DepthSearch and BreadthSearch, that search through a maze using their respective search algorithms and print the results in the console as they go. The search is executed when they are instantiated.

    If I have:

    DepthSearch search1 = new DepthSearch(maze, row, column); Console.ReadLine(); 

    or

    BreadthSearch search2 = new BreadthSearch(maze, row, column); Console.ReadLine(); 

    it works just fine.

    However, if I have:

    DepthSearch search1 = new DepthSearch(maze, row, column); //Depth First Search BreadthSearch search2 = new BreadthSearch(maze, row, column); //Breadth First Search Console.ReadLine(); 

    The console closes immediately after running the searches (I can see the printing as it's progessing) and shoots the following exception: Exception thrown: 'System.InvalidOperationException' in mscorlib.dll

    Can someone help me understand why this exception is being thrown and why it only happens when they're run back-to-back? Also, is this related to why the console automatically closes?

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

    SAS: Making sure your logistic regression is right? [Advice]

    Posted: 01 Oct 2018 03:45 PM PDT

    I'm trying to run logistic regression in SAS; I'm interested in looking at associations with a *positive* outcome variable (coded as 1). Here is the code I used:

    *Run Logistic Regression where outcome is RMT;

    Title 'Logistic Regression';

    Proc Logistic data=malawi.malpro1;

    Model HML35=HC61 HV009 HC1;

    Run;

    And here are the variables I'm looking at:

    Rapid Malaria Test HML35 (OUTCOME VARIABLE)

     0 Negative 1 Positive 6 Other 9 Missing \_\_ Not Applicable 

    Education Level Attended HC61

     0 No Education, Preschool 1 Primary 2 Secondary 3 Higher 8 Don't know 9 Missing 

    Number of Household Members HV009

     Listed as 0-90 

    Child's Age (in months) HC1

     Listed as 0-60 

    ______________________________________________

    I'm worried that, since the RMT has more than 2 outcomes (pos, neg, missing, NA, etc.), how do I treat it as the actual outcome variable? And more importantly, how do I know that SAS is doing what I'm trying to accomplish?

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

    Object oriented programming guide.

    Posted: 01 Oct 2018 01:31 PM PDT

    I am a beginner C programmer and i want to learn an object oriented programming language but can't decide between C++ or Java. Can you guys recommend which will be more interesting as I want to make small projects in it. C seems very bound in making small projects. Any suggestions will be appreciated. Any guide or tutorials or books to follow specifically? I want to learn OOP in details.

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

    How do I create a basic GUI to run my code?

    Posted: 01 Oct 2018 05:24 PM PDT

    I dont know if this js the right place to ask this, but here goes. Im starting to learn R and python on my own free time and have started to wonder how is it that programmers "translate" the code into functional programs. Ive done some quick research that says a GUI is coded with java. Is this the only way to make a basic Interface?

    Isn't there a program I can use to quickly, and simply make a basic interface? Im learning just for fun anyways, but I wanted to try and build something simple like a calculator, for example. With an input box, some buttons and a basic display. Something that I could show to people other than a bunch of code lines.

    Thanks for any help/tips in advance!

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

    [project] collecting footages of live stream weather webcam sites

    Posted: 01 Oct 2018 01:29 PM PDT

    Hi everyone,

    As part of my design graduation project I'd like to collect footages of live webcams at certain times of the day (that one for instance https://www.viewsurf.com/univers/ville/vue/16924-france-ile-de-france-paris-la-defense).

    I'm looking for a way to automate this process. To start off, my goal is to collect these footages everyday for a week.

    Having never done any programming before, I'm also wondering what level of skills is required to that. I'm grateful of any recommendations.

    submitted by /u/0_3____--
    [link] [comments]

    Is there a name for "nesting", where things can be arbitrarily nested, but any two groups are either disjoint or one is a subset of the other?

    Posted: 01 Oct 2018 07:29 AM PDT

    In programming, we can't have two scopes A, B, s.t their intersection is nonempty and neither is contained in the other.

    Is there a more general name for this concept?

    As an example, human eras most certainly do not satisfy this property -- it is very common to name two eras that overlap, neither of which is contained in the other.

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

    Looking for advice on what languages / tools I'd need for a project

    Posted: 01 Oct 2018 04:28 PM PDT

    Hello all, I hope I'm doing this right -- Just made an account a few minutes ago.

    I had an idea a few months ago, finally sat and drew a picture of how I'd want to it work but and the more I thought about it the more and more certain I was that it needed to be from HTML. Now its become a bit of an obsession. I feel it could help some folks and maybe be a useful tool outside of work -- But here's what I'm aiming for:

    I want to create a step by step flowchart -- not like those ones I find when I search for "flowchart programs" on google but one that the user can click 'yes' or 'no' and be able to move through a window ( likely HTML ) which helps guide the user through a process or series of steps

    Can't seem to paste any pictures here, but I figure I'd drop a line here first

    Ty in advance!

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

    Accessing outside cloud storage

    Posted: 01 Oct 2018 03:10 PM PDT

    Hello,

    I'm creating a website through Wix for a nonprofit I'm affiliated with (it needs to be Wix. People accessing are older and need an easy to use, hands off backend control).

    What I'm wanting to do is build something like a database of documents, and believe that uploading to some kind of secondary cloud storage, then clicking a hyperlink would be the easiest to maintain (I will not be in 100% control after the site is built).

    The problem I'm running into is that this access to data needs to be member only.

    Is there any way to only access files via a webpage click? Does it require certain cloud storage services?

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

    I want to program a virtual assistant. What platform and language should I use?

    Posted: 30 Sep 2018 11:46 PM PDT

    It's for my Master's project.

    Basically, it'll take a voice input, convert it to a string, be able to analyze the string to understand the meaning behind it, have it determine an appropriate response, and then execute.

    Maybe I'm just feeling a little ambitious, but I don't think this will just be another of my one-and-done projects. I may want to expand this out, maybe add it to an avatar, maybe have it control my future house or something (lights, locks, music, air conditioning, etc).

    Question is, what language and platform are these potentially large projects done in? For my undergrad, I worked with mostly Java under a Windows/eclipse environment. Since starting grad school, I've been working more with Ubuntu and I've picked up other languages like Python over the years.

    I have a feeling that I can do most of what I'm looking to do with any platform and any language, but I'm looking for what will give me the most range with least amount of resistance. I'm trying to avoid a situation where, 6 months from now, someone will tell me, "You know, a lot of this would have been much easier to program if only you had started with ____ instead".

    Much appreciated for any advise that can be given. Also, if there is a more specific subreddit I should check out, please advise me there as well.

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

    Deploy, install and update windows application

    Posted: 01 Oct 2018 12:00 PM PDT

    I have an application and I would like to deploy it to users as a file that they can download off of my website.

    Once the user downloads the application, how can they install the application on their pc? i.e. move the application to the correct folder and perform initial setup, EULA etc. Will I need to build my own installer as part of the application to install the application? Or is their a default windows installer program in windows with an api that can be used to install my application? Or is their a 3rd party library/software that I can use to install my application?

    On top of this, how can I then perform over the air updates of my application to my users? Again, will I need to build my own auto updater that checks for updates and downloads and installs them or is their a library available that can do this?

    Thanks in advance for your help!

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

    Can I code wearing a VR headset?

    Posted: 01 Oct 2018 10:38 AM PDT

    Hi people,

    This is not a coding question, but related to coding. I apologize if I've violated community rules.

    I am thinking of buying 2 monitors to improve productivity at home. I've 2 monitors at work which is awesome.

    But then, I got the idea if I can code wearing a VR headset. I can literally have multiple windows open in a large space in front of me. I know VR devices are mostly for media and games, I'm not sure if some one is already doing this or is simply not practical.

    thanks

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

    Issue on simple Javascript program

    Posted: 01 Oct 2018 10:29 AM PDT

    Hi all,

    First and foremost, I do not know much about Javascript at all.

    Some background on the project;

    This guy here has made some code to automatically switch through photos. If you scroll down to the code section and look at the "Update!" area, that is the code I am using. He is injecting some javascript using Greasemonkey.

    I'm coming into an issue where the code he is using is only half working. When it hits the "right arrow" key (what I've figured out is Key 39), it compares the web address before and after the right arrow key. If they are the same, it's hit the end of the album and reloads to the first picture. The reloading part works, but it looks to me like the right arrow key is not first being pressed. So it just continually is refreshing the page and not really getting anywhere. I know some basic coding, so I can "read" what he wrote, but I cannot begin to troubleshoot it.

    Any help would be extremely appreciated. Thanks!

    Running Firefox ESR V 52 and Greasemonkey V4.1

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

    Is there any form of lists in C++?

    Posted: 01 Oct 2018 12:21 PM PDT

    I am relatively new to C++ and i got used to Python where you had lists of objects inside of it. I didn't found something simillar in C++. So is there anything like that in C++? If not what can be used in simillar way? P.S. I am, in a way, also relatively new to programming itself so i don't really know any professional terms (i'm 15)

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

    [Project] Building customer registration flow for local judo school

    Posted: 01 Oct 2018 07:05 AM PDT

    My friend has a local judo school. He has multiple groups with different ages. Right now, he has a simple sign-up form for a customer who would like to take part in a course or group. At the beggining he was creating an agreement in MS Word and he was sending it to his customer. Everything manually!

    Last year I created for him a small python script which was generating a latex document and then pdf based on the sign-up email. My friend copied the sign-up email content to txt file, than run a program and voila! pdf agreement ready to send. I'm adding also a line to small CSV so in the end he has a complete list of generated agreements.

    As far as he is going to develop his school for another groups and one more city, its becoming a bit tiring to manage 100+ clients and he asked me if I can automate a bit this process.

    I can code but I do not have any idea about how to make it automatic and where the program should be implemented? A server? Local machine? Introduce my python script into his php site? The base idea is to build kind of web-based "cockpit" where he will be able to manage sign-ups/groups etc and with one click send an email with agreement, or look into prepared agreement before sending it to client, count customers etc. Do you have an idea what will be the best and economical way/technology to build it? Maybe a similiar product already exists? As I mentioned: * www is written in php and is very simple * I already have a program to generate pdf agreements. Thank you for help! Sorry for my English, it's not my native

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

    I'm stuck working out a dual joystick tank control system! (with strafe)

    Posted: 30 Sep 2018 11:16 PM PDT

    I'm at a loss how to model a tanks movement using vectors/forces and modelling two fixed position tracks on a tank frame in 2D. I wanted to duplicate the controls for a simple 2D JavaScript game using an XBox controller.

    The details are:

    Many years ago I played an arcade game where there were two joysticks that controlled a futuristic (flat filled 3D) tank in a large arena that fights against another similar tank.

    Each joystick controlled a track - pushing the left one forward would do a large right circle, pulling back on the right stick at the same time would spin the tank on the spot.

    But not only was there the usual forward/backward for each track - the tracks could slide side to side too!

    Pushing both sticks to the right would strafe right fast, pushing one right would "pull" the other along and the strafe would be much slower.

    Pushing the left forward, and the right joystick left would push the tank left with the right track while pulling the tank along with the left track, making a super wide turn.

    I've found this to get me started - without the straffing, but it would be nice to find a tutorial or something!
    https://forum.unity.com/threads/tank-physics.49579/


    EDIT:

    I worked out a rough estimation of it! Yay!
    The side to side sliding I'll add another time... for this hacky maths it's simply adding velocity at 90 degrees to the direction of the front. =)
    https://codepen.io/SarahC/pen/MPajWY?editors=0110

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

    Multi threading c++

    Posted: 01 Oct 2018 12:46 AM PDT

    I have an assignment to create a program that will search through 6 text files inside of a .dat file to find all instances of an inputted word (e.x. "the") using multiple threads (which the user can choose the amount of). I am not a not versed in programming so I was wondering where to look for help on this. I've read a few guides on the subject but I can't quite figure out where to begin

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

    SCHOOL WEBSITE MAKING

    Posted: 30 Sep 2018 11:13 PM PDT

    So recently, we are tasked to make the school website. I know that all of the people present here can help me in doing the website. Any tips and tricks that all of you can help me? Any recommendations? I gladly accept all. Thanks!

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

    Help C++

    Posted: 30 Sep 2018 11:07 PM PDT

    Hi everyone. I'd like to ask you how to change this code: https://pastebin.com/zj5HjCzb. It's universal Turing machine and I need to find out how to make a parallel Turing machine out of it. Any help or hints are truly appreciated!

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

    No comments:

    Post a Comment