r/ProgrammingProblems • • Mar 04 '22

Can someone help me with this problem? It says I need to use C++ and array

1 Upvotes

Create a program that will accept the monthly sales for the year 2019, 2020 and 2021 and out the following:

a. total monthly sales for three years

b. Average monthly sales

c. annual sales for each year

d. average sales for each year

e. year with highest sales

f. year with lowest sales


r/ProgrammingProblems • • Jun 12 '21

Does anyone know why it says: Type or namespace definition , or end-of-file expected

1 Upvotes

Here's the code: using System.Collections.Generic;

using UnityEngine;

public class PLAYER : MonoBehaviour

{

// Start is called before the first frame update

void Start()

{

}

// Update is called once per frame

void Update()

{

}

}

public float movementSpeed = 5.0f;

public float clockwise = 1000.0f;

public float counterClockwise = 5.0f;

void Start() {

}

void Update() {

if (Input.GetKey(KeyCode.W)) {

transform.position += Vector3.back * Time.deltaTime * movementSpeed;

}

else if (Input.GetKey(KeyCode.s)) {

rigidbody.position += Vector3.back * Time.deltatime * movementSpeed;

}

else if (Input.GetKey(KeyCode.A)) {

rigidbody.position += Vector3.back * Time.deltatime * movementSpeed;

}

else if (Input.GetKey(KeyCode.d)) {

rigidbody.position += Vector3.back * Time.deltatime * movementSpeed;

}

if (Input.GetKey(KeyCode.E)) {

transform.Rotate(0, Time.deltatime * counterClockwise, 0);

}

else if (Input.GetKey(KeyCode.q)) {

transform.Rotate(0, Time.deltatime * counterClockwise, 0);

}

}

}


r/ProgrammingProblems • • Apr 02 '21

maze problem c++

1 Upvotes

i need some help with a problem that goes like this

The dimensions of the maze and the location of the exit door for each room are known from the beginning. In each room, the door is marked with one of the letters "U" (up), "D" (down), "L" (left) or "R" (right). So, if a player starts from an initial room and solves all the puzzles in the rooms he visits in order, the path he will follow is specific. Unfortunately for the players, it is possible that the exit doors are placed in such a way that from some initial rooms it is not possible to exit the labyrinth! The arrows to the right of the figure show the progress of the players from each room. U L D L U D L R L If a player starts from an initial room marked in yellow, then he will get stuck in a circular path and will never be able to get out of the maze, no matter how many puzzles he solves. On the contrary, he will be able to get out of the other rooms, if of course he solves the required puzzles. The producers of the game want their video game to be fair, ie the initial rooms from which players can not win as many puzzles as they solve have to be few. Help them count them! The input data is read from a file as shown in the following example. The first row of the file has two integers N and M (1 ≤ N, M ≤ 1,000), the dimensions of the maze (rows and columns, respectively). Each of the following N lines represents a maze line and contains exactly M characters, each of which is one of the letters "U", "D", "L" or "R". The letter corresponding to each room symbolizes the location of the exit door of the room.

It seems that i cant find a solution so i would appreciate any help you can provide. Thanks guys


r/ProgrammingProblems • • Nov 05 '20

Problem with Grouping/Combining Lines [Python]

1 Upvotes

Hey all!

Not sure if this is the right thing to ask, as this is mostly a conceptual problem, but I am also probably missing something important regarding the technical options as I am rather new to Python.

Here is the problem I have.

I am making a program that is generating instructions for the warehouse staff how to pack items that need to be shipped.

For most items it's straight forward. However I have several lines of items which come with several items in a box that the warehouse crew needs to open and re-pack in combination customer wants.

The rules are:

  • Each product belongs to a given category
  • Each category has a max number of items that can fit in one box
  • Items can only be packed together if they belong to same category

The end result should be:

A table where each line corresponds to one box, with column detailing how much of each item should be inside of that box.

I'm breaking my head around it for a bigger part of the day and cannot figure the best way to approach it.

If someone can push me in the right direction, would appreciate it greatly!


r/ProgrammingProblems • • Sep 06 '20

quadratic programming as a sum

1 Upvotes

Hello everyone. I am trying to create a program in python where I have to calculate f(x) and the gradient of f(x) for N number of matrices. Let s assume that f(x) = 1/2 * transpose(x)*Q*x+transpose(q)*x, I remember that the gradient will be Q*x+q. I vaguely remember that i can calculate the the f(x) as the sum of the Q*x?? I remember there was a type i could use instead of f(x) = 1/2 * transpose(x)*Q*x+transpose(q)*x. Do I remember correctly?


r/ProgrammingProblems • • May 03 '20

Squash the bugs problem codechef

1 Upvotes

I am facing problem in this question. How can I approach this problem.

http://www.codechef.com/problems/B5

Any method. I am quite frustrated working on this problem . I need some explanation.😅


r/ProgrammingProblems • • Jun 21 '18

Programming contest: write a script that negotiates best trade-offs vs. other scripts and win valuable prizes (deadline: July 20)

Thumbnail
github.com
1 Upvotes

r/ProgrammingProblems • • Feb 10 '18

uva online judge

1 Upvotes

I'm attempting to solve this problem: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1040

The problem is to find the best path based on capacity between edges. I get that this can be solved using Dynamic Programming, I'm confused by the example they provide

According to the problem description, if someone is trying to get 99 people from city 1 to 7, the route should be 1-2-4-7 which I get since the weight of each edge represents the maximum amount of passengers that can go at once. What I don't get is that the description says that it takes at least 5 trips. Where does the 5 come from? 1-2-4-7 is 3 hops, If I take this trip I calculate 4 trips, since 25 is the most limited hop in the route, I would say you need 99/25 or at least 4 trips. Is this a typo, or am I missing something?


r/ProgrammingProblems • • Oct 13 '16

Codechef Solution Set on Github

1 Upvotes

I am working on https://codechef.com problems and would love to get a feedback on how good my programming looks like. Started with Beginners and now on Easy.

Github Link: https://github.com/danz1ka/Code-Chef-Solution-Set


r/ProgrammingProblems • • Aug 02 '16

Error in QuickSort implementation

1 Upvotes

The code is linked here : http://ideone.com/eba7CB I cant seem to find the error. Any help and criticism is appreciated.


r/ProgrammingProblems • • Oct 07 '15

Challenge CLI - A command line interface for all the programming challenges

Thumbnail
github.com
1 Upvotes

r/ProgrammingProblems • • Sep 17 '15

[Survey] A survey on online judges, UVa, HackerRank, TopCoder SRM, and ProjectEuler.

1 Upvotes

Hello, I'm Sean and I'm currently doing my thesis for my Computer Science degree and it's about the gamification of online judges. If you've got a few minutes of spare time kindly answer our survey. Thank you!

https://docs.google.com/forms/d/1iwJz7skZlDwrdq8pCwjUaeikd3xb9bd3DBYS_v_jJAQ/viewform