r/programminghelp • • May 13 '26

Other Looking for a lightweight CLI template program to prevent leaking secrets in config files

3 Upvotes

Let's say I've got a file, config.ini, that looks like this

[foo]
BAR = public_value
BAZ = super_secret_value
QUX = another_public_value

At some point I might want to edit it, and I also might want to check it into a git repo. Having Super_Secret_Value in my repo could cost me $148M, so I don't want to do that.

Instead, what I would like to do is create two files, config.secrets, which does [not]{.underline} get checked into git, and config_template.ini, which does.

Ideally, config.secrets would look something like

BAZ_SECRET_VALUE = super_secret_value

and config_template.ini would look like

[foo]
BAR = public_value
BAZ = {% BAZ_SECRET_VALUE %}
QUX = another_public_value

Perhaps this is even the case for numerous 「name_i」_template.「ext」 and 「name_i」.secrets files, in which case I could have a simple shell script like this:

#! /usr/bin/env bash

# process_secrets.sh

for template in *_template.*
do
  base="${template/_template*/}"
  ext="${template/*_template./}"
  secrets="$base.secrets"
  「template_processor」 "$template" "$secrets" --delimiters="{% %}" \
                         > "$base.$ext"
done

where I could then copy process_secrets.sh to 「repo」/.git/hooks/post-commit, post-checkout, and post-merge (at least that's what it seems like I should do based on the gitinfo2 package for LaTeX). (Note: I know I'd have to include config.ini and the 「name_i」.「ext」 in .gitignore.)

My question boils down to this: what's the standard solution for this 「template_processor」 that I assume must exist? Ideally it would be something written in bash, or there's some C or Rust binary for *nix I can get on Homebrew, apt, pacman, etc. I'm trying to not reinvent the wheel here, but if there isn't a "standard" solution, I suppose I can try to roll my own.


r/programminghelp • • Apr 18 '26

Answered Python 'list index out of range' error still persists after lots of debugging - any help appreciated

3 Upvotes

I have tried debugging it a lot - this is even a simplified version of the actual block of code within a larger project that I made so I'd hopefully be able to solve it easier.

This is what manages to get printed before the error (this is correct so far):

0 a ; 2 b
1 a ; 1 b

The error is in line 11 and as the title says it's that the list index is out of range.

I'm just really not sure why because in the while loop I thought I made sure that the index was in range. I also tried substituting line 8 (within index initialisation) with:

WithinIndex = LineNum + FutureCount < len(LinesIn) - 1

Which would eliminate any issues with adding to Future count within the while loop, but that shouldn't be needed anyways, right? I'm really not sure where I've gone wrong with my logic so any help would be appreciated, thanks.

This is the full program:

import sys

LinesIn = ['a', 'a', 'b', 'c', 'c', 'a', 'c', 'a', 'c']

# trying to identify a, then identify how close the next b is for each a there is

for LineNum in range(len(LinesIn)):

if 'a' in LinesIn[LineNum]:

FutureCount = 0

FutureLine = LinesIn[LineNum + FutureCount]

WithinIndex = LineNum + FutureCount < len(LinesIn)

while 'b' not in FutureLine and WithinIndex:

FutureCount += 1

FutureLine = LinesIn[LineNum + FutureCount]

if LineNum + FutureCount == len(LinesIn) and 'b' not in FutureLine:

FutureCount = 0

print(LineNum, LinesIn[LineNum], ';', FutureCount, FutureLine, file = sys.stderr)


r/programminghelp • • Jan 31 '26

Python What is the best library for creating interfaces in Python?

3 Upvotes

I started studying programming recently, I only had a basic understanding of front-end, but now I'm focusing more on back-end development. Currently, I'm studying Python. I'm working on a small project just for study purposes; it's an interface to help people who are starting out or who don't have a regular study routine for musical instruments. I started the project using only the terminal, but I'd like to integrate an interface into it. However, I'm very unsure which library to use. I tried using tkinter and PyQt6. Could someone help me with this? If anyone wants to analyze the code I've written so far, I'll leave the repository link: https://github.com/AntonioH-B/guitar-training-interface


r/programminghelp • • Jun 05 '25

Answered Need help with a java code

3 Upvotes

Hello I'm a beginner in java just started learning a few days ago. I've made a text based rpg where you follow a path and there are certain items or monsters and when you reach the end you clear it. Just a normal first project. Now I'm trying to add new stuff like attacking a monster you encounter.. Now I've set
int PlayerHP = 10;
int SwordDmg = 5;
int Slime1HP = 10;
int Slime1Dmg = 2;
Now basically when you encounter a slime I know that I need a for loop for you to keep printing
"You dealt" + SwordDmg + "damage to the Slime. It has " + Slime1HP-SwordDmg + "hp left. The slime dealt " + SlimeDmg + "damage to you. You have " + PlayerHP-Slime1Dmg + "HP left."
until Slime1HP = 0 but I don't know how to frame it and I've been trying multiple ways but I'm stuck there.. Really need some help..


r/programminghelp • • Jan 24 '25

Java I keep getting java.lang.NullPointerException on new projects, how do I fix this?

3 Upvotes

Hello I am using android studio (dolphin Sept 2022) and I keep getting this error on my new projects. My first project runs fine but whenever I make a new one I get this error. I've already tried deleting the Gradle file but I keep getting the same issue. If anyone has any answers I would appreciate it a lot.


r/programminghelp • • Jun 09 '23

React ELI5: In React/JavaScript, what are bundles (created after modifying the .js files by a bat)?

3 Upvotes

Hello!

There's this open source video game I contribute to, Space Station 13 (not specifying which codebase).

There, we use TGUI as our GUI which uses React (Node and yarn) as a framework.

Workflow is that we modify the .js files and then run a bat file that does linting and unit tests (this I understand). However, then it also produces a tgui.bundle.js (and sometimes tgui.bundle.css).

This... tgui.bundle.js scares me. It's like a million characters on a single line and it causes merge conflicts all the damn time.

What exactly is that accursed file? Why can't we just directly use the .js files live?

My background if it helps explaining: Amateur coder, fairly familiar with "Dreammaker" (Object oriented, kinda python+java had a ugly child-like syntax compiled language; also with python. I've been messing around with JS/TSX since a few weeks to finally add GUIs to stuff I'm making.

The .bat file calls a .ps1 file, which has

if ($Args[0] -eq "--pretty") {
    $Rest = $Args | Select-Object -Skip 1
    task-install
    task-prettify
    task-prettier
    task-lint
    task-webpack --mode=production
    exit 0
  }

r/programminghelp • • Mar 10 '23

Python Been learning python for a few weeks, this tictactoe is the most complex thing i've done and i would love if someone who knows what they're doing could critique it and tell me what they would do differently

3 Upvotes

https://gist.github.com/misterpen/2a63f20036405fb068321337b4bfea7b

i noticed i spelled column wrong the whole time


r/programminghelp • • Feb 06 '23

Python is there any better way?

3 Upvotes

The functions just checks if the two given directions are opposites. It works like this but it is not the most beautiful code...

def check_direction(directions: tuple) -> bool:
    if directions[0] == 'north' and directions[1] == 'south':
        return True
    if directions[0] == 'south' and directions[1] == 'north':
        return True
    
    if directions[0] == 'east' and directions[1] == 'west':
        return True
    if directions[0] == 'west' and directions[1] == 'east':
        return True
    
    return False

r/programminghelp • • Jan 29 '23

Other I need some COBOL help

3 Upvotes

Right so I'm trying to generate a random number between 1 and 10 using the following code:

COMPUTE RANDOM-NUM = (FUNCTION RANDOM (1) * 10) + 1

Which should work as per tutorials but no matter what happens I always get the number 09 and I have zero clue why. Is there any way to fix this? Is it just a simple mistake that I'm missing?


r/programminghelp • • Oct 24 '22

C++ New to Binary Trees

3 Upvotes
Ok so i just started learning Binary trees. The problem im having is my print function wont give me the output of the values in the left side of the binary tree. Can someone tell me how I can get the ouput i want?


#include <cstdlib>
#include <iostream>
#include <string>
#include <ctime>


using namespace std;


struct Node{     // That Binary Tree

    int data;

    Node* right;
    Node* left;





};

Node* createNode(int data){

    Node* newNode = new Node();
    newNode->data = data;
    newNode->left = newNode-> right  = nullptr;
    return newNode;





}


void PrintNumbers(Node* root){

    if(root = nullptr) return;
    
    cout<<root->data <<endl;
    PrintNumbers(root->left);
    PrintNumbers(root->right);



}

int main(){

        srand(time(0));


    // Random list of numbers


Node*  root=NULL;

int Small0 = 1 + rand() % 3;
int Small1 = 1 + rand() % 3;
int small2 = 1 + rand() % 3;
int small3 = 1 + rand() % 3;
int small4 = 1 + rand() % 3;
int small5 = 1 + rand() % 3;

root->left = createNode(Small0);
root->left = createNode(Small1);
root->left = createNode(small2);
root->left = createNode(small3);
root->left = createNode(small4);
root->left = createNode(small5);


PrintNumbers(root);






}

Output i get

zsh: segmentation fault

r/programminghelp • • Oct 23 '22

JavaScript Simple Discord Bot

3 Upvotes

I'm trying to make a simple discord bot to add to one of my friend's servers, but I haven't coded anything in over two years. All I need it to do is to react to any message in the server that contains a particular word. For example, if someone sends a message containing the word "apple", the bot will add an apple emoji to a message. Does anyone know where I can just copy & paste some generic code that does this? I haven't had any luck so far. 


r/programminghelp • • Oct 18 '22

Other From a Sr. Dev to new devs

3 Upvotes

To the new developers employed or not I see a lot of the same questions and I’m going to do my best to answer some of the common questions and give some general advice on how to really set yourself apart.

Questions:

Q. How do I become a better developer?

A. Practice. Treat software like a sport spend some time every day working out a problem even if it’s something from leetcode or hacker rank IMO spend an hour on this daily, spend another hour on projects and another on learning when your employed the second two are easy when your still working on finding that first job you have to set this time aside and just never stop doing this.

Q. What are the things an employer looks for?

A. Soft skills passing a coding exam is easy if you have practiced your craft this doesn’t mean you’ll pass them all as some are intentionally designed for you to fail to see how you handle it and how you go about solving challenging problems. A really good soft skill is having the right mindset having the mindset that your trying to help them (peer, client, employer etc) succeed rather than trying to get the job, gig, client etc really does wonders

Q. How do I overcome imposter syndrome?

A. Overcoming this is difficult and there’s no one size fits all because imposter syndrome is for different reasons but the best thing to do is be comfortable knowing you don’t know and be comfortable on the journey of seeking knowledge.

Now for some advice. I’ll start with the beginnings of learning to program.

  1. anyone can learn to program but not everyone should learn to program the biggest advice I have here is to really ask yourself if you love it or not. I don’t mean every moment do you love it. I mean do you love it such that when it’s hard and frustrating do you want to keep trying even if you end up trying again tomorrow. If not honestly ask yourself what does. This doesn’t mean you shouldn’t be a dev but great devs love the craft.

  2. Now to job searching and interviewing your just as much in control as the interviewer. In fact you might as well be an interviewer your just interviewing them on why you should work there examples being do you think you’ll get along with your peers, will you enjoy the culture and can this job satisfy your goals for growth and the questions you ask your interviewer should be aimed at getting this information.

  3. lastly is to seek out information and people. Don’t expect them to come to you if you want to learn about a different part of the company ask to have lunch with that person and pick their brain about what it is they do, the pain points they have and brainstorm possible solutions to their problems.

That’s some of the best of what I got feel free to message me but preferably ask questions in the comments as someone else might have the same questions and it will bring them value to have the same answer.


r/programminghelp • • Sep 26 '22

C++ Help with c++ homework

3 Upvotes

I am trying to complete an assignment for my c++ programming class but the autograder keeps giving me the error message " Test Timed Out, Potential Infinite Loop ".

The assignment is to: Create a program that displays the ending balance in a savings account, given the beginning balance, the deposit amounts, and the withdrawal amounts. Use two loops in the program: one to get the deposit amounts, and the other to get the withdrawal amounts.

The code I have written is :

"#include<iostream>

#include<iomanip>

using namespace std;

int main(){

double beginningBalance;

cout<<"Enter the beginning balance:";

cin>>beginningBalance;

cout<<"Enter the deposit amounts";

double deposit = 0.0;

double endingBalance = beginningBalance;

while(deposit !=1)

 {

 	cin>>deposit;

 	if(deposit==1)

 	break;

 	endingBalance +=deposit;

 }

 cout<<"Enter withdrawal amounts";

 double withdrawal = 0.0;

 while(withdrawal != -1)

 {

 	cin>>withdrawal;

 	if(withdrawal==-1)

break;

 	endingBalance-=withdrawal;

 }

cout<<"Ending balance in the account is:"<<fixed<<setprecision(2)<<endingBalance<<endl;

}"

Does anyone know where I went wrong? And if you could reply with the corrected code it would help tremendously. I am very, very green and new to programming in general so I wouldn't be surprised if its riddled with errors.

Any criticism (constructive) is appreciated!


r/programminghelp • • Aug 04 '22

React Navigate after Authenticated react-router v6

Thumbnail
self.react
3 Upvotes

r/programminghelp • • Jul 25 '22

Java Storing objects in a LinkedList

3 Upvotes

Hi all, just wondering if someone could help me with understanding linked lists in JAVA a little better.

I have a programme with 4 separate classes: Node LinkedList Runner(app) Student

I am making a programme which stores objects, of a class called ‘Student’, am I storing those objects in my node class or linked list class?

I have no issues with just having 3 classes(node, linkedlist and runner), but when I add in the Student class I’m getting confused on the approach I should be using to store the object in the linkedlist.

Any advice would be hugely appreciate!


r/programminghelp • • Jun 11 '22

C# How do you load multiple data types into one variable in C#?

3 Upvotes

Like if you want console.writeline() Multiple times into one variable


r/programminghelp • • Apr 23 '22

Career Related Keep Switching Programming Languages

3 Upvotes

I have a sort of problem when it comes with learning program languages. Whenever I try a language, I either get frustrated or bored, and switch to a completely different language. When I first start programming, I did HTML and CSS, found myself frustrated with CSS so I switch to learn Kotlin. Everything was going well until I had to use Android Studio, I got frustrated, so I switch to React.js. After doing my first hello world realize this was no better, and now is on Ruby. I like Ruby the programming languages, but now founding myself overwhelm with Rails (setting things up) and decide to just go back to HTML and CSS.

My question to everyone is what's the best way to stick with one language while you learning? I'm not in no rush for my first software engineer job, but programming can become tedious while at the same time you are supposed to know all these different frameworks and languages and that can become draining at times. I be feeling like I don't know where I want to put my focus in, and every time I call myself taking a break, I be feeling like I'm wasting time when I could be learning more. Any guidance or help would be appreciative.


r/programminghelp • • Feb 16 '22

Other How to run GCC on Windows 11? I installed it (correctly) based on the instructions on MSYS2 and Visual Studio's websites, but it doesn't execute code

3 Upvotes

Not sure if this counts, since this is more about running code than writing it.

I have followed the instructions on these sites. I have also made sure to change "Path" in the environmental variables. https://code.visualstudio.com/docs/cpp/config-mingw https://www.mingw-w64.org/

The installation worked, but no matter what I try (running in command prompt, running in Visual Studio) I get something like: "'g++' is not recognized as an internal or external command, operable program or batch file." when I try to execute some code. Why is this?

EDIT 1: Visual Studio Code*, not Visual Studio.

EDIT 2: Seems to be working now! I'm the only user on my computer, but I had to change my system variables - not just the user variables - for it to work.


r/programminghelp • • Jan 06 '22

C# what is an interface c#

3 Upvotes

I have tried YouTube Reddit and discord with friends can anybody give like a hey stupid explanation of interfaces. What they are used for. What's the point of them, I just am not getting it.


r/programminghelp • • Dec 29 '21

Other Problems computing Fibonacci Sequence using custom CPU/Emulator

3 Upvotes

Not sure if this is the right subreddit to post this in, if it isn't please tell me where I'm supposed to post this.

Instruction Set

Code

  • Expected result:

1
1
2
3
5
  • Actual Result:

[No Output]
  • Code run through emulator

0 : MVDR, 1 0
1 : MVDR, 1 1
2 : MVDR, 0 2
3 : ADD, 0 1
4 : MVRAD, 0 2
5 : MVRR, 2 3
6 : DEC, 3
7 : MVARD, 2 0
8 : MVARD, 3 1
9 : INC, 2
10 : CMPRD, 2 20
11 : JILT, 3
4 : MVRAD, 0 2
5 : MVRR, 2 3
6 : DEC, 3
7 : MVARD, 2 0
8 : MVARD, 3 1
9 : INC, 2
10 : CMPRD, 2 20
11 : JILT, 3
[Repeats loop indefinitely]

Here's my emulator for this CPU:

https://github.com/ThatCodingGuy86/CPU-Emulator

(warning, very horrible code)


r/programminghelp • • Dec 11 '21

C# How to make sure my program does not crash if User does not fill his/her deck first

3 Upvotes

So for my assignment I have to make a deck of cards that I can fill up into the console. And then I can Shuffle, Cut Deck Randomly, Player selected cut deck, draw and display card, display all cards, and to quit it. I have EVERYTHING working except that I cannot figure out how to stop it from crashing if I do not FILL the Deck first. So my question is, what do I have to do to stop that crash? Below I will put my main program code and after that the Deck Class Code

Main Program Code

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using CardGame;

namespace DES1_Week2_Assignment

{

class Program

{

static void Main(string[] args)

{

Deck MyDeck = new Deck();

bool Running = true;

// TODO: Create a deck variable and assign a new object of type deck to it

// TODO: Create a menu that will let players choose from the following options

// - Fill Deck

// - Shuffle Deck

// - Cut Deck (Random number of cards)

// - Cut Deck (Player selects how many cards to cut off the top)

// - Draw a card from the deck and display the card

// - Display every card in the deck

// - Quit the program

while (Running)

{

Console.WriteLine("Program User Menu: ");

Console.WriteLine("1. Fill Deck\n" +

"2. Shuffle Deck\n" +

"3. Cut Deck(Random Location)\n" +

"4. Cut Deck(Player Selected)\n" +

"5. Draw and Display Card\n" +

"6. Display All Cards\n" +

"7. Quit Program");

Console.Write("What would you like to do?");

string UserChoice = Console.ReadLine();

switch (UserChoice.ToLower())

{

case "1":

{

Deck.FillDeckWithPlayingCards(MyDeck);

Console.Clear();

Console.WriteLine("Deck has been filled!\n");

}

break;

case "2":

{

Console.Clear();

MyDeck.Shuffle();

PressAKey("Deck has now been shuffled!");

Console.Clear();

}

break;

case "3":

{

Console.Clear();

MyDeck.CutDeck();

PressAKey("Deck cut randomly is a success. Press any key to continue");

Console.Clear();

}

break;

case "4":

{

Console.Clear();

Console.WriteLine("By what number would you like to cut the deck by?");

string UserResponseInput = Console.ReadLine();

int UserResponse;

bool NeedValidUserResponse = true;

bool WasANumber = int.TryParse(UserResponseInput, out UserResponse);

while (NeedValidUserResponse)

{

if (UserResponse <= 0 || UserResponse >= 52)

{

Console.Clear();

PressAKey("That is an invalid input, please input # from 1-51 only please! Press any key and select Option 4 to try again!");

Console.Clear();

}

else if (UserResponse > 0 && UserResponse < 52)

{

Console.Clear();

MyDeck.CutDeck(UserResponse);

PressAKey("Deck was cut by your input. Press any key to continue");

Console.Clear();

}

else if (WasANumber)

{

NeedValidUserResponse = false;

}

else

{

Console.Clear();

PressAKey("That is an invalid input, please input # from 1-51 only please! Press any key and select Option 4 to try again!");

Console.Clear();

}

break;

}

}

break;

case "5":

{

Console.Clear();

PlayingCard CardThatWasDrawn = MyDeck.DrawCard();

CardThatWasDrawn.DrawCardAtLocation(1,1);

PressAKey("Card is Drawn and here it is for you!");

Console.Clear();

}

break;

case "6":

{

Console.Clear();

MyDeck.DisplayDeck(13);

PressAKey("Press any key to continue");

Console.Clear();

}

break;

case "7":

{

Running = false;

continue;

}

case "quit":

{

Running = false;

continue;

}

case "exit":

{

Running = false;

continue;

}

default:

{

Console.Clear();

Console.WriteLine("That was not a valid option, please input 1-7 please.\n");

}

break;

}

}

// TODO: Add a loop so the program keeps running until the player chooses to quit

// TODO: Implement each of the menu options so they call the required functions on your deck variable

// - (Will often require additional code for full functionality)

PressAKey("Press any key to continue");

}

static void PressAKey(string Message)

{

// Save console cursor position

int OldX = Console.CursorLeft;

int OldY = Console.CursorTop;

// Write message at the bottom of the console window

Console.SetCursorPosition(0, Console.WindowHeight - 1);

Console.Write(Message);

Console.ReadKey();

// Return the cursor to its previous location

Console.SetCursorPosition(OldX, OldY);

}

}

}

DECK CLASS CODE

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using CardGame;

namespace DES1_Week2_Assignment

{

class Deck

{

// Fields ////////////////////////////////////////////////////////////////////////////////////////////////

// TODO: Declare required fields here like the array of PlayingCards to hold all of the cards in the deck.

private PlayingCard[] CardArray;

private int TopCardIndex;

private bool HasChanged;

private bool IsFilled;

// Constructors //////////////////////////////////////////////////////////////////////////////////////////

// TODO: Implement a default constructor

public Deck()

{

}

// TODO: Implement a constructor that takes an parameter for the size of the deck

public Deck(int NumCardsInDeck = 52)

{

CardArray = new PlayingCard[NumCardsInDeck];

TopCardIndex = 0;

HasChanged = true;

IsFilled = false;

}

// Public Methods ////////////////////////////////////////////////////////////////////////////////////////

// TODO: Implement AddCard method

public void AddCard()

{

PlayingCard AddCardToDeck = null;

if (TopCardIndex >= 52)

{

CardArray[TopCardIndex] = AddCardToDeck;

TopCardIndex++;

HasChanged = true;

}

}

// TODO: Implement Shuffle method

public void Shuffle()

{

Random rand = new Random();

for (int IndexCurrent = 0; IndexCurrent < CardArray.Length; IndexCurrent++)

{

int IndexNew = rand.Next(0, CardArray.Length);

Swap(IndexCurrent, IndexNew);

}

}

// TODO: Implement DrawCard method

public PlayingCard DrawCard()

{

PlayingCard CardToDraw = null;

if (TopCardIndex < 52)

{

CardToDraw = CardArray[TopCardIndex + 1];

TopCardIndex++;

HasChanged = true;

}

return CardToDraw;

}

// TODO: Implement CutDeck method

public void CutDeck(int CardToSwap = -1)

{

Random rng = new Random();

if (CardToSwap < 0)

{

CardToSwap = rng.Next(1, CardArray.Length + 1);

}

PlayingCard[] tempArray = new PlayingCard[CardToSwap];

for (int i = 0; i < CardToSwap; i++)

{

tempArray[i] = CardArray[i];

}

int CardsLeft = CardArray.Length - CardToSwap;

for (int i = 0; i < CardsLeft; i++)

{

CardArray[i] = CardArray[CardToSwap + i];

}

Console.WriteLine();

for (int i = 0; i < CardToSwap; i++)

{

CardArray[CardsLeft + i] = tempArray[i];

}

}

// TODO: Implement DisplayDeck method

public void DisplayDeck(int CardsInRow, int PositionX = 0, int PositionY = 0)

{

int CurrentX = PositionX;

int CurrentY = PositionY;

ConsoleColor OldBGColor = Console.BackgroundColor;

ConsoleColor OldFGColor = Console.ForegroundColor;

Console.BackgroundColor = ConsoleColor.White;

for (int i = TopCardIndex; i <= 51; i++)

{

if (i % CardsInRow == 0 && i != 0)

{

CurrentX = 0;

CurrentY += 4;

}

CardArray[i].DrawCardAtLocation(CurrentX, CurrentY);

CurrentX += 6;

}

Console.BackgroundColor = OldBGColor;

}

// Private Methods ///////////////////////////////////////////////////////////////////////////////////////

// TODO: Implement any private methods that you need here

private void Swap(int IndexOne, int IndexTwo)

{

PlayingCard Temp = CardArray[IndexOne];

CardArray[IndexOne] = CardArray[IndexTwo];

CardArray[IndexTwo] = Temp;

}

// Static Methods ////////////////////////////////////////////////////////////////////////////////////////

// TODO: Implement FillDeckWIthPlayingCards method

public static void FillDeckWithPlayingCards(Deck deck)

{

//deck.CardArray = deck.IsFilled;

if (deck.CardArray == null || deck.CardArray.Length != 53)

{

deck.CardArray = new PlayingCard[52];

}

PlayingCard.Ranks CurrentRank = PlayingCard.Ranks.Ace;

PlayingCard.Suits CurrentSuit = PlayingCard.Suits.Hearts;

{

}

for (int i = 0; i < deck.CardArray.Length; i++)

{

deck.CardArray[i] = new PlayingCard(CurrentSuit, CurrentRank);

if (CurrentRank == PlayingCard.Ranks.King)

{

CurrentSuit++;

CurrentRank = PlayingCard.Ranks.Ace;

}

else

{

CurrentRank++;

}

}

}

}

}


r/programminghelp • • Dec 11 '21

Python SQlite3 error in Python 3.9

3 Upvotes

I keep getting this error sqlite3.OperationalError right at (' and nothing I changes stops the error:

cursor.execute*("create table linux (Distribution, " + ",".join(column_names)* + ")")

Any clue as to why it keeps crashing with a syntax error?


r/programminghelp • • Nov 17 '21

Project Related Creating a vst/plug - in for the music industry… where do I start?

3 Upvotes

My Languages are c++, c#, and Java…


r/programminghelp • • Nov 08 '21

Other Linux Shell Script Multiplying String With Integer By Reading file

3 Upvotes

I am new on Linux and Shell programming. I've been trying to read a file which contains numbers. And I tried to multiply those numbers with "*". For example:

5

4

7

2

1

are numbers which contained in the txt file. Let's assume that the script file's name is program and the txt file's name is input. Program should run like:

>./program input

And output needs to be

*****

****

*******

**

*

And here is my code:

#!/bin/bash

filename = $1 #takes the file name from user as terminal argument

while read line; do echo -n "*";done #while loop reads the file line by line and prints asterisk

done<$filename

Well, in that code I need to multiply line and "*" but somehow I just could not find anything about it.

I would be really appreciated if you could help. Thanks for the attention.