Can someone tell me what my teacher means by this? (binary).

Learn Programming - Thu, 01/17/2019 - 20:58
  1. (4 pts) Write the following decimal numbers in both binary and hexadecimal. Pad the binary numbers on the left with zeroes to the nearest four bits.

a. 31

I understand this is 01111 or 11111 in binary. But what does he mean by pad the binary numbers on the left with zeros to the nearest four bits. Can someone explain this please? thank you.

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

Confused, dont know which to focus on...

Learn Programming - Thu, 01/17/2019 - 20:23

Hey everyone, lately i don't know where should I focus on wether it's on front end or back end. I'm currently working as a full time programmer in a small company (5 months), The technologies that they use are JSP(Java), Apache cayenne(ORM), html, css, javascript(jQuery).

Im a bit competent in Java (I think?) and in html, css, javascript are some basics that i know to get me through the projects.

I still have some spare time to study programming and work on my skills but the problem is I dont know which technology should i focus more on? because I heard that learning 2 languages at the same time is a bad idea?

Any advice and help is appreciated, thanks in advance :)

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

program to find primes only crunches 1/5 the numbers but is only .5s faster (python)

Learn Programming - Thu, 01/17/2019 - 20:20

I've been doing a lot of project euler lately, and recently did problem 35. I compelted it no problem, but I discovered the need I have to more efficiently build lists of prime numbers. Before this, I had only implemented Eratosthenes sieve, but I have now researched and built a function that implements a factorization wheel such as from the link below.

My question is, is that I now only pass 20% or so of the numbers that I did before to test if they're prime, yet I only cut time by 1/2 a second (out of 10 seconds for a ceiling of 1 million). why is my gain so pitiful?

old generator:

def primeList(number): #eratosthenes sieve primes = [2] #inital prime list nums = 0 #used for finding total numbers checked for primality for i in range(3,int(number)): #checks all numbers below number (the ceiling given to the function) n = 0 #used for iterating through list of primes nums += 1 #one more number checked for primality while primes[n] <= i**(1/2): #it's only necessary for trial division to check primes below the square root of the candidate if i % primes[n] == 0: #if there's a remainder of zero, it was evenly divided and is not prime break #the break stops the while from continuing to "else" n += 1 #iterate to next prime to check else: #if the while was never broken, i is prime primes.append(i) #add i to the list of primes print("List nums crunched: " + str(nums)) #just for testing, show numbers checked for primality return primes

new generator: (note that it still uses the old generator for the first wheel)

def wheelPrimeList(number): if number < 29: #pick the largest wheel possible, to a point wheelBase = [2,3] #wheel of 6 product = 6 elif number < 209: wheelBase = [2,3,5] #wheel of 30, like wiki page product = 30 elif number < 2309: wheelBase = [2,3,5,7] #wheel of 210 product = 210 else: wheelBase = [2,3,5,7,11] #wheel of 2310 product = 2310 innerWheel = [i for i in range(1,product + 1)] #generate the first circle for i in wheelBase: #remove all multiples of the initial primes from the wheel k = 1 #used to iterate multiples while i * k <= product: #remove all multples within the list #print(i * k) try: #some multples are hit by multiple primes, so try is used to ignore "not found" errors innerWheel.remove(i * k) #remove current multiple from list except: #except not needed pass #ignore k += 1 #iterate k primes = primeList(product) #find all primes within the first circle, this is the only circle with exceptions from the prime list nums = 0 #used for finding total numbers checked for primality while primes[-1] < number: #continue for as long as it's below the ceiling innerWheel = [int(product + i) for i in innerWheel] #generate the next circle in the factor wheel for i in innerWheel: #iterate through prime candidates n = 0 #used for iterating through list of primes nums += 1 #one more number checked for primality while primes[n] <= i**(1/2): #it's only necessary for trial division to check primes below the square root of the candidate if i % primes[n] == 0: #if there's a remainder of zero, it was evenly divided and is not prime break #the break stops the while from continuing to "else" n += 1 #iterate to next prime to check else: #if the while was never broken, i is prime primes.append(i) #add i to the list of primes if i > number: #if the last prime added is above the ceiling break #cancel the rest of the for loop del primes[-1] #remove the last added prime, it is larger than the ceiling print("wheel nums crunched: " + str(nums)) #just for testing, show numbers checked for primality return primes

the actual testing setup:

import time start_time = time.time() print(len(primeList(1000000))) print("primeList time: " + str(time.time() - start_time)) start_time = time.time() print(len(wheelPrimeList(1000000))) print("wheelPrime time: " + str(time.time() - start_time)) #only 0.5s faster

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

New to the programming world.

Learn Programming - Thu, 01/17/2019 - 20:14

Wondering if anyone could give me direction on great sites/bootcamps to learn programming. Right now I use Codecademy to grasp the concept of HTML, CSS and JavaScript. I have a Bachelors degree in an unrelated field so going to get a second one is not really in the cards for me right now. Figured I would check with the Reddit community for a good starting point. Thank you all in advance!

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

I am looking to compile the best web development resources, any ideas?

Learn Programming - Thu, 01/17/2019 - 20:11

I have created a community to teach beginners web development r/beginnerwebdev. We have seen decent growth recently with over 200 subscribers in 4 days. I want to create a sidebar and wiki with good resources and teaching materials for beginners. I figure posting in a subreddit about learning programming would be the best place. You can respond in the comments here or on the resource suggestions thread. Thanks for the help :)

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

Advice on deploying old html and javascript website.

Learn Programming - Thu, 01/17/2019 - 19:58


I have an old webpage(created circa 2011) that used some javascript to create a force directed graphs, basically it consists of a few js files and a simple html file. This isn't using any kind of frame work , its just plain old javascript and a canvas element. I've some free time and I thought it'd be quite interesting to see if I could make the algorithm a bit more efficient, it's been a few years since I've done much web development, so I'm just wondering what the tools would be to re-write this in.

I've looked around and done a bit of reading, I'm pretty comfortable with the latest version of javascript, I understand git and source control etc. I was thinking to just code my changes in atom on my desktop, the only thing I'm really hazy about is a deployment strategy, I was hoping there would be something that I could use that packaged up my javascript files and then uploaded it to my ftp server.

Does anyone have any suggestions? I was thinking webpack? but people always seem to use that in conjunction with react, so I was thinking perhaps that's not what I should be using. Also it would be nice if there was something that could pick up my changes in git after I've pushed them and then just automatically handle the whole process.

Many Thanks


*sorry if this has been asked before, I looked briefly but didnt see.

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

Is there a method of pagination that can reliably sort by a non-stable aggregate parameter?

Learn Programming - Thu, 01/17/2019 - 19:37

I'm building an API which has a component similar to , which is sorted by the number of "active" members in the chat. In twitch this would be translated as viewers.

As you can plainly see, the list in the link is paginated somehow. In my application, viewers would be leaving left and right, resulting in my pagination cursor drifting if I were to specify an offset of viewers.

Is the answer simply to send up from a frontend a list of ids they already have in the pagination set and run the exact same SQL query using a WHERE NOT IN clause? I'm really curious as to how an application like twitch manages to paginate its results by such a drifting number like viewer count.

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

Type of boot camp

Learn Programming - Thu, 01/17/2019 - 19:33

Should I do front end or full stack boot camp. In Toronto if anyone has a boot camp recommendation

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

I want to start working with Amazon MWS - which language is better to learn for it?

Learn Programming - Thu, 01/17/2019 - 19:19
I want to start working with Amazon MWS but I only know how to code in Python. Amazon MWS only supports these languages: PHP, C# and Java. For the sole purpose of working with Amazon MWS, which language would be the easiest/fastest one to learn? submitted by /u/namio5
[link] [comments]

What to learn next?

Learn Programming - Thu, 01/17/2019 - 19:15

So about a month ago I finished a couple python courses and now I don't know what's useful to learn next. I understand the python syntax and can kind of write it. I tried learning django but its too complex for me with the knowledge that I have now. I want to pursue programming as my profession. What is useful to know and learn next? Any tips are helpful :D

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

Super Simple React Todo App

Learn Programming - Thu, 01/17/2019 - 19:08

Hey there, /r/learnprogramming! I just finished making a super simple Todo List App in React so that I could learn and understand it a little bit better. Here it is:

What I want feedback on:

  1. Am I making correct use of functional vs. class components?
  2. Is there any code where there was a lot of unnecessary stuff written in?
  3. Are the comments good and sufficient?
  4. With the deletion feature in specific, could it have been implemented better?
  5. Do I violate React conventions at any point in time?
  6. [Insert Whatever Else You Think Could Be Better]

Any feedback would be appreciated! Thank you all for your kind consideration!

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

Trying to create an IF statement to compare three objects

Learn Programming - Thu, 01/17/2019 - 19:07

Hey! I'm just looking for some homework help here. I'm trying to get this line of code to work where it will compare the heights of some basketball players. When I try and start an if statement, I get the error:

"bad operand types for binary operator >"

Heres the code I'm looking at right now:

package Modded; public class Moddded { BasketballPlayer player1, player2, player3; public Modded() { player1 = new BasketballPlayer("John Smith", 170, "St Louis"); player1.getHeight().setFt(5); player1.getHeight().setIn(11); player2 = new BasketballPlayer("Joe Green", 180, "Minneapolis"); player2.getHeight().setFt(5); player2.getHeight().setIn(8); player3 = new BasketballPlayer("Liam Gray", 200, "Houston"); player3.getHeight().setFt(6); player3.getHeight().setIn(3); if(player1.getHeight() > player2.getHeight() { }

I have a separate height class as well. Not sure what I'm doing wrong here.

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

[C++] Parallel Arrays with 2D arrays

Learn Programming - Thu, 01/17/2019 - 19:02

I've been refreshing and supplementing my experience with 2D arrays with C++ and I'm working on a program that takes an text file of names and a text file of grades of tests and writes the first one in an array and grades into a 4x4 array but the last column is left empty intentionally.

I recently learned about parallel arrays and I wanna to know if it's possible to have a 1-dimensional array parallel with 2D array?

Here's what my code currently looks like:

It's already able to take the text files and place them in the arrays and displays them successfully like like I described.

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

Tips for documenting and creating comments?

Learn Programming - Thu, 01/17/2019 - 18:56

I'm very bad at commenting my own code (i always forget to do it) , do you have any tips for this?

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

In C, it is said that spaces/white space doesn't matter, but how come this example of Hello World doesn't compile?

Learn Programming - Thu, 01/17/2019 - 18:51

From what I can read on the internet, spaces/white space doesn't matter in C. For example

#include <stdio.h>int main(){printf("Hello World");return 0;}

will run fine

But how come something like this doesn't compile?

#include <stdio.h> int main() { printf("Hello World"); return 0; }

Shouldn't the new line be ignored? Is it a matter of the compiler I'm using? How can I reduce the length of my lines neatly, do you just have to rely on wordwrap of your IDE?

submitted by /u/PyS-C
[link] [comments]

What Laptop should I get?

Learn Programming - Thu, 01/17/2019 - 18:35

I am planning on replacing my old laptop for a new one. I am either think of getting a MacBook Pro or Surface Book 2. I am not sure which to choose.

Currently, I am a highschool student and most of the uses for a new laptop I would have is either for school work or programming, of course. Right now I am in a Python course, but later on, I hope to get into a Java or C++ Course.

I know that both of these choices are just preference, and I like both of them. I just want to hear opinions on what the most optimal laptop is out of the two of these.

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