/r/CodingHelp

Photograph via //r/CodingHelp

Welcome! Feel free to ask any questions regarding coding you have!

Our Rules

1. FLAIR YOUR POSTS! Don't put tags in post titles!

2. Do not ask us to do all the coding for you unless you have money to spend. (If you have got money to spend, make that clear and the amount in question).

3. Do not post spam and/or misleading titles.

4. Do not be abusive to other coders.

5. Please format code properly, or use a site such as Gist or Pastebin. If possible please provide a live example of your issue.

6. Do not downvote people because you think they asked a dumb question. Just because you think that someone has a dumb question, doesn't mean that it is dumb to them.

7. Do not have a misleading user flair. Keep them sensible, describing your level of coding ability and/or languages you know and/or your profession.

8. Please do not ask unethical questions, such as asking for homework to be written by someone else, or asking someone to copy another project directly.

9. Make sure to follow the Reddit Rules.


How to start coding:

Check our website https://codinghelp.site we have all the information you need there!


Related subreddits:


Suggest a post flair

If you have any suggestions for flairs (programming languages or generic coding topics) that we should add, please use the button below to message the mods with your suggestion.

If approved as a sensible flair for the community to use, it will be added to our bot for automated suggestions and to the flair list for everyone to use!

Anyone who abuses this by spamming mods will be banned.


Current supported flairs

  • HTML
  • CSS
  • Javascript
  • PHP
  • SQL
  • Ruby
  • Java
  • Python
  • C++
  • C#
  • C (Not in Bot)
  • Open Source
  • Other Code
  • Random
  • Meta

Flair colors

  • Green

Web Related Languages (Eg HTML, CSS)

 

  • Blue

App Related Languages (Eg Python, C#)

 

  • Red

Generic Coding Topics (Eg Open Source)

 

  • Yellow

Other Flairs (Eg Random, Meta)


/r/CodingHelp

75,598 Subscribers

1

Logic to replace numbers not following ordinality in Excel

0 Comments
2024/06/23
07:59 UTC

1

Help with HTML: Filtering Multiple Isotope Options

Hi everyone!

I apologise if this is in the wrong subreddit, or formatted poorly. I posted in another sub, but got no replies. I'm very fresh to coding and struggle wrapping my head around it.

I'm trying to use isotope filtering for a page on my film blog. I had excellent help on here regarding :not before, so I thought I'd try again. When I click on one filter, it removes all items with that tag, but when I click another, the previous filter reappears. I'd like to make it so I can click two filters and it removes any items with these tags, regardless of whether it has both or not.

For example, a piece of my code is:

<div class="filter-wrap">

<ul class="filter option-set" data-filter-group="group3">

<li class="subtitle">Content:</li>

<li><a href="#" data-filter-value=""class="selected">None</a></li>

<li><a href="#" data-filter-value=":not(.alcohol)">Alcohol</a></li>

<li><a href="#" data-filter-value=":not(.child)">Children</a></li>

<li><a href="#" data-filter-value=":not(.death)">Death</a></li>

<li><a href="#" data-filter-value=":not(.drugs)">Drugs</a></li>

<li><a href="#" data-filter-value=":not(.flash)">Flashing Lights</a></li>

<li><a href="#" data-filter-value=":not(.gory)">Gore</a></li>

<li><a href="#" data-filter-value=":not(.jump)">Jumpscares</a></li>

<li><a href="#" data-filter-value=":not(.nude)">Nudity</a></li>

<li><a href="#" data-filter-value=":not(.prof)">Profanity</a></li>

<li><a href="#" data-filter-value=":not(.love)">Romance</a></li>

<li><a href="#" data-filter-value=":not(.sex)">Sex</a></li>

<li><a href="#" data-filter-value=":not(.shaky)">Shaky Camera</a></li>

<li><a href="#" data-filter-value=":not(.vio)">Violence</a></li>

</ul>

</div>

When I click Alcohol, it will remove all films with alcohol included. But when I click Alcohol AND Profanity, Alcohol-tagged items will reappear.

Is there a way I can fix this? I'd like to be able to click multiple options and hide films with these items from the list.

Thank you for your attention!

1 Comment
2024/06/23
07:37 UTC

0

Need Help in solving this problem statement !!! If possible provide code solution.

You are given an array of n integers with an initial value of (10^9)! You have to do exactly m operations. In each operation, pick any element and add 1 to it such that after performing all the operations:

Each number has to be updated at least once.

The absolute difference between any two adjacent elements should be at most 1.

GCD of the original and updated value of the kth element should be maximum. In other words, you have to maximize the value of gcd((10^9)! the value of kth element after performing all the operations).

Find the number of operations performed on the kth element. Here, 1-based indexing is used, and gcd(x,y) denotes the greatest common divisor of integers x and y.

Input

The only line contains three integers n, m, and k (1≤n≤m≤(10^9),1≤k≤n) — the size of the array, the number of operations you must perform, and the index of the element.

Output

Print single integer — the number of operations performed on the kth element.

Examples

Input

3 4 2

Output

2

Input

3 6 2

Output

2

Note

In the first example, 2 operations will be done on the middle element and 1-1 operations on the rest of the elements. Hence the answer is 2.

In the second example, 2 operations are done on each element to satisfy all the necessary conditions.

2 Comments
2024/06/23
05:53 UTC

1

Ccxt vs alpaca vs safe-cex

Am building a trading terminal, want to include mainly crypto exchanges for now, wondering what crypto API libraries to use, or should i just link it directly using each exchanges API ?

0 Comments
2024/06/22
19:36 UTC

1

Want to create a website where users can draw together

Hello I don’t have much experience in web development past a portfolio website and a to-do list site but I would like to create a website where you have a canvas and when you arrive to the website you join the server and see what people have drawn. How hard would this be to make? My goal is for this to be a learning experience so what would I have to learn in order to do this successfully without copy pasting too much code?

2 Comments
2024/06/22
18:57 UTC

1

QWERTY chorded keyboard?

Would anyone know how to do this, Make a QWERTY keyboard into a chorded keyboard

0 Comments
2024/06/22
17:13 UTC

1

I want to start learning rust but I only have an understanding of higher level concepts and want to learn some more core ideas related to comp-sci like memory, buffers, pointers, etc.

I was just wondering if anybody had some good resources for me to brush up on these concepts before i read the rust book, because as of right now even though i have a pretty good understanding of algorithms and abstraction all the other words i said above are just words to me and i know if i tried to read the rust book right now half of it would be like reading a foreign language.

So as I said if anyone has any good resources to brush up on some of these lower level concepts it would be greatly appreciated.

I hope this post is within the guidelines and doesnt get struck for violation of rule 9 as I'm not asking to learn how to code and where to start i just want some good short resources to become acquanited with the vocabulary and concepts I am going to encounter whilst reading through the rust book that are currently foreign to me.

2 Comments
2024/06/22
15:01 UTC

1

can anyone help with google apps script

this is my code which is working fine no problem

function onEditNote(e) {
  if(e.source.getActiveSheet().getName() == "Notes") notes(e)} //trigger fn for note sheet

function notes(e){
  let input = e.value
  let cell = e.range.getA1Notation()
  if(commList.includes(input)){
  let ind = commList.indexOf(input)
  let data = ss.getRange('source!A'+(2+ind)).offset(0,1).getValue().split(',')
  let info = ss.getRange('source!A'+(2+ind)).offset(0,2).getValue().split(',')
  let nextCol = String.fromCharCode(cell.charCodeAt(0)+1)
  data.map((v,i) => ss.getRange(cell[0]+(parseInt(cell[1])+1+i)).setValue(v))
  info.map((v,i) => ss.getRange(nextCol+(+cell[1]+1+i)).setValue(v))
  }
}

but when i make notes private like "notes_" and calling the same then this line "e.range.getA1Notation()" gives this error

TypeError: Cannot read properties of undefined (reading 'getA1Notation') at notes(notes:10:22) 
at onEditNote(notes:6:54)

I can't figure out why it is happening, just want to hide notes from being imported as macro

4 Comments
2024/06/22
13:42 UTC

0

Struggling with backend on simple tic tac toe website

Hey all so I created a simple tic tac toe website using vanilla js HTML/CSS. I want to be able to play it online (Let’s say my friend plays me on their device). I have been trying to figure out how to do that using node. But I am having the hardest time figuring it out. How should I got about learning this?

2 Comments
2024/06/22
12:17 UTC

1

Why does one work and not the other, or am I doing something else wrong?

Am I able to type it out the long way if I want to?

(short explanation:)

import argparse
parser = argparse.ArgumentParser()
arg = parser.parse_args()

When I type "arg.word", it works.
When I type "argparse.ArgumentParser().parse_args().word", it doesn't.

(long explanation:)

import argparse

def decode_Caesar_cipher(s, n):

alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',.?!"

s = s.strip()

text = ''

for c in s:

text += alpha[(alpha.index(c) + n) % len(alpha)]

print(text)

parser = argparse.ArgumentParser()

parser.add_argument("--word")

parser.add_argument("--offset")

arg = parser.parse_args()

this next part, I just wanted to see if I could type it the long way

if argparse.ArgumentParser().parse_args().word and arg.offset:

decode_Caesar_cipher(arg.word, -int(arg.offset))

I'm thinking that they should've taught me classes before they taught me argparse, but I digress :p

7 Comments
2024/06/22
11:32 UTC

0

WHAT IS THE BEST PLACE TO MASTER HTML AND TO CORRECTLY TAKE NOTES?

I (18M) started to learn how to code HTML with a youtuber named "bro code" and i don't really know if this is the right thing to do .

12 Comments
2024/06/22
10:56 UTC

1

Fixing a script

Can I have a script for showing the flipped-over cards in online card games ?

0 Comments
2024/06/22
09:41 UTC

2

Sys.argv

SOLVED, THANK YOU!!!*

For mnemonic purposes, what does argv stand for? Why do they call it argv?

2 Comments
2024/06/22
05:38 UTC

1

Fixing a script

So I found a script in a thread I needed for something that makes LMB into RMB when control is held (a mac feature I wanted), but it seems to bug when I hold shift alongside ctrl and left click. How would I fix this? I asked the originally commenter but there was no reply.

^LButton:: ; Ctrl + Left Click

Click right

return

2 Comments
2024/06/22
05:27 UTC

1

Why will this not compile

I'm learning the basics of coding can someone tell me why this will not compile?

https://imgur.com/a/7QpelOi

3 Comments
2024/06/21
21:44 UTC

1

I feel like a fraud using external help on coding homeworks

For context, I’m through a change of industry graduate degree for IST which needs no prior experience in CS. The course I’m taking now is about objects and data structures in Java, before this class I’ve coded for a couple weeks in Python using CS50p, where I also got completely destroyed by assignments and had to use a ton of guides on how to complete the assignments as I had no one to really ask or mentor me.

The Java class was a complete divergence from Python and even though we are halfway through the class in 5 weeks, I still find myself extremely confused by the most basic things such as methods, when to declare a parameter, and overall syntax for creating some functions. We are on generics, Big O, ArrayLists, and LinkedLists.

Is this normal? I feel like I can’t ever get ahead or if I take a break for a couple days to actually let the information simmer, I’m immediately learning something else. Not to mention, the class is asynchronous (ADHD brain sabotaged me a lot with these classes) and there is basically no classmate interaction.

9 Comments
2024/06/21
20:39 UTC

0

Software development

I need a solution to this code. Can anyone help

Problem B Bob Roberts is the self proclaimed “Car Vet” who owns several junk car lots where people can come and search for spare parts for their (ailing) cars. The cars in each lot are parked in a fenced-in  grid lot, where each car takes up two grid squares. Each lot also has zero or more grid locations devoted to piles of parts (fenders, -track tape players, wheel covers, fuzzy dice, etc.); these locations are effectively blocked. Business has been so good that each of Bob’s lots has only one empty grid space left.

From time to time, Bob or one of his lot attendants drops a part on the ground and it rolls underneath one of the cars. The only way to retrieve it is to move the car out of the way. Depending on the location of the empty grid space, it may be necessary to move several cars in order to achieve this. Cars can only move forward or backward, and car movement is also constrained by the fence, which prevents any car from moving off the lot, and by the blocked grid locations containing piles of parts.

Figure 1 shows an example. An ambihelical hexnut has rolled under car number  in row , column  of the grid (shaded dark gray). The space in row , column  is empty and the space in row , column  is blocked. The only way to retrieve the part is to move car , then car , then car . Note that if the locations of the empty grid cell and the blocked grid cell were reversed, it would not be possible to retrieve the part.

\includegraphics[width=.25\linewidth ]{sampleinput1.png} Figure 1: Sample lot. Cars , , and  must be moved, in that order, to uncover the grid location in row , column . This corresponds to Sample Input . The problem here should be obvious: For a given location Bob would like to know how to move cars around to uncover that location, or if it is even possible to uncover it.

Input Input starts with a line containing two positive integers      indicating number of rows and columns of the junk car lot. Following this are  lines each containing  integers; the  value on the  line indicates the contents of the grid square at row , column . All values  are in the range . Each non-negative value indicates that half of a junk car is in that location. Every non-negative value appears exactly twice and these two occurrences are horizontally or vertically adjacent to each other. A value of  indicates the empty grid location and a value of  indicates a blocked location. There is always exactly one empty location and at least one car, but there may be zero or more blocked locations. Following these  lines is a single line containing two integers      indicating the row and column number of the desired location to be uncovered. This will always correspond to the location of a junk car.

Output Display, on a single line separated by spaces, the numbers of the cars that must be moved to make the given location empty. They should appear in the order in which they must be moved. If there is more than one sequence of possible moves, display the sequence of shortest length. If there is still a tie, display the sequence that comes lexicographically first according to the car numbers in the sequence. If it is not possible to uncover the desired location, display impossible.

Sample Input 1      Sample Output 1 4 4 8 8 -1 9 4 10 10 9 4 3 3 -2 16 16 2 2 3 3 8 4 3 Sample Input 2      Sample Output 2 4 4 8 8 -2 9 4 10 10 9 4 3 3 -1 16 16 2 2 3 3 impossible

1 Comment
2024/06/21
19:16 UTC

8

How to actually learn to code

So I am 21m and I am in my final year of uni, I want to do a lot this summer as I didn’t get an internship but when i find myself wanting to start a project, but I realize that I can’t actually code anything of my own, I find my self either using ai to help me write code or the internet, YouTube , I feel so frustrated, I feel like I dont know anything. I need advice please, should I study more, try to do projects without copy and pasting code, learn the syntax better? Any advice is greatly appreciated

8 Comments
2024/06/21
17:57 UTC

1

C++ simple code not working

Hi! Currently learning C++ for a uni class. My professor gave me a simple exercise but I can't get it to work properly. The exercise is to write 2 functions, one multiplies 2 numbers and the other 3 numbers. The program asks the user how many numbers they want to multiply and then it choses between the two functions. (The code prints 0 as a result for any given number. I checked the solution for said exercises and my professor uses a do-while loop but I don't really understand its use in this specific siutation.) This is what I wrote:

Thanks to whoever will help me!

#include <iostream>
using namespace std;

int multiply (int a, int b){
    return a*b;
}

int multiply (int a, int b, int c){
    return a*b*c;
}

int main() {
    int n=0, a=0, b=0, c= 0;
    int prodotto2= multiply(a,b);
    int prodotto3= multiply(a,b,c);
    cout<<"How many numbers to multiply?\n";
    cin>>n;
    cout<<"Insert numbers\n";
    if(n==2){
        cin>>a>>b;
        cout<<"The result is"<<" "<<prodotto2<<endl;
    }else {
        cin>>a>>b>>c;
        cout<<"The result is"<<" "<<prodotto3<<endl;
    }

    return 0;
}
6 Comments
2024/06/21
16:53 UTC

1

Positioning Issues for a Popup Window

Hello,

I've got a section of python code that is driving me nuts trying to figure out. I have no other assistance with this and I cannot get a popup window to display dynamically between monitor resolutions over the task bar on a windows pc. I can send the section of code I'm working on if that helps, but I'm working in the PyQT5 library and I really would like to get this working as soon as possible. I feel like I'm beating my head into a brick wall.

1 Comment
2024/06/21
16:29 UTC

1

Chrome extension

Hi there Is there a chrome extention to show what happens if I clicked an item but without me clicking on it (just by pointing on it) Let me explain more It's like I'm playing a mind memory game and I wanna know what this card is but without clicking

2 Comments
2024/06/21
15:46 UTC

0

Chrome extension

Hi there Is there a chrome extention to show what happens if I clicked an item but without me clicking on it (just by pointing on it) Let me explain more It's like I'm playing a mind memory game and I wanna know what this card is but without clicking

0 Comments
2024/06/21
15:37 UTC

2

What Skills Should I go for

I'm entering my sophomore year next month. Currently I know python well and I've good with C++ and MySql too. I've started doing dsa but I see people around me doing Javascript, Node.js, React, MERN Stack and some are even showing off their internships in these fields . So I wanted to know which place should I go, like apart from dsa where should I go coz there's so much to choose from and I've been curious about so many skills like Js, Django, AI, MERN Stack, AWS, Flutter and so on but it makes me overwhelmed and confused.

2 Comments
2024/06/21
15:19 UTC

0

Coder Professional

Do you want to code anything in any programming language? You can do it with this gpt: https://chatgpt.com/g/g-wEfUEX5ME-coder-professional-html-python-abap-more

0 Comments
2024/06/21
10:02 UTC

2

Please help me!!

I am going trying to learn python and C++ and now i am wondering how to properly take notes while learning them.

Also any tips on how to remeber each code without messing them up?

5 Comments
2024/06/21
06:48 UTC

1

C++ question

Help how can i avoid using ascii codes in c++ when i work with char😭😭😭 it's very hard to keep tgese codes of characters in mind

4 Comments
2024/06/21
03:34 UTC

1

Imac feature needed on windows

there is a feature on iMac where when control is held, LMB registers as RMB and RMB does the same. How would I go about recreating this feature on windows as someone who doesnt know how to code? Ive tried using my mouse software/keyboard software and google but it hasnt helped.

2 Comments
2024/06/21
00:57 UTC

2

zPos from sin(zRot) is rarely accurate (Tom's Peripherals)

0 Comments
2024/06/21
00:01 UTC

1

Odradek college project

Hi all, apologies for the not great format, first time putting up a post(: So for a college comp sci project I'm looking at creating a "functioning" odradek from death stranding, I'd just like it would activate and unfold when it gets an audio cue of people talking. I'd also like to implement facial tracking if I can, so once it unfolds the camera sees a person and follows them around till a certain distance away. I've got the 3d modeling chops to make the design and everything, it's the coding and hardware aspect I'm a little shaky on. I've got basic experience but not super advanced. I know some python and c++ and a little Java. I was also looking at using an esp-eye I've got for the tracking too and then I'd 3d print the parts. If anyone has any advice I'd love to hear them(this could definitely be a long term 2-3 year project) Thanks in advance for any advice😁

1 Comment
2024/06/20
21:05 UTC

1

Please guide me !

I have no background into coding and want to start by learning python. Tutorials are just so confusing and I can’t build a roadmap and at all , it just gets so confusing . Are there any free courses that could guide me as a complete beginner.

5 Comments
2024/06/20
20:58 UTC

Back To Top