r/CodingHelp • • Nov 09 '20

[Java] I have no idea how to do this question my teacher gave me. Help

16 Upvotes

Write a program with a loop that lets the user enter a series of integers. The user should enter -99 to signal the end of the series. After all the numbers have been entered, the program should display the largest and smallest numbers entered


r/CodingHelp • • Nov 06 '20

[Other Code] Help with Acellus Coding

16 Upvotes

Not sure where else to put this, as the Acellus subreddit seems dead. Trying to help niece with her coding but afraid I'm not much help with it, can somebody help "fix" this code and maybe give a brief explanation of why so I can assist her? Thanks so much. You have 14 total blocks you can use, must use the if statement/conditional.

Acellus "code": https://i.imgur.com/Q5AnFrk.jpg


r/CodingHelp • • Oct 19 '20

[Python] Computer Science Classes in High School or Online Courses?

16 Upvotes

In this video I shared my thoughts on whether people should take CS classes in high school or online classes on there own time and schedule. Make sure to let me know what you thought dow below.

Video: https://youtu.be/CKsvK7R8gWo


r/CodingHelp • • Oct 07 '20

[C++] C++ code not showing the results after input

16 Upvotes

I am trying to create a program using functions that shows the highest and lowest numbers in a set of 4 integers. I can input the numbers but then the program ends (not sure if its from void). I'm sorry for any mistakes, I'm still a newbie. Thanks for your help!

#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <string>
#include <cmath>

using namespace std;

void findLargest(int, int, int, int);
void findLowest (int, int, int, int);

int main()
{
    int x, y, z, a;
    
    cout << "To find the highest and lowest numbers, enter 4 integers:" << endl;
    cout << endl;
    cout << endl;
    
    cout << "Enter 1st number: ";
    cin >> x;
    cout << "Enter 2nd number: ";
    cin >> y;
    cout << "Enter 3rd number: ";
    cin >> z;
    cout << "Enter 4th number: ";
    cin >> a;
    return 0;

}


void findLargest(int x, int y, int z, int a)
{
    
    int Largest;
    
    cout << "The largest number is " << Largest;
    
    if (x > y && x > z && x > a)
    {
        Largest = x;
        cout << x << endl;
    }
    else if (y > x && y > z && y > a)
    {
        Largest = y;
        cout << y << endl;
    }
    else if (z > x && z > y && z > a)
    {
        Largest = z;
        cout << z << endl;
    }
    else
    {
        Largest = a;
        cout << a << endl;
    }

}

void findLowest(int x, int y, int z, int a)
{
    int Lowest;
    
    cout << "The lowest number is " << Lowest;
    
    if (x < y && x < z && x < a)
    {
        Lowest = x;
        cout << x << endl;
    }
    else if (y < x && y < z && y < a)
    {
        Lowest = y;
        cout << y << endl;
    }
    else if (z < x && z < y && z < a)
    {
        Lowest = z;
        cout << z << endl;
    }
    else
    {
        Lowest = a;
        cout << a << endl;
    }

}

r/CodingHelp • • Oct 03 '20

[Python] Why does my recursion sequence code keep failing?

16 Upvotes

o I wrote blocks of code for these tasks 1. Is to search through the list as well as sublists inside it and return True if any of the elements match the certain parameter 2. Is to remove all the elements in the list that are the same as the parameter. Here is the link: https://repl.it/repls/AllHandyDisk#main.py

I have been going through the blocks of code for as long as I can imagine but I am not able to find a single error. Could you please take a look at it.


r/CodingHelp • • Oct 02 '20

[Javascript] Get Current Exchange Rate Javascript

16 Upvotes

Im trying to get the current exchange rates in javascript. How would I do this? I have searched but cant find anything currently. I will be always exchanging from USD to another currency


r/CodingHelp • • Sep 22 '20

[Other Code] How can I write a Shell Script that will perform an action based off of the first line in a text file?

16 Upvotes

I am very new to scripting anything, but basic shell scripts is what I have the most experience with so it’s what I’m trying to use here.

I’m trying to make a script I can run on macOS.

Basically I currently have a command that gets the SSID of the current WiFi network I’m connected to and writes it to a file “~/Script/currentssid”

So I made it that far, but below I’m no longer sure what to do.

Next I want to create a second file where I can manually list SSID’s.

When I run the script I want it to get the current SSID print it to a file, then check that file and see if that SSID exists in the manually crated list.

If it does exist then do action 1

If it does not exist then do action 2

If the file is blank then do action 2


r/CodingHelp • • Sep 02 '20

[C#] Having trouble understanding the big picture.

16 Upvotes

I've been trying to learn to code in C# on and off for a few years through SoloLearn, Skillshare and Udemy. I understand the bare basics, but I always have trouble understanding how it all comes together.

I would equate it to looking at a pile of Legos, and then looking at a castle made out of Legos and not getting how it all comes together. Is there a targeted course or tutorial for this type of issue anyone would suggest? Or is coding just not for me.


r/CodingHelp • • Aug 25 '20

[Javascript] Could use some help with summing specific values in arrays - [x-post from /r/LearnJavaScript]

16 Upvotes

For fun I started working on a haiku twitter bot, using NodeJS and the Twit package. It's all working well, but I'm struggling with making it a bit more robust. General workflow below:

  1. Get tweet

  2. Split tweet words into wordArray

  3. Split wordArray into countedArray containing the syllable count for all words in wordArray

  4. Return indices from countedArray whose sums equal 5, then 7, then 5

  5. Match indices with values from wordArray and join all three lines to make full haiku

  6. Tweet.

The above works really well. However, it ONLY returns two indices from countedArray. Therefore, each line of the haiku only contains two words. I'd like to make it a bit more interesting by returning all possible sums from the countedArray whose values equal 5, 7 or 5. From my reading I understand that this is called a two sum or three sum scenario, and I'm having trouble applying those techniques to this application. Has anyone done similar or have any thoughts? Some code samples below:

//Get the tweet from the twit call
var responseText = data[0].retweeted_status.full_text

//Split words into wordArray
var wordArray = responseText.split(/[\n\r\s\@]+/)

//Count syllables, relies on syllable package
var countedArray = []
 for (i = 0; i < wordArray.length; i++) {
    var countedValue = syllable(wordArray[i])
    countedArray.push(countedValue)
 }

//Find values in array whose syllables sum 5, 7, 5
var line1Array = twoSum(countedArray, 5)
    var line1FullArray = makeHaiku(line1Array, wordArray, countedArray)

    if (line1FullArray != null) {
        var line2Array = twoSum(countedArray, 7)
        var line2FullArray = makeHaiku(line2Array, wordArray, countedArray)

        if (line2FullArray != null) {
            var line3Array = twoSum(countedArray, 5)
            var line3FullArray = makeHaiku(line3Array, wordArray, countedArray)
        }

    }

//Put it all together for tweet
var tweetThis = line1FullArray.join(' ') + '\n' + line2FullArray.join(' ') + '\n' + line3FullArray.join(' ')


//Here is the twoSum() function referenced above, this is where the sums are calculated
function twoSum(nums, target_num) {
var map = [];
var indexnum = [];

for (var x = 0; x < nums.length; x++) {
    if (map[nums[x]] != null)
    {
        index = map[nums[x]];
        indexnum[0] = index + 1;
        indexnum[1] = x + 1;
        break;
    } else {
        map[target_num - nums[x]] = x;
    }
}
return indexnum;
}

//The makeHaiku() function, take input arrays and return the words that match the index values of twoSum
var makeHaiku = function(linexArray, wordArray, countedArray) {
linexFullArray = []
for (j = 0; j < linexArray.length; j++) {
    linexFullArray.push(wordArray[linexArray[j] - 1])
    delete wordArray[linexArray[j] - 1]
    delete countedArray[linexArray[j] - 1]
}
return linexFullArray
}

r/CodingHelp • • Aug 23 '20

[Javascript] Can scripts be bound to shortcut keys?

16 Upvotes

Hey all, I dabble in HTML, CSS and JS for work but am by no means a 'developer'.

What I wanted to ask was as I run the same scripts/write the same functions repeatedly for testing/mock ups, if it's possible to create a macro function that will be bound to a shortcut key so I can literally just hit the key and it writes the script automatically?

I have a decent keyboard with switches/macro keys so could bind a lot of these to expedite time.

I know Google dev tools allows you to press the down key to reuse the last script used but I'd like it to also work in a text editor (I use Atom generally).

Is this an efficient use of time or is there a better way? Curious to know, thanks!


r/CodingHelp • • Aug 16 '20

[C++] Help with a few thing in C++

16 Upvotes

So I recently started learning c++ and it has been fine. But there are a few thing i dont get. Note im a noob sorry if i am just being dumb. So how does void work. I know it doesnt return a value but what does that mean. It doesnt make much sense to me. Cant find a good explanation. Whats the difference between x++ and ++x? How do I use parameters Finally pointers just confuse the hell out of me.

Again sorry if im being dumb. I am just a noobie to coding who needs help.


r/CodingHelp • • Aug 14 '20

[C++] Array Explanation

16 Upvotes

Hi, I am working on a MQL5 code (based on C++) and am trying to understand the math behind it. I am a coding novice so it is quite difficult for me. Could someone explain in simple terms what is being done here? My biggest issue is just with simple referencing & syntax. I included some specific questions next to the lines after // Thanks for your help!


    input int                inpNmsPeriod  = 40;          // Natural market slope 
    period
    input ENUM_APPLIED_PRICE inpNmsPrice   = PRICE_CLOSE; // Price
    input int                inpTemaPeriod = 10;          // Triple EMA pre-smoothing period
    
    //
    //
    //
    
    double val[],valc[]; double alpha;
    int    iNmsPeriod;
    struct sCoeffStruct     //how and why is this "struct" used?
    {
    double sumx;
    double sumx2;
    double bot;
    double root;
    };
    sCoeffStruct coeff[];
    
    ==================
    int OnInit()
    {
    SetIndexBuffer(0,val ,INDICATOR_DATA);
    SetIndexBuffer(1,valc,INDICATOR_COLOR_INDEX);
    //
    //
    //
    
    iNmsPeriod  = (inpNmsPeriod>1)  ? inpNmsPeriod : 1;
    alpha = 2.0 /(1.0 + MathMax(inpTemaPeriod,1));
    ArrayResize(coeff,iNmsPeriod+1);           //what does this mean, in simple language?
    for (int period=1; period<=iNmsPeriod ; period++)    //what does this mean, in simple language?
    {
    coeff[period].sumx  = period*(period+1.0)/2.0;    // why is [period] in brackets?
    coeff[period].sumx2 = period*(period+1.0)*(2*period+1.0)/6.0;
    coeff[period].bot   = period*coeff[period].sumx2 - coeff[period].sumx*coeff[period].sumx;
    if (coeff[period].bot==0) coeff[period].bot=1;
    coeff[period].root  = MathSqrt(period);
    

r/CodingHelp • • Jul 02 '20

[Javascript] Designing a portfolio website. I am new to backend development. What should I know and any useful tips?

16 Upvotes

I want to use golang as a backend language. How can i improve my knowledge on the backend development?


r/CodingHelp • • Jun 21 '20

[Javascript] I need help with a POST request

16 Upvotes

I'm trying to send a POST request to an API. I eventually need to be able to do it with PHP, but JavaScript (jQuery) is fine for now. The error that I'm getting is:

"Values in teamIds (1404) must be a Number type"

Here's my code:

var postData = {
    "method": "games.search",
    "params": {
        "offset": 0,
        "count": 10,
        "afterDateTime": "2010-06-21 21:49:27",
        "beforeDateTime": "2020-06-21 21:49:27",
        "teamIds": [
            1404
        ],
        "orderBy": "DESC"
    }
}

$(document).ready(function(){
    $('#button').click(function(){
        $.ajax({
            url: 'https://scorestream.com/api',
            type: 'POST',
            data: postData,
            success: function(data){
                console.log(data);
            }
        })
    })
})

Basically, when an element with the ID button is pressed, it will log the response. I used ReqBin to send some test requests, and they work: https://reqbin.com/bspb9gs6.

I get the same error with my PHP code:

<?php

function httpPost($url, $data) {
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($curl);
    curl_close($curl);
    return $response;
}

$url = 'https://scorestream.com/api';

$request = [
    'method' => 'games.search',
    'params' => [
        'offset' => 0,
        'count' => 10,
        'afterDateTime' => '2010-06-21 21:49:27',
        'beforeDateTime' => '2020-06-21 21:49:27',
        'teamIds' => [
            1404
        ]
    ],
    'orderBy' => 'DESC'
];

$response = httpPost($url, $request);

header('Content-Type: text/json');
print_r($response);

r/CodingHelp • • Jun 04 '20

[C] How would i swap "for loop" with a "while loop"?

16 Upvotes

I wrote this program and I am being told to replace the "for loops" with either "while loops" or "switch statements", how would i would i do that?

#include <stdio.h>

int main(void)
{
  int i, j;
  int num;

  //6 odd calculations
  for(i = 1;i <= 12;i+=2)
  {
    // Initialize num to 1 every time to get proper factorial
    num = 1;

    //factorial calculation
    for(j = 1;j <= i;++j)
      num *= j;

        if(i%2 != 0)
        {
         // Print the odd result
            printf("Odd:%d\tOddFactorial:%d\n", i, num);
        }
  }
  printf("================================\n");
  //6 even calculations
  for(i = 2;i <= 12;i+=2)
  {
    // Initialize num to 1 every time to get proper factorial
    num = 1;

    //factorial calculation
    for(j = 1;j <= i;++j)
      num *= j;

        if(i%2 == 0)
        {
         // Print the even result
            printf("Even:%d\tEvenFactorial:%d\n", i, num);
        }
  }
  return 0;
}

r/CodingHelp • • May 27 '20

[HTML] Taking my first Frontend Web Development class, please check out my pile of garbage and tell me if I can fix anything

16 Upvotes

This is my final project!
https://www.dogyearsinhumanyears.com/


r/CodingHelp • • Feb 25 '20

[Python] [beginner] how do I get Python to display this? I can get the 5 fives, 4 fours, etc, but idk how to display them on the same line like that with nested loop structures.

Post image
16 Upvotes

r/CodingHelp • • Dec 04 '19

Is There anybody with all the answers for Cmu CS Academy Python coding?

16 Upvotes

Hey, I'm falling a bit behind in my computer science class and I need some answers to some of the work. Anything would help. Thank you!
Link to the Website: https://academy.cs.cmu.edu/


r/CodingHelp • • Oct 19 '19

[Python] I'm on a mission to simplify the most popular coding interview questions asked by top tech companies - would love your feedback on my latest upload.

Thumbnail
youtube.com
16 Upvotes

r/CodingHelp • • Sep 28 '19

Friend had a psychotic break

Post image
16 Upvotes

r/CodingHelp • • Sep 25 '19

[Python] Started a YouTube series going over popular coding questions in Python. What do ya'll think of this one?

Thumbnail
youtube.com
16 Upvotes

r/CodingHelp • • Aug 13 '26

[C#] How did or where you learn to develop apps/games

15 Upvotes

I am wondering as i want to make my own game but i dont know where to go as every tutorial i watch just confuses me even more and alot of the tutorials only explain lets say what a variable is and not actual code.


r/CodingHelp • • Oct 21 '25

[HTML] Is FreeCodeCamp and Fullstack developing worth learning?

15 Upvotes

I’m really new to coding in general and my knowledge is super limited, but I really want to get into game dev. I just want to know if I’m wasting my time by starting with HTML and working my way up, or if I should just jump straight to learning C# for Unity.


r/CodingHelp • • Jun 12 '23

[Mod Post] /r/CodingHelp will go offline on June 12th to protest.

15 Upvotes

JOIN OUR DISCORD SERVER: https://discord.gg/r-codinghelp-359760149683896320

As the moderation team of /r/CodingHelp, we have concerns about recent changes to Reddit. A recent Reddit policy change threatens to kill many beloved third-party mobile apps, making a great many quality-of-life features not seen in the official mobile app permanently inaccessible to users.

On May 31, 2023, Reddit announced they were raising the price to make calls to their API from being free to a level that will kill every third party app on Reddit, such as Apollo, Slide or RIF. Basically any reddit app that is not the official app is dead

Even if you're not a mobile user and don't use any of those apps, this is a step toward killing other ways of customizing Reddit, such as Reddit Enhancement Suite or the use of the old.reddit.com desktop interface. This isn't only a problem for users: many subreddit moderators depend on tools only available outside the official app to keep their communities on-topic and spam-free.

Accordingly, the moderation team of /r/CodingHelp will be shutting down on June 12th.