Our server costs ~$56 per month to run. Please consider donating or becoming a Patron to help keep the site running. Help us gain new members by following us on Twitter and liking our page on Facebook!
Current time: August 24, 2026, 3:18 am

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Here's a simple programming problem for you to solve
#31
RE: Here's a simple programming problem for you to solve
(April 27, 2016 at 4:35 am)Alex K Wrote:
(April 27, 2016 at 2:17 am)pool the great Wrote: I can't C your response,Tibby.

Of course not, in Python it's basically

"
begin program
dothethingIwant();
end program
"

Smile

Lol!! So I guess python has a function for everything? That's no fun!
Reply
#32
RE: Here's a simple programming problem for you to solve
Code:
// *********************Pool's Homework****************

#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    //initialize variables
    string str;
    int integ, len, iter, count;
    
    //get the string and the length of output
    cout << "Input the string: " << endl;
    cin >> str;
    cout << "Input an integer: " << endl;
    cin >> integ;
    
    iter = 1; //iterator for exponent
    count = 0; //iterator for number of combinations
    len = str.length(); // how many letters
    const int COMB = pow(len, integ); //number of combinations
    string solutions[COMB]; //an array of strings to concatenate the solutions into

    for (int i = 0; i < integ; i++)
    {    
        while (count <= COMB-1)
        {
            for(int j = 0; j < len; j++) //ab
            {
                for(int k = 0; k < pow(len,(integ-iter)); k++)
                {
                    solutions[count] += str[j];
                    count++;
                }
            }
            
            
        }
        iter++;
        count = 0;
    }


    //print solutions
    cout << endl << endl << "There are " << COMB << " string combinations." << endl;
    cout << "String Combinations:" << endl;
    for (int i = 0; i < COMB; i++)
        cout << solutions[i] << endl;
    
    return 0;
}

You're welcome. You can PayPal me the $2k we agreed upon.

http://cpp.sh/2vh7d
"There remain four irreducible objections to religious faith: that it wholly misrepresents the origins of man and the cosmos, that because of this original error it manages to combine the maximum servility with the maximum of solipsism, that it is both the result and the cause of dangerous sexual repression, and that it is ultimately grounded on wish-thinking." ~Christopher Hitchens, god is not Great

PM me your email address to join the Slack chat! I'll give you a taco(or five) if you join! --->There's an app and everything!<---
Reply
#33
RE: Here's a simple programming problem for you to solve
That, sir, is not C. Giggle
Reply
#34
RE: Here's a simple programming problem for you to solve
But very nearly Smile
The fool hath said in his heart, There is a God. They are corrupt, they have done abominable works, there is none that doeth good.
Psalm 14, KJV revised edition

Reply
#35
RE: Here's a simple programming problem for you to solve
My contribution.  I can't be bothered with pure c either, but I wanted to show pool some recursion:

Code:
// ********************* If you're gonna cheat, might as well go for 25 points! ****************

#include <iostream>
#include <string>
using namespace std;

string str;
int digits;
int counter = 0;

// The following appends a series of single characters to whatever comes in-- originally an empty string; so each call will add a new digit //
void printStrings(string curStr, int curDigit){
    for (int i = 0; i < str.length(); i++){
        string newStr = curStr + str[i];
        if (curDigit < digits -1) printStrings (newStr, curDigit +1);  // If we aren't on the last digit, keep recursing (i.e. add another digit) //
        else {                                                         // If we ARE on the last digit, we can just go ahead and print each string //
            counter++;
            cout << endl << newStr;
        }
    }
}

int main()
{
    cout << "Input some unique characters: " ;
    cin >> str ;
    cout << "Max length: ";
    cin >> digits ;
    cout << endl << "Created following strings:" << endl;
    printStrings("", 0);                                              // Starts the recursive routine here
    cout << endl << endl << "(" << counter << " total)";
    return 0;
}

http://cpp.sh/5lfu

PS  It's the one time I'm proud to say: SteelCurtain, mine's smaller than yours! Big Grin
Reply
#36
RE: Here's a simple programming problem for you to solve
He can figure it out. The algorithm is there.
"There remain four irreducible objections to religious faith: that it wholly misrepresents the origins of man and the cosmos, that because of this original error it manages to combine the maximum servility with the maximum of solipsism, that it is both the result and the cause of dangerous sexual repression, and that it is ultimately grounded on wish-thinking." ~Christopher Hitchens, god is not Great

PM me your email address to join the Slack chat! I'll give you a taco(or five) if you join! --->There's an app and everything!<---
Reply
#37
RE: Here's a simple programming problem for you to solve
(April 28, 2016 at 7:47 am)bennyboy Wrote: PS  It's the one time I'm proud to say: SteelCurtain, mine's smaller than yours! Big Grin

Bastard!
"There remain four irreducible objections to religious faith: that it wholly misrepresents the origins of man and the cosmos, that because of this original error it manages to combine the maximum servility with the maximum of solipsism, that it is both the result and the cause of dangerous sexual repression, and that it is ultimately grounded on wish-thinking." ~Christopher Hitchens, god is not Great

PM me your email address to join the Slack chat! I'll give you a taco(or five) if you join! --->There's an app and everything!<---
Reply
#38
RE: Here's a simple programming problem for you to solve
Let's see if what you sissies posted works *cracks knuckles*
Reply
#39
RE: Here's a simple programming problem for you to solve
Let's see if pool can solve the problem in Brainfuck.
Reply
#40
RE: Here's a simple programming problem for you to solve
(April 28, 2016 at 4:48 am)SteelCurtain Wrote:
Code:
// *********************Pool's Homework****************

#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main()
{
    //initialize variables
    string str;
    int integ, len, iter, count;
    
    //get the string and the length of output
    cout << "Input the string: " << endl;
    cin >> str;
    cout << "Input an integer: " << endl;
    cin >> integ;
    
    iter = 1; //iterator for exponent
    count = 0; //iterator for number of combinations
    len = str.length(); // how many letters
    const int COMB = pow(len, integ); //number of combinations
    string solutions[COMB]; //an array of strings to concatenate the solutions into

    for (int i = 0; i < integ; i++)
    {    
        while (count <= COMB-1)
        {
            for(int j = 0; j < len; j++) //ab
            {
                for(int k = 0; k < pow(len,(integ-iter)); k++)
                {
                    solutions[count] += str[j];
                    count++;
                }
            }
            
            
        }
        iter++;
        count = 0;
    }


    //print solutions
    cout << endl << endl << "There are " << COMB << " string combinations." << endl;
    cout << "String Combinations:" << endl;
    for (int i = 0; i < COMB; i++)
        cout << solutions[i] << endl;
    
    return 0;
}

You're welcome. You can PayPal me the $2k we agreed upon.

http://cpp.sh/2vh7d

I give thumbs down for SC.
My input: AB
My input: 2
Output:
AA
BB
AB
AB
Reply



Possibly Related Threads...
Thread Author Replies Views Last Post
  Is anyone else having this problem today? Jackie 10 2808 May 4, 2022 at 5:48 pm
Last Post: awty
  Cryptocurrency in simple details. WinterHold 49 13884 September 10, 2021 at 11:02 am
Last Post: Spongebob
  Is anyone else having a problem with Facebook? Jackie 5 1848 March 15, 2018 at 1:03 am
Last Post: Minimalist
  Programming Language Swift Poll Shining_Finger 24 8328 December 2, 2015 at 7:21 pm
Last Post: bennyboy
  Programming Question Shining_Finger 8 2412 December 2, 2015 at 5:30 pm
Last Post: Tiberius
  Programming the Human Mind: Shining_Finger 21 8489 November 24, 2015 at 7:56 pm
Last Post: bennyboy
  Anyone into Android programming? emjay 97 36526 September 20, 2015 at 6:50 am
Last Post: bennyboy
  Advice Sought for Web Programming AFTT47 13 5741 April 4, 2015 at 10:41 pm
Last Post: bennyboy
  BIOS problem helpmeplz Ryantology 39 12788 January 22, 2015 at 4:25 am
Last Post: Aractus
  Home network configuration problem popeyespappy 5 2398 January 21, 2014 at 5:04 am
Last Post: Dragonetti



Users browsing this thread: 1 Guest(s)