• Breaking News

    Saturday, June 1, 2019

    What have you been working on recently? [June 01, 2019] learn programming

    What have you been working on recently? [June 01, 2019] learn programming


    What have you been working on recently? [June 01, 2019]

    Posted: 01 Jun 2019 09:11 AM PDT

    What have you been working on recently? Feel free to share updates on projects you're working on, brag about any major milestones you've hit, grouse about a challenge you've ran into recently... Any sort of "progress report" is fair game!

    A few requests:

    1. If possible, include a link to your source code when sharing a project update. That way, others can learn from your work!

    2. If you've shared something, try commenting on at least one other update -- ask a question, give feedback, compliment something cool... We encourage discussion!

    3. If you don't consider yourself to be a beginner, include about how many years of experience you have.

    This thread will remained stickied over the weekend. Link to past threads here.

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

    I think learning how databases work is essential for programmers

    Posted: 31 May 2019 11:27 PM PDT

    http://coding-geek.com/how-databases-work/

    I was connecting to databases and doing queries for about 2 years. But, never knew what's going on "under the hood". After reading this, now I have a sense how these things are working and how I can optimize the database for performances.

    :)

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

    How I got a job in software

    Posted: 01 Jun 2019 08:53 AM PDT

    Hello, the purpose of this post is to share my experience of starting from zero to becoming a developer. During the time I was learning, these types of posts really helped motivate and encourage me so I told myself I would write one once I got a developer job.

    Software was always something I knew I liked, but it just didn't line up until around a year ago. Before then, I graduated and worked in another engineering field. I got bored of that industry really quick and for around 6 months of constant studying and working on projects, I started applying to software jobs. I got 1 interview and they liked me and now I've been working for a bit over 2 months. I work in a major tech hub and they pay me a bit north of 100k for my salary.

    My stack is modern web development with React and Redux. During my study there were distinct milestones that made me feel like I was actually making progress.

    • In the beginning I was just learning javascript and its syntax. This was where I was stuck for a long time without any real improvement. I felt I was doing it through a book and was trying to go chapter by chapter and memorizing everything. This is not the move, I would definitely recommend just skimming it - aim to know OF concepts and where to find them again when you actually need to know them (this is a really useful strategy in web development).
    • The first milestone was when I immersed myself in web development - specifically listening to podcasts. I tried subscribing to this sub, going on discord, stack overflow, etc but it wasn't until podcasts that I felt a major change. The hardest thing about web development is the abundance of technologies - listening to a podcast like SyntaxFM really helped me get a grip on what each technology/framework did. Whatever does this for you would be the best method.
    • The second milestone is to find an opinionated teacher. I took a Udemy course on React and Redux and in that course I learned about a few other technologies too. After the first one, I realized courses were not really my style and what I found valuable was just the curriculum. So then I started looking around other courses just to see what technologies they were teaching and then taught myself those technologies through docs. Analysis paralysis is real and in the beginning you'll be pulled so many different ways by enticing tech headlines that you won't know what to study. With a curriculum this is a lot easier. I think my process could have been cut down to 3 - 4 months if I had a nice curriculum. What ended up being most useful was this roadmap. Note: it's very complete and you do not need to know everything on there (I know less than half).
    • The third milestone was reading other people's code. I found that I really liked deciphering peoples code and found it a really enjoyable challenge. My tip would be to find projects similar to what you've built and trying to decipher their code. It'll be easier since you built something similar. Try and pick something popular (github stars/npm downloads) so that you know the code is at a decent quality. You learn a lot about different patterns very quickly this way.
    • Lastly, contributing to an open source project is the final mile stone. It looks really good on a resume. I really liked working with Gatsby so I got involved with their open source project. They have a peer programming program where you can work on issues together with one of their devs. It's great for getting up and running. It can be daunting at first but start small (beginner friendly issues) and familiarize yourself slowly with the library.

    Tips to people starting/currently in the webdev journey:

    1. Study based on the roadmap
    2. Skim things - know of concepts/technologies, don't try to study it to death until you actually need it.
    3. Listen to SyntaxFM
    4. Join Reactiflux on discord - #need-help
    5. Build things that you think are cool and it won't feel like work.

    Hope this helps.

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

    The Helsinki MOOC on full stack web development in English is now open

    Posted: 31 May 2019 09:52 AM PDT

    Has anyone been in the same place? Surrounded by better programmers

    Posted: 01 Jun 2019 04:08 AM PDT

    Hi guys,

    First of, i want to thank this sub because it inspired me to learn Python about three years ago. Since then i also picked up VBA in my last year master degree (Finance graduate). My automation skills allowed me to put my feet in investment banking with nearly 0 experience. Whenever i went i impressed my colleagues and managers with my automations (Automating reports, mass mailing, processes... You name it).
    I recently got to a position in a hedge fund, where they don't necessarly need an exclusive CS person, but someone with strong financial culture AND programming knowledge. I succeeded the interview and got the position (Middle officer). But the thing is, half of my team are comfortable with programming, even my manager spends most of his time programming (And he has a crazy good level, i suspect him being a CS major). We also have the risk team right in front of us, they know how to program (R, Python, C, VBA), same for the management side (Portfolio managers and their assistants). And aaalll the processes seem to be already automated LOL. It's hard to distinguish myself and i think the only way i can do so is to review their code to learn from it and try to do better.

    I still don't have time to program or to automate processes, it's been 2 months that i've been here and i'm only struggling with understanding my middle officer missions.

    Has anyone ever been in a position like this? Where well, you proved being skilled etc in front of non programmers but got accepted to a place where everyone has a better level than you?

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

    Newbie + career switching ??? HELP

    Posted: 01 Jun 2019 12:42 PM PDT

    Hey guys, im new here, i have a urge to learn progamming but i have no knowledge about a progam, where should i start ?

    Is there a progam where i can begin, can i have good tips, because i dont like my job anymore and i wanna make a career switch.

    Thank u very much

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

    Where do I start?

    Posted: 01 Jun 2019 10:17 AM PDT

    I want to start learning programming/coding, how and where do I start?

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

    The Odin Project vs. Colt Steele's Web Dev Bootcamp on Udemy?

    Posted: 01 Jun 2019 08:11 AM PDT

    For anyone who has done any or both of these, which one would you recommend I do? I'm currently on the HTML and CSS basics on the Odin Project (Codecademy part), but some people mentioned that the projects are based on rails, which isn't good? So I'm not sure if I should continue with TOP.

    I'm going to be a senior CS college student but I feel like I didn't really learn anything or how to actually build real things. We only made stuff on the command prompt using c++ and java. So I'm using this summer break to learn web development on my own. Or if anyone has better recommendations, that would be great, too. Thanks

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

    Looking for a project to collaborate on

    Posted: 01 Jun 2019 11:31 AM PDT

    Hi all,

    I've been programming for a few years (I'm a self-taught with a background in biology) and would like to add a collaborative project to my GitHub. I know Python (advanced), C++ (beginner), and HTML (beginner). I also have an intermediate knowledge of machine learning (I'm very familiar with packages such as Keras, Scipy, Pandas, etc). For example, I have made neural network models to find seizures based on EEG data.

    If any of you have a cool project you want to collaborate on let me know. Or if there's another Reddit page/website for this purpose I'd appreciate it if you share it here.

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

    Logic building

    Posted: 01 Jun 2019 08:13 AM PDT

    I know most people would say practice and it is, but every time i get stuck to a problem, I eventually see its solution and after feel guilty about it! I just can't think of a solution and declare my defeat. Any advice for how to keep going!

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

    DIGEdit, a new high performance text editor.

    Posted: 01 Jun 2019 01:08 PM PDT

    DIGEdit (https://github.com/kingtoolbox/DIGEdit) is a new high performance text editor. It is very easy to open and edit one line of 100M Bytes, or a GBytes file, and have a lot of features too.

    It is totally free for use.

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

    Looking for ways to improve my programming this summer, what do you recommend?

    Posted: 01 Jun 2019 01:00 PM PDT

    Hey guys, so a little background I am a 22 college student and I just started learning to program. Im currently taking my second computer science class, which is an object oriented based C++ class. I am going to be taking this summer off but want to continue to improve on my skills, but not sure where I should go. All I have learned so far is syntax and working with text based programs. At my skill set, what would you recommend I should work on this summer? I will be taking data structures next semester so maybe something related to that? I also plan on learning the basics of Github. Any resources or advice would be much appreciated. I know I am only a beginner but sometimes I feel so lost compared to others and it can be a bit discouraging.

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

    Learning C#

    Posted: 01 Jun 2019 12:50 PM PDT

    C# is an awesome programming language, especially for starters it is a lot of fun. It was my first programming language and now my little sister is learning it.

    I think we programmers should all try to motivate the younger generations to learn coding as soon as possible. And we should also motivate people in jobs that will be eradicated in the next years or decades to switch to coding.

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

    Started my CS degree next week, curious for some advice.

    Posted: 01 Jun 2019 12:35 PM PDT

    Any advice is welcome. I'm mainly concerned about using my MacBook Pro. I know I will not be limited or hindered by using one, but my C language course is using Visual Studio on Windows. I can use VSCode for Mac but it's not the same so I'm wondering if it would benefit to learn on what the professor is using. On the other hand, I want to use my Mac for my future endeavors, so I'd rather get comfortable using OSX for my programming. I know it's beneficial to know both, and I do want to be fluent with both operating systems, but I guess I'm nervous about using a different IDE or text editor when I'm first learning. Do you think I should stick with my MBP, or use Windows for learning?

    Again, any other advice/tips would be greatly appreciated. Thank you.

    edit: Grammar - just realized I accidentally wrote "started" instead of "starting" in the title.

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

    Starting robotics research with a Docker; could use some help getting context.

    Posted: 01 Jun 2019 12:18 PM PDT

    So I've gotten robotics research in school (currently an undergrad) and I've been thrown into something totally foreign and admittedly maybe a bit out of my current skill level for the moment--though I'd love to push passed this boundary. My question's two fold:

    First of all,

    I'm supposed to learn [Docker]( https://www.docker.com/products/docker-enterprise ) but I have no idea what it is. I'm comfortable with Python (took Berkeley's 61a) but I'm not sure what all these technical nuances and jargon stands for. From the Docker website:

    "Docker Enterprise is the only end-to-end platform for building, sharing and running container-based applications, from the developer's desktop to the cloud and managing the entire application lifecycle at every stage"

    "end-to-end platform; container-based applications; application lifecycle" can someone ELI5 what these mean? One problem I have with learning tech jargon is that something is often described with terms I don't know, and when I look up those terms that rabbit hole continues. Can someone give me a basic, fundamental, and maybe analogy driven (with connections to general knowledge) what these all mean? That'll be super useful

    Secondly,

    My task verbatim is to: "create a task manager class for monitoring dockers that can re-instantiate docker containers if they error out "

    Again, can someone unpack this for me as if they were talking to a fire year old? Would be super useful!"

    Thanks in advance

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

    Are any Universities particularly well known for their CS programs?

    Posted: 01 Jun 2019 08:07 AM PDT

    Through my current employer, we are given free access to Coursera, which provides curriculums for a range of topics and degree programs. Now, I obviously don't expect this to take the place of a real degree, but I appreciate the chance to learn in somewhat of a University setting. When I search "JavaScript" I get results for classes from Duke, John's Hopkins, U Michigan, NYU, plus some international (Russia and China), etc. Does the name matter? Or should I just choose a course based on its syllabus? My goals are to learn JS over the next two years well enough to find a job and quit my current industry.

    Edit: I signed up for the Duke University course simply because it was the first listed option, if that information matters here

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

    creating a twitter bot account that posts random photos from a folder every x amount of hours/minutes?

    Posted: 01 Jun 2019 08:06 AM PDT

    I have a small background in programming, but I'm interested in creating a twitter account that will post photos/memes I have saved in a folder on my pc. I've seen a lot of these account popping up lately but have no clue how it's done. A good example would be @spongebscreens on twitter or @simpscreens.

    My goal isn't to do it with a tv show, just a collection of photos that I have picked out to add into the folder.

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

    Problems connecting my MongoDB "cluster" to project ( "deprecated string" useNewUrlParser )

    Posted: 01 Jun 2019 11:41 AM PDT

    This is the string I was given to access the database:

    "mongodb+srv://xxx:xxx@cluster0-6elhw.mongodb.net/test?retryWrites=true&w=majority"

    Hidden details for obvious reasons, but I get an error that the syntax is "deprecated" and that I should use {useNewUrlParser: true } but I don't know how to fix this.

    (node:8612) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect. Server started on port 5000 MongoDB Connected...

    I would assume that I need to either change the current version of mongoDB or to have some special syntax added. Should I just ignore the warning?

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

    Help with MPI programming

    Posted: 01 Jun 2019 07:35 AM PDT

    Hi all I am trying to learn the basics of MPI programming but I have an error :

    munmap_chunk(): invalid pointer, it does it with large numbers of NM

    #include<stdlib.h> #include<mpi.h> #include<unistd.h> #include<stdio.h> #include <random> // declare columns // 4 variables x and y for p q r t // may be an easier way to do this // this will result in N*N tupples of x and y for each iteration using namespace std; default_random_engine generator; int main() { // declare control and MPI variables int MAX = 2000; int NM = 1000; int K = 500; int np; int rank; MPI_Init(NULL,NULL); MPI_Comm_size(MPI_COMM_WORLD, &np); MPI_Comm_rank(MPI_COMM_WORLD, &rank); int N = NM/np; //...... set up the kmeans variables these variables should be viewable by all nodes ......// //..........MEANS ARE GLOBAL - ARE ONLY UPDATED IN RANK 0..........// double start, end; double * meansx = new double[K]; double * meansy = new double[K]; double * means_tempx = new double[K]; double * means_tempy = new double[K]; double * XM = new double[K*NM]; double * YM = new double[K*NM]; double * X = new double[K*N]; double * Y = new double[K*N]; double temp; double * distance = new double[K*K*N]; normal_distribution<double> * distsx = new normal_distribution<double>[K]; normal_distribution<double> * distsy = new normal_distribution<double>[K]; int cluster = 0; int * Mresult = new int[K * NM]; int * Mest_result = new int[K * NM]; int * result = new int[K * N]; int * est_result = new int[K * N]; /* for calculating final means*/ double * sum_x = new double[K]; double * sum_y = new double[K]; int * count_x = new int[K]; int * count_y = new int[K]; /* use MPI reduce to calcualte these*/ double * Gsum_x = new double[K]; double * Gsum_y = new double[K]; int * Gcount_x = new int[K]; int * Gcount_y = new int[K]; //...... the environment is now set up so move on to sharing the chunks of data needed by each node ......// // ........ start the MPI sharing of data this step includes populating observations in master ................. // if(rank==0){ for (int i = 0; i < K; i++) { normal_distribution<double> distributionx(i*5.0, 2.0); normal_distribution<double> distributiony(i*5.0, 2.0); distsx[i] = distributiony; distsy[i] = distributiony; meansx[i] = i*5; meansy[i] = i*5; } for (int i = 0; i < NM*K; i++) { for (int j = 0; j < K; j++){ XM[j*N + i] = distsx[j](generator); YM[j*N + i] = distsy[j](generator); } } for (int i = 0; i < K * NM; i++) { Mresult[i] = cluster; Mest_result[i] = 0; if (i % 10 == 0) { cluster++; } } for (int i = 0; i < K * N; i++) { result[i] = cluster; est_result[i] = 0; if (i % 10 == 0) { cluster++; } } //........................end populate data items.................// //........................broadcast items ............... ... // start = MPI_Wtime(); MPI_Scatter(XM, N*K, MPI_DOUBLE,X, N*K, MPI_DOUBLE, 0, MPI_COMM_WORLD); MPI_Scatter(YM, N*K, MPI_DOUBLE,Y, N*K, MPI_DOUBLE, 0, MPI_COMM_WORLD); MPI_Scatter(Mest_result, N*K, MPI_INT,est_result, N*K, MPI_INT, 0, MPI_COMM_WORLD); } else{ MPI_Scatter(XM, N*K, MPI_DOUBLE,X, N*K, MPI_DOUBLE, 0, MPI_COMM_WORLD); MPI_Scatter(YM, N*K, MPI_DOUBLE,Y, N*K, MPI_DOUBLE, 0, MPI_COMM_WORLD); MPI_Scatter(Mest_result, N*K, MPI_INT,est_result, N*K, MPI_INT, 0, MPI_COMM_WORLD); } //......................end broadcast items ............... ... // MPI_Barrier(MPI_COMM_WORLD); //..... PARALLEL REGION .......................................// for(int iter = 0; iter < MAX; iter++){ for (int i = 0; i < N*K; i++) { for (int j = 0; j < K; j++) { distance[i*(K)+j] = sqrt(pow(X[i] - meansx[j], 2) + pow(Y[i] - meansy[j], 2)); // printf("x is %f and y is %f cluster is %d mean X is %f mean Y is %f distance is %f\n",X[i], Y[i], j, meansx[j], meansy[j], distance[i*(K)+j]); } } for (int i = 0; i < N*K; i++) { int index = 0; temp = distance[i*(K)]; for (int j = 0; j < K; j++) { if (distance[i*(K)+j] < temp) { temp = distance[i*(K)+j]; est_result[i] = j; } } } for(int k =0; k<K; k++){ sum_x[k] = 0; sum_y[k] = 0; count_x[k] = 0; count_y[k] = 0; } for (int i = 0; i < N*K; i++) { for (int k = 0; k < K; k++) { if (est_result[i] == k){ sum_x[k] += X[i]; //printf("k was %d est_result[i] was %d X[i] was %f sum was %f\n", k, est_result[i],X[i], sum_x[k]); } if (est_result[i] == k) { count_x[k] += 1; } if (est_result[i] == k) { sum_y[k] += Y[i]; } if (est_result[i] == k) { count_y[k] += 1; } } } //printf("sum x 0 is %f for %d \n", sum_x[0], rank); MPI_Barrier(MPI_COMM_WORLD); MPI_Reduce(sum_x, Gsum_x,K, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); MPI_Reduce(sum_y, Gsum_y, K, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); MPI_Reduce(count_x, Gcount_x, K, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); MPI_Reduce(count_y, Gcount_y,K, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); if(rank==0){ for (int i = 0; i < K; i++) { means_tempx[i] = (sum_x[i] / count_x[i]); means_tempy[i] = (sum_y[i] / count_y[i]); } // x is same y is same int xsm = 0; int ysm = 0; // set meansx to temp for (int i = 0; i < K; i++){ if (means_tempx[i] == meansx[i]){ xsm++;} meansx[i] = means_tempx[i]; } for (int i = 0; i < K; i++){ if (means_tempy[i] == meansy[i]) { ysm++;} meansy[i] = means_tempy[i]; } if (ysm == K && xsm == K) { printf("converged after %d", iter); //printf(" cluster %d has : %d observations\n",i,Gcount_x[i]) ; //iter = MAX; } } // printf(" got this far %d %d \n", rank, iter); } if(rank==0){ end = MPI_Wtime(); double timeT = end - start; printf("took %f seconds \n", timeT); for (int i = 0; i < K; i++){ //printf(" cluster %d has : %d observations\n",i,Gcount_x[i]) ; } } MPI_Finalize(); } 
    submitted by /u/hlhluuj46u
    [link] [comments]

    Discovery of Learning Resources on the Internet

    Posted: 01 Jun 2019 01:24 AM PDT

    Hello guys, it's not strictly related to programming but I think it is very important and everyone, especially new programmers, should know this. I have got a simple and yet powerful tip. Use Brave and DuckDuckGo. You will discover a lot of new and interesting websites. Chrome and Google don't give them any chance.

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

    How do I create nested objects in c++, the RIGHT way.

    Posted: 01 Jun 2019 10:54 AM PDT

    So basically, I want to create an array in c++, that contains arrays, that contains objects. Here is the javascript equivalent:

    var array=[[{},{},{},{},{}],[{},{},{},{},{}],[{},{},{},{},{}],[{},{},{},{}],[{},{},{},{},{},{}]];

    Can I do this WITHOUT tuple or c++17?

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

    How do I go about my resources ?

    Posted: 01 Jun 2019 10:50 AM PDT

    I have been referring multiple resources to learn programming books , sites , competition , reading pre written code , codewars , you name it .. now pertaining a single book i.e "Primer" I really don't know how to go about that book. I mean I've read it and all but then again it doesn't really tell me write any code or for that matter doesn't even show that much of code in it's text .. it's conceptually enlightening GIVEN , but still do just read it once and then give the practical paet a try or do I continue simultaneously reading and writing OR do I simply do the practical stuff and go back to referring a validated text where I am stuck ?

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

    deeplearning.ai Coursera Course or Microsoft edX Course?

    Posted: 01 Jun 2019 10:49 AM PDT

    I'm currently deciding between Principles of Machine Learning: Python Edition and Introduction to Tensorflow by deeplearning.ai. I've done some introductory work in Python and I know all the basics and things that would be taught in a basic introductory course, and I want to dive into Machine Learning. I don't know which one is better for a more beginner approach or just better overall. Any advice would be appreciated, thanks!

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

    [C++14] are member pointers freed automatically by the default destructor?

    Posted: 01 Jun 2019 10:47 AM PDT

    So lets say I have a class with a pointer and then have a method which invokes the new keyword on that pointer, for example:

    class A{ int * ptr; void dumb() { ptr = new int[500]; } } 

    called through:

    int main(){ A a; a.dumb(); } 

    For some reason this doesn't cause a memory leak in my IDE, although I definitely think it should?

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

    Need help to convert c# code to java/c++

    Posted: 01 Jun 2019 10:37 AM PDT

    Problem statement :
    Given row and col values determine whether a matrix exists or not
    For ex:
    3 2 (dimensions)
    2 1 0 (row values)
    1 2 (col values)
    Output : Matrix Possible

    3 3
    3 2 1
    1 2 2
    Output : Matrix Not Possible

    I have following code in c# which achieves the required result (using Havel-Hakimi theorem ) :

    public class Pair

    {

    public int Count;

    public int Length;

    }

    public class PairsList

    {

    public LinkedList<Pair> Pairs;

    public int TotalCount;

    }

    class Program

    {

    static void Main(string[] args)

    {

    int[] rows = new int[] { 0, 0, 1, 1, 2, 2 };

    int[] cols = new int[] { 2, 2, 0 };

    bool success = Solve(cols, rows);

    }

    static bool Solve(int[] cols, int[] rows)

    {

    PairsList pairs = new PairsList() { Pairs = new LinkedList<Pair>(), TotalCount = 0 };

    FillAllPairs(pairs, cols);

    for (int r = 0; r < rows.Length; r++)

    {

    if (rows[r] > 0)

    {

    if (pairs.TotalCount < rows[r])

    return false;

    if (pairs.Pairs.First != null && pairs.Pairs.First.Value.Length > rows.Length - r)

    return false;

    DecrementPairs(pairs, rows[r]);

    }

    }

    return pairs.Pairs.Count == 0 || pairs.Pairs.Count == 1 && pairs.Pairs.First.Value.Length == 0;

    }

    static void DecrementPairs(PairsList pairs, int count)

    {

    LinkedListNode<Pair> pair = pairs.Pairs.First;

    while (count > 0 && pair != null)

    {

    LinkedListNode<Pair> next = pair.Next;

    if (pair.Value.Count == count)

    {

    pair.Value.Length--;

    if (pair.Value.Length == 0)

    {

    pairs.Pairs.Remove(pair);

    pairs.TotalCount -= count;

    }

    else if (pair.Next != null && pair.Next.Value.Length == pair.Value.Length)

    {

    pair.Value.Count += pair.Next.Value.Count;

    pairs.Pairs.Remove(pair.Next);

    next = pair;

    }

    count = 0;

    }

    else if (pair.Value.Count < count)

    {

    count -= pair.Value.Count;

    pair.Value.Length--;

    if (pair.Value.Length == 0)

    {

    pairs.Pairs.Remove(pair);

    pairs.TotalCount -= pair.Value.Count;

    }

    else if(pair.Next != null && pair.Next.Value.Length == pair.Value.Length)

    {

    pair.Value.Count += pair.Next.Value.Count;

    pairs.Pairs.Remove(pair.Next);

    next = pair;

    }

    }

    else // pair.Value.Count > count

    {

    Pair p = new Pair() { Count = count, Length = pair.Value.Length - 1 };

    pair.Value.Count -= count;

    if (p.Length > 0)

    {

    if (pair.Next != null && pair.Next.Value.Length == p.Length)

    pair.Next.Value.Count += p.Count;

    else

    pairs.Pairs.AddAfter(pair, p);

    }

    else

    pairs.TotalCount -= count;

    count = 0;

    }

    pair = next;

    }

    }

    static int FillAllPairs(PairsList pairs, int[] cols)

    {

    List<Pair> newPairs = new List<Pair>();

    int c = 0;

    while (c < cols.Length && cols[c] > 0)

    {

    int k = c++;

    if (cols[k] > 0)

    pairs.TotalCount++;

    while (c < cols.Length && cols[c] == cols[k])

    {

    if (cols[k] > 0) pairs.TotalCount++;

    c++;

    }

    newPairs.Add(new Pair() { Count = c - k, Length = cols[k] });

    }

    LinkedListNode<Pair> pair = pairs.Pairs.First;

    foreach (Pair p in newPairs)

    {

    while (pair != null && p.Length < pair.Value.Length)

    pair = pair.Next;

    if (pair == null)

    {

    pairs.Pairs.AddLast(p);

    }

    else if (p.Length == pair.Value.Length)

    {

    pair.Value.Count += p.Count;

    pair = pair.Next;

    }

    else // p.Length > pair.Value.Length

    {

    pairs.Pairs.AddBefore(pair, p);

    }

    }

    return c;

    }

    }

    Can someone help me with c++/java version of about code. (it seems to use Havel-Hakimi theorem and I am not really familiar with c# to understand the logic behind it but i was able to run above code with some googling)

    Would really like help with conversion as java/c++(familiar with) will give me better understanding about the method/algorithm used in above code

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

    [java] Adding background music that runs in IntelliJ console

    Posted: 01 Jun 2019 10:29 AM PDT

    So i want to add background music to a program but the code I'm using halts the program instead of running it in background because of the Thread.sleep() method

    public static void playMusic(String filePath, int time) { try { File file = new File(filePath + ".wav"); Clip clip = AudioSystem.getClip(); clip.open(AudioSystem.getAudioInputStream(file)); clip.start(); Thread.sleep(time); } catch (Exception exc) { System.err.println(exc.getMessage()); } } 

    Is there any way I could add a music file that runs through the entirety of the program in the background?

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

    No comments:

    Post a Comment