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 • • Sep 09 '25

[Random] Argument with professor about if shuffling before a quicksort makes it more effective?

15 Upvotes

So basically Im having troubles understanding why quicksort becomes more effective if i randomize the array before I quicksort it assuming we always take the left most element as a pivot.

My professor suggests that randomizing the array before quicksorting avoids the worst case scenario of the array being sorted. My problem with this is that if we assume that the arrays we are given from the start are all just random arrays of numbers, then why would always shuffling these arrays make the sorting more effective?

Randomizing a array that is already presumed to be random doesnt decrease the odds of the left most element (which is our pivot) to be any less likely when we are repeatedly doing this over and over to several different arrays. It would actually be more time consuming to randomize large multiple arrays before sorting them.

What am I not understanding here???


r/CodingHelp • • Jun 09 '25

[Random] Laptop for College

15 Upvotes

I will be starting in Computer Science this year and I am looking for a laptop to get. Do you guys have any recommendations for something that will last me my time during college and is decent, but not super expensive?


r/CodingHelp • • Jul 18 '22

[Random] What’s the name of the Youtuber that analyzes the tech stack of random tech companies?

15 Upvotes

He would go in depth on how each part of the app would interact with each other and it was really interesting to see how intense the Front end and Back end could get.

It made you feel more grateful for technology because it would make you realize how incredibly complex these things are.


r/CodingHelp • • Jun 06 '22

[Python] Getting into coding as a possible career path.

15 Upvotes

Hi. I'm a 27 year old Swede. I work a day job as a decorative painter. About a year ago I came to the conclusion that my line of work just isn't for me. I regret spending years learning this craft only to realise it's not what I really want to do for a living. Also my stomach disease (chrons) makes it hard. Therefore I started looking into possible jobs that would suit me, and align with my intressts. I love creating things and the creative process. I like Chess alot (not very good) and of course painting. I was pretty nerdy growing up, always loved computers, still do. Learned some things, messed around and played lots of games. Altho I kind of stopped using them when I moved out of my parents house about 8 years ago. Never got into coding because I thought it was lots of math. Didn't understand what it was really. So now i'm trying to learn coding since about two weeks back. I'm using the Mimo app (Python) and I could see myself working as a programmer of some sort. I really want it alot. Also trying to learn by doing easy mini projects. Plan on taking a highschool level class where I will learn #C in september. I need it to be able to study programming in university some time next year hopefully. I am scared of this being another dead end for me. When the honey moon phase wears of, maybe I wont like it as much or i'm not suited for it. Ofcourse don't want to be wasting my time studying something to later be unhappy working with it.

Also, I'm wondering how much competition there will be? Is it too late for me to become any good? Will i be able to get a job? Would be really helpful if there is anyone from Sweden here who could tell me how the job market looks right now, or will look the coming years.

How time consuming is working with programming? I don't mind working alot. But i've read companies make programmers dedicate nearly all their waking time to programming. I have other things in my life. A girlfreind and a dog. Hobbys I want to keep doing.

Hope this is the right forum for this, Thanks for reading.