Programming

Optimizing inputs for max value of 2x + 3y

Learn Programming - Tue, 06/19/2018 - 16:15

I am trying to optimize x and y inputs on the equation 2x + 3y to obtain the max value given that

  1. x+y <= 50
  2. x <= 10
  3. y <= 50
  4. x,y >= 0

I could brute force the parameters, but I want to do to the technique where you plug in the max allowed x and remaining y, max allowed y and remaining x, and max of both (example below)

  1. Maxed both ... x = 10, y = 40
  2. Maxed y ... x = 0, y = 50
  3. Maxed x ... x= 10, y = 0

I'm having trouble formulating the program layout. I could obviously plug in values I know to be the max, but that would just be hard coding. How could I model the constraints so that the code will know to only check three x,y input sets?

Thanks.

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

ps4 and arduino usb host got some troubles a brewing

Learn Programming - Tue, 06/19/2018 - 16:07

so i spent the past days trying to play with a ps4 and usb host sheild for arduino.

eventually to make a stepper record and play system.

so far i have just been seeing what choices i can do as i also dont have much space after the ps4 libs take up to 69% of the arduino.

code so far nothing, has not changed really from the original example.

https://pastebin.com/J2F6rwv3

this is the link to origianl usb host lib :https://github.com/felis/USB_Host_Shield_2.0

and yea i have come into some porblems that im looking for some guidance possible.

problems i have found.

1.when pressing left or right to run the stepper,the first steps are smooth but once it is running it makes loads of noise like the pulse signals are different becasue of the delay needed for the arduino to read all the code and come back to move the next step. is there an easy way to block and run my steprght(); routine untill button released?i cant find anywhere i cant find anywhere in the libs where i could use something like PS4.button.released?

  1. i ust to use the nes controller to control a steppr and could press mulltiple buttons at the same time to do something difrent how would i do that with whats given in the libs?

i.e

if (PS4.getButtonClick(TRIANGLE)) { Serial.print(F("\r\nTraingle")); PS4.setRumbleOn(RumbleLow); }

id bassically like to learn how to add these together.

if (PS4.getButtonClick(CIRCLE)) { Serial.print(F("\r\nCircle")); PS4.setRumbleOn(RumbleHigh); }

like so:

if (PS4.getButtonClick(TRIANGLE)++PS4.getButtonClick(CIRCLE)){ do something different form normal}

is there a way?

3.the other thing id like to learn is how to enter a mode selection function on button pressed and then from there use left and right to select the routine i want to be played/looped. so far i made

typedef void (*PFUNC) (void);PFUNC myfuncs[] = {&routine1, &routine2, &routine3, &routine4, &routine5, &routine6 ,&routine7 };#define CNT_PFUNCS (sizeof(myfuncs)/sizeof(myfuncs[0]))uint8_t ifunc = 0;

so with the code above i made a void routine1(){} for each rountine and id like.

when i press options button to enter a routine select mode where i then press left and right to increment thru the routines to then eventually press x to play that current routine.seems allot when i write it but i dont belive it is.

anyway thats all..i thought id just post them all in one like this to see where it gets me...anyway im going to work tonight so maybe ill advance a bit myself...

thanks

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

I made this site in two weeks. What did I do wrong?

Learn Programming - Tue, 06/19/2018 - 16:04

Hey y'all. I made this (http://www.calebricketts.net) website in two weeks as a side project at work. This is my first time creating an entire website from scratch, and I need opinions for what I did wrong and what I should fix. I researched small website industry standards, and tried to conform to them. I want to make it as high quality as I can.

It was made using Angular js with a Bulma HTML framework. It's hosted by GitPages, if that matters.

edit: fixed the link, now it should be secure. Thanks for that feedback

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

Tips for learning AWS Cloud Computing or some equivalent?

Learn Programming - Tue, 06/19/2018 - 15:56

I'm new to computer science, though I do have limited experience. I've been messing with Python on codecademy, and have used it for a course in college as well, so I'd like to continue using Python. Any suggestions on what route I should pursue to learn AWS or some equivalent? I've looked online but haven't found anything specifically focused on this topic besides the training offered by Amazon itself. Amazon offers a lot of courses but they seem pretty expensive.

I'm considering either teaching myself or doing a coding boot camp. Is this a feasible route? I'm quite motivated and I know that I enjoy coding. Any experience, feedback or advice would be appreciated.

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

Need Advice: Interested in starting a career in Software Development

Learn Programming - Tue, 06/19/2018 - 15:39

I have recently become aware of a 6-month course for "full-stack Web Development", focused on readying students for entry level jobs. The $12,000 program uses Woz-U's coursework. It's expensive, but I think that the environment will be fulfilling because of the great people and Faith-based focus.

I'm interested in an effective and efficient education that will get me started in the industry. I do want to do some type of class, online or in person, because my own motivation wavers at times.

I have been wondering what kind f questions I need to be asking before knowing, truly, if I should be going into a Web Development career. I have always had an affinity for math, science, and divergent thinking. I used to write simple scripts for plugins on my Minecraft server, when I was in High School. Now I think I could make even cooler things, and even get paid. I know I have the brain for it, but I wonder about the pragmatic aspect of making a career out of software development.

I don't want to enter an industry that is going to dry up if/when Net Neutrality falls through. I don't want to enter a company that uses cutthroat business practices. I want to enter a solid field that will help me start a family in the next 5 years.

If you have any insight, or questions that will help me along the way, I would love to hear.

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

C++ - Having issue with cin.sync cin.clear

Learn Programming - Tue, 06/19/2018 - 15:22

Hi guys,

Very new to c++. I'm following along with instructions that are for a slightly different program, but I do not believe it makes a difference. Here is the code snippet that I have:

cout << "Please enter your first test score: "; cin >> test1; while (test1 < 0 || test1 > 50 || !cin) { cin.sync(); cin.clear(); cout << "Invalid test score.. Must be an integer between 0 and 50: "; cin >> test1; }

However, when I run that with 'int test1' = two, it successfully registers that the integer can't store a char or string so it WILL run the while loop. So that's good. But, after it performs cin.sync and cin.clear, it runs cout << "Invalid test score.... blah blah" infinite times. It never actually asks for the user to input test1 again which is what I want.

As an aside: when I enter in an integer of 51+ or any negative number, the loops runs perfectly.

Any suggestions would be super helpful. Thanks.

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

Introducing FundRequest, a marketplace for software development

Learn Programming - Tue, 06/19/2018 - 15:09

FundRequest a platform where organisations can pledge money for development tasks using cryptocurrency micro payments. Developers that solve tasks, by offering pull requests via GitHub are rewarded in cryptocurrency. Tasks vary from beginner to more expert difficulty and in different areas, front-end to backend related requests. An interesting way to start contributing to existing projects while getting rewarded for your work.

https://fundrequest.io/requests

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

C++ exercise

Learn Programming - Tue, 06/19/2018 - 15:08

So the exercise was : Write a program that prompts the user for two integers. Print each number in the range specified by those two integers. I think i wrote the program correctly but would like some input, criticism, etc.

#include <iostream> using namespace std; int main() { int n1 = 0, n2 = 0; cout << "Enter two numbers: " << endl; cin >> n1 >> n2; while(n1 <= n2){ cout << n1 << endl; ++n1; } return 0; } submitted by /u/PvndaK
[link] [comments]

Setting up tesseract API to use in C++program.

Learn Programming - Tue, 06/19/2018 - 14:46

I'm learning C++ and want to mess around with tesseract OCR. I've visited the tesseract project github page and have downloaded & installed the tesseract 4.0 engine on my Windows 10 machine. However, I'm not clear on what steps I need to take to make API function calls and use the API in my C++ program. I think since tesseract is written in C & C++ I won't need to use any bindings. The "for developers" subsection of the readme links me to a big header file, but I'm not sure if all I need is to copy and paste that header file into a visual studio .h file and I'm good, or if other steps will be necessary. If all I need is the header file, then how will the header file know where the tesseract engine I installed is located on my computer in order to use it?

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

Having trouble with cin.sync and cin.clear

Learn Programming - Tue, 06/19/2018 - 14:46

Hi guys,

Very new to c++. I'm following along with instructions that are for a slightly different program, but I do not believe it makes a difference. Here is the code snippet that I have:

cout << "Please enter your first test score: "; cin >> test1; while (test1 < 0 || test1 > 50 || !cin) { cin.sync(); cin.clear(); cout << "Invalid test score.. Must be an integer between 0 and 50: "; cin >> test1; }

However, when I run that with 'int test1' = two, it successfully registers that the integer can't store a char or string so it WILL run the while loop. So that's good. But, after it performs cin.sync and cin.clear, it runs cout << "Invalid test score.... blah blah" infinite times. It never actually asks for the user to input test1 again which is what I want.

As an aside: when I enter in an integer of 51+ or any negative number, the loops runs perfectly.

Any suggestions would be super helpful. Thanks.

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

Understanding Base91 encoding

Learn Programming - Tue, 06/19/2018 - 14:40

I am at a point where I can't grok this particular algorithm. I have managed to mostly figure out Base64 encoding, which involves splitting binary data up into 6-bit chunks instead of 8, and using a translation table into specific ASCII characters. My implementation was naïve though, and I was converting strings to binary numbers and then operating on those actual 0's and 1's...

I found this implementation of Base91 in Python (my language of choice so far), though I've looked at implementations in Java, Haskell, etc. They all seem to do the same or similar things with bitwise-shifts and constants defined by the algorithm specification (I tried reading the source paper, but I had trouble with that as well).

My question: How/why exactly is this algorithm choosing the two letters that each 13-bit block is encoded into, and decoding them in reverse? I know the assignment happens here: out += base91_alphabet[v % 91] + base91_alphabet[v // 91] using modulo and floor division, but the way that v value is calculated involves and, or and right-shift bit operators...

Any help or resources that would help me understand why all the bit-shifting is necessary, or even a tutorial on encoding algorithms would be much appreciated!

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

Can you help me figure out wtf is wrong with my website?

Learn Programming - Tue, 06/19/2018 - 14:31

Hello all,

I feel kind of rude posting this,

but I've built a website - and I've also built an custom tracking tool that saves anonymous data about site visits.

The way this works is that when you click on a different page in my dynamic js website, an ajax request is made and a php script saves an entry of you clicking on that site in a mysql database.

Since I've launched the tracking feature a few days ago - I've seen really strange results. Apparently people refresh the home page 20 times in a row - within a few seconds. Something is clearly broken.

The thing is, I have no idea how to get to the bottom of this, as the website works fine when I use it.

Could anyone maybe help? Point me in the right direction (maybe some of my traffic is from bots who behave strangly?)

I'd appreciate any help :)

Btw - the website is http://matri.design

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

[Algorithms Help] Find Local Max/Min in 2D Array.

Learn Programming - Tue, 06/19/2018 - 14:27

I've been reading around on the internet about this problem, so far I've seen a number of different algos, but there's 3 in particular I'd like to ask about.

  1. Divide by middle column -- O(nlogn)
    • Described on slide 19 of this lecture
  2. Alternate dividing by middle row/column -- O(n)
    • Described in the hint for creative problem 19 of this online book
  3. Window method -- O(n)
    • Described on slides 20-23 of this same lecture

I sort of understand the reasoning around method 3 and why it should be O(n). But when I look at method 1, which has O(nlog), I get confused. The logn factor appears because there's logn divisions of the original problem, I believe. But why doesn't this appear in methods 2 and 3? Are they not also dividing up the original problem?

My guess is that methods 2 and 3 has divisions of the original problem that do not depend on n, but method 1's divisions does depend on n. But why is that?

Many thanks to any insight provided!

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

User login in kotlin

Learn Programming - Tue, 06/19/2018 - 14:25

Hi, I'm learning kotlin and started building an app. I've finished most of the UI but now I want to connect the app to a database so I have a login and a register feature but I don't know how to proceed do I connect to the DB directly or build something in php that relays the data? I also want it to be secure authentication (something with a public and a private key)

I really need some directions on how to proceed with this cause I'm really stuck and some searches I did didn't prove useful

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

Pages