r/programminghelp • • Sep 09 '21

Python Solving for a 'self-referential' matrix equation in python

3 Upvotes

For lack of a better title.

I am looking to solve the equation:

V = A @ V @ A.T + Q

for a square matrix V, where A and Q are square matrices.

Any help appreciated.


r/programminghelp • • Jul 17 '21

C# Memory Scanner & Files Spread Across Multiple Pages?

3 Upvotes

I am building (well, tweaking) a C# memory scanner to extract images, text, etc. from live memory. My question is, is it possible for various forms of data to be spread across multiple memory pages? For example, a JPEG file might start in one page, and end in another? Or is it wholly allocated into a single page?


r/programminghelp • • Jun 20 '21

Java Where can the "new" keyword in java be used?

3 Upvotes

Currently learning java and I have seen over time the keyword "new" used like the example below. What I want to know is how does it work in this case?

 LinkedList<Customer> queue = new LinkedList();
        queue.add(new Customer("Sally"));
        queue.add(new Customer("Ben"));
        queue.add(new Customer("Emma"));
        queue.add(new Customer("Fred"));

I understand that the keyword "new" is used to instantiate a object reference to a class. From there we are able to access methods attributes and other things from within that class. But I can't understand what the above code is doing and why we are instantiate again? Also the word Customer is a class. New to collection's also how can a class be a field for a Linked List.


r/programminghelp • • Jun 15 '21

HTML/CSS 2nd day at programming. I need help.

3 Upvotes

Hey guys! I'm changing my major to computer science this fall and I wanted to get a headstart and start learning HTML and CSS. Right now, I'm attempting to make a shitty ironic website. I've been trying to figure out how to make 2 images and some text stay on the same line, but I can't figure it out. Here's my code. https://pastebin.pl/view/ee49e943 Thanks you guys!


r/programminghelp • • Jun 14 '21

Other I have an idea but don't know how to do it

3 Upvotes

I started programming recently and I would like to turn my idea to a program that would help me a lot. Basicaly what I want to do is: I introduce 2 different lists of numbers and then press a button and a messagebox or something like that shows and write the common numbers between the 2 lists. I learned how to programme in visual basic so that would be the easiest language for me, but any type of help would be appriciated. I'm sorry if this is not the right place to post this.


r/programminghelp • • Jun 09 '21

Other Visual studio code pushing to empty repo just hangs/is stuck when I push.

3 Upvotes

I'm following the instructions from this video. https://youtu.be/0e6LqN2LvRM

At the very end when I choose Push to...and select the remote, the wheel just spins forever. It's definitely stuck. Nothing on my GitHub.


r/programminghelp • • May 05 '21

Python Python or c# ?

3 Upvotes

Trynna develop a game and thought id start with python to learn some programming basics and in case the game developing didn’t work i could use python in a job or something in the future, i wanna use gd script which is very similar to python and and can only be used in godot engine and the best for the engine. Also i wanna learn c# later to use it with unity.

Should I continue my plans or stop learning python and only focus on c# cause it’s also usable in godot.


r/programminghelp • • Apr 10 '21

Answered printf not showing the real values of those I chose, but showing 3 similar random numbers from nowhere. why is that?

3 Upvotes
 \#include<stdio.h>

 int main(int argc, char*** argv) {

     double a, b, c, x1, x2, x;

     scanf_s("give the constants a,b and c of ax\^2 + bx + c = 0 such that a = %lf, b = %lf, c = %lf\\n", &a, &b, &c);

     printf("a= %lf b= %lf c= %lf\\n", a, b, c);



     return 0;

 }

example, when debugging and writing 6 7 8, it print a=-9255963134931.... (same for b and c)


r/programminghelp • • Mar 16 '21

HTML/CSS Images in HTML file not showing up after being put into cyberduck.

3 Upvotes

I had an HTML file with images that worked perfectly. However, when I uploaded all the HTML files and pictures to the same place in Cyberduck, the images no longer show up and are replaced with the alternate line. I have tried every solution I have found on the internet and nothing works. I have also made sure it is not a spelling error. Any help is appreciated.


r/programminghelp • • Feb 16 '21

JavaScript After hitting the "PayNow" button the page refreshes and the console log does not open with correct statements. (HELP pls)

3 Upvotes

First here is my HTML Code: https://pastebin.com/Rxbn6092

Next here is the Javascrpt code: https://pastebin.com/4UcH8wR8 (This is where I believe the problems is, but not sure. Been trying to figure this out the last couple of days and still not sure why I don't get an actually output.

So this is suppose to be a baic credit card processing form, but I'm somehow messing it up. (still new to html) After hitting the PayNow button I would like the page to confirm payment, and if you enter the wrong zip/cvc there should be an error message, but it does not work. Any ideas, I'd love any help thanks in advance!

Ex of the console box output wanted: https://gyazo.com/bd209c49c037681c2ab93118e77a9ee2

This is example is kindof poor, since the paynow is not a button, but an image that is required to use, any way to fix my issues?


r/programminghelp • • Feb 12 '21

Java World Series Champions assignment

3 Upvotes

Hey so I was wondering if someone can help me understand what I"m doing wrong with this Java program assignment "World Series Champions"
so basically I need to write a program that lets the user enter a team name and indicate how many times they won the World Series through the Time Period 1903-2009.

I got everything else down except when it finds a team it says that team is not on the list so need help understanding what I'm doing wrong here so I can fix it

package com.WorldSeries;
// Solution to Spring 2021 COSC-1337-004 Program #2: World Series Problem
// Given the number of games in a series, and the probability of a team
// winning an individual game, this program will calculate the probability
// of the team winning the series.
import java.io.*;
import java.util.*;
import javax.swing.JOptionPane;
/**
* This is a program for Assignment 2: World Series Champions of Spring 2021 COSC-1337-004
*/
public class Main {
public static int count = 0;
public static String output = "";
public static String input = "";
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
final String FILENAME = "WorldSeriesWinners.txt";
ArrayList<String> data = new ArrayList<String>();
// Read the data file
int reply = JOptionPane.showConfirmDialog(null,
"Do you want to use the default file " + FILENAME + "?",
"Do you want to use the default file?",
JOptionPane.YES_NO_OPTION);
if (reply == JOptionPane.NO_OPTION)
System.exit(0);
else {
// Read the data from file.
try {
data = readData(FILENAME);
} catch (IOException e) {
}
}

// Sequential search the String array and print the result
reply = JOptionPane.YES_OPTION;
while (reply == JOptionPane.YES_OPTION) {
count = 0;
output = "";
input = JOptionPane.showInputDialog(null,
"What team do you want stats on?");
if ((input != null) && (input.length() > 0)) {
boolean found = sequentialSearch(data, input);
if (found == true) {
JOptionPane.showMessageDialog(null, output);
} else {
JOptionPane.showMessageDialog(null,
"Can't find the team in the list.");
}
}
reply = JOptionPane.showConfirmDialog(null,
"Do you want to search for another team?",
"Do you want to search for another team?",
JOptionPane.YES_NO_OPTION);
}
System.exit(0);
}

/**
* The readData method reads the data from a text file 'filename' and save
* Strings in an ArrayList.
* u/param filename The file name of the text file to be read.
* u/return The ArrayList contains all Strings from the text file.
* u/throws IOException
*/
public static ArrayList<String> readData(String filename) throws IOException {
ArrayList<String> data = new ArrayList<String>();
File file = new File(filename);
Scanner inputFile = new Scanner(file);
while (inputFile.hasNext()) {
data.add(inputFile.nextLine());
}
inputFile.close();
return data;
}

/**
* The sequentialSearch method sequential search the String 'name' in the
* ArrayList 'array'.
* u/param array The ArrayList to search from.
* u/param name The String to search.
* u/return The boolean if String 'name' is found in ArrayList 'array'.
*/
public static boolean sequentialSearch(ArrayList<String> array, String name) {
final int STARTYEAR = 1903;
int year;
boolean found = false;
for (int index = 0; index < array.size(); index++) {
if (array.get(index).compareTo(name) == 0) {
count ++;
year = STARTYEAR + index;
if ((year >= 1904) && (year < 1993))
year = year + 1;
else if (year >= 1993)
year = year + 2;
output = output + Integer.toString(year) + ", ";
found = true;
}
}
output = "The " + input + " have won the World Series in the years:\n" +
output + "\nand won the World Series " + count + " times.";
return found;
}

}


r/programminghelp • • Feb 01 '21

Java What is a public void input?

3 Upvotes

Hello, I am currently working on a Java assignment, but I have never come across this phrase before, and my prof. won't get back to me. This is my assignment:

"

Write a class in Java named Student whose UML class diagram is shown below. The default (no-parameter) constructor should initialize the String data members to the empty String( “ “) and the double member to 0.0. The input method should allow users to input the values of the object’s data members using prompted console input. Do not use pop-up dialog boxes for this input! The toString( ) method is important for effective output. Note that in the diagram, private access is denoted with a minus sign ( - ) and public access is denoted with a plus sign ( + ).

Student class

- String name //Student Name

-String id //Student ID (s + 8 digits)

- double gpa //Student GPA (0.0 tp 4.0)

+Student() //Default constructor

+Student(String, String, double) //All parameters contructor

+String toString()

+void input() //Console input of Student object

+void set(String, String, double) //Sets all instance variables

+String getName()

+String getID()

+String getGPA()

"

My code so far:

import java.util.Scanner;

public class Student
{
    private String name;
    private String id;
    private double gpa;
    
    public Student(String n, String i, double g)
    {
        name = n;
        id = i;
        gpa = g;
    }
    
    public String toString()
    {
        return( name +
                "\ntheir student id is : "+ id + 
                "\nand their gpa is : "+ gpa);
    }
    
    public void input()
    {
        
        
    }
    
    public void set(String n, String i, double g)
    {
        name = n;
        id = i;
        gpa =g;
    }
    
    public String getName()
    {
        return name;
    }
    
    public String getID()
    {
        return id;
    }
    
    public double getGPA()
    {
        return gpa;
    }
}

Any help as to what it is that I'm supposed to do with the public void input() would be absolutely appreciated.


r/programminghelp • • Jan 07 '21

C++ How do I set up the vulkan sdk for visual studio code?

3 Upvotes

I am trying to follow vulkan-tutorial.com but they use Visual Studio and I want to use VSCode. I have tried for about 2 hours and nothing worked (The sdk installed fine but I don't know how to include it in my includepath).

My sdk folder incase it helps: https://prnt.sc/wihea4


r/programminghelp • • Jan 06 '21

JavaScript Questions about express.json() and express.urlencoded()

3 Upvotes

Is there ever a scenario you would want extended: false instead of true as a parameter in urlencoded?

I understand urlencoded is used to parse URL encoded bodies and express.json() is used to parse JSON objects but why can't they combine the two? I've seen these are commonly used in tandem but are there some who would prefer to use one and not the other?


r/programminghelp • • Jan 03 '21

Python Need help understanding time complexity of this code

3 Upvotes

I have two loops like so that runs over a list of numbers with n elements

  for n in numsList:
       heapq.heappush(heap, n)
  while heap:
        num = heapq.heapop(h)

The time complexity of first loop is nlogn since there are n elements and the heap needs to maintain the heap property when elements are inserted (heapify on each loop) so it is nlogn ( n elements x heap insert cost for each element which is logn)

While the second loop, runs for n elements and heappop takes logn times for each run so overall for second loop is nlogn again?

I am not clear on either actually especially the second loop where I believe it should be n instead of nlogn.

Thanks!


r/programminghelp • • Dec 15 '20

Answered Visual Code refusing to install

3 Upvotes

So I was planning to learn C# and for that I needed Visual Code for programming. I downloaded the exe file but when trying to install the IDE, it says the community version isn't available because my PC doesn't meet requirements, although I have Windows 10 with 4GB RAM and all required specs.

How do I fix this issue?

Edit: the reason I faced this problem is because I have Windows 10 Professional version 10.0 which is the earliest version and VSS doesn't support it. As a solution, I'll suggest the reader if they can upgrade to the latest version of Windows OS as relevant at your time or install MonoDevelop as a temporary alternative. Kudos to all who helped me in this situation.


r/programminghelp • • Dec 09 '20

Answered Help with some coding homework...

3 Upvotes

So my teacher is using code.org. I hate it, I prefer scratch over it. Even though scratch got the majority vote we're stuck with this and I can't figure out how to do this.

Here's what I'm at

I was able to do most of it. I got the bee halfway through the path, and I need some help figuring out some decent code for this.

Oh! And even worse, requirements...

Use a function and name it

Use a variable and name it

Make your variable change

Use a conditional

Use a loop

Use less than 29 blocks

I've watched youtube video after youtube video, website after website. It's just so hard lmao

https://drive.google.com/file/d/1Ely--hnZbnxgE0eS9z2G4od09sQjntBo/view?usp=sharing

There's my work so far.


r/programminghelp • • Oct 21 '20

Other Inverting Mouse Axis

3 Upvotes

Hey Guys,

I'm absolutely new to this and wanted to ask if theres a way for a simple batch file or anything similar, that inverts the mouse X and Y-Axis with the input of a button and the other way around? Help would be much appreciated.


r/programminghelp • • Oct 16 '20

Python (Python) I can’t figure out why my script won’t work.

3 Upvotes

So, I’m doing work for my class and we’re using elif logic, and it simply won’t work. The problem is coming from line 3, but no matter how hard I try other solutions it doesn’t work. Please help me figure out what’s wrong with it.

The script: print(‘This script will ask you for an answer to the equation {X+5}>6. ‘)

x = input(‘x: ‘)

If x <= 1:

print(‘false’)

else:

print(‘true’)

Edit: Sorry for formatting, I’m on mobile.


r/programminghelp • • Oct 16 '20

Python Monitoring Time Spent on Websites

3 Upvotes

Hey there everyone, I'm currently working on a personal project to get me to stop procrastinating by monitoring how much time I've spent on a particular website (i.e. YouTube, Reddit, Netflix, etc) and closing the tab in question after a given amount of time. Does anyone have some advice as to how I can access that information and how I can get the tab to close, or is there documentation you could refer me to? Thanks so much! (I'm using Python but if that's the wrong language - which is entirely possible given my lack of real experience - let me know!)


r/programminghelp • • Oct 08 '20

JavaScript Safest way to add credentials?

3 Upvotes

I have web app (vanilla js) and I need to add credentials of a rest api. Question is how to hide them? I don’t that someone could peak in to js via inspector and get credentials.


r/programminghelp • • Sep 30 '20

C Linking to liblua.a file with Linux and GCC

3 Upvotes

I'm following a tutorial about embedding Lua in c++ and I'm following along but in C and with the intention to compile for Linux. The guy in the tutorial is using Visual Studio 2017 and links to liblua.a by doing

#ifdef _WIN32
#pragma comment(lib, "Lua540/liblua54.a")
#endif

How do I do this but for GCC?


r/programminghelp • • Sep 22 '20

Java Why might I be getting a "cannot find symbol" error when compiling my code?

3 Upvotes

I am working on a graphics engine for the upcoming Ludum Dare Game Jam and I have almost no experience working with the Java Advanced Window Toolkit nor Swing but the are my best options. Currently I am stuck on a cannot find symbol error in this function in GGraphics.java (which extends java.awt's Canvas class):

public void paint(Graphics g) {
    long pStackLength = this.pStack.getPointer();
    int polySize;
    for (long i = 0; i < this.pStack.getSize(); i++) {
        GPoly currentPoly = this.pStack.pop();
        g.setColor(currentPoly.getColor());
        //the monster of a line below draws a filled polygon with the integered xPoints and yPoints and the length of that list
	g.fillPoly(currentPoly.intPoints(this.width, this.height)[0], currentPoly.intPoints(this.width, this.height)[1], currentPoly.getPointCount());
    }
}

When I compile all of my files I receive the following:

GGraphics.java:69: error: cannot find symbol
			g.fillPoly(currentPoly.intPoints(this.width, this.height)[0], currentPoly.intPoints(this.width, this.height)[1], currentPoly.getPointCount());
          ^

I don't know why it can't find the symbol, it is inside the function scope.

edit: It seems as though the text box formatting is kinda weird, so ill specifically say that the karat points to the "y" in currentPoly.getPointCount().

edit2: I’ve scrapped lots all of the game engine and I’m partially starting over


r/programminghelp • • Aug 12 '20

Java Kotlin - coroutines and channels

3 Upvotes

I have an app where one of the features is bulk import. I want to do it so that the user can upload 10k records, another one can make a similar request at the same time, and I want to do it all in the background. the flow should go like this, user1 imports 10k records which I will validate/produce and send it to the Channel -> from another function I should receive data and save it to my DB -> while data is being saved to the DB, another user makes a request for 5k records, again data goes through validate/produce and after all is good I send it to the same Channel -> when consumer is done with the saving of user1 data, he should start with save of the next data from Channel. I guess my question is how can I make this flow that consumer always listens when Channel got some data so he can save i to the DB, and I would like to do it in the background so user can still use app, and another users can also import bulks.

Here is the code I currently have, I know its not good, and for some reason it works. My due date is very close, so I would appreciate any help. Thanks

CODE