+ 1

Ballpark challenge in C++

I’m new to coding in general. My previous experience is only VBA, which does share some similarities but a lot of differences that I’m feeling very green. So I’m looking for some help completing this challenge in C++. I have tried a few different attempts but I’m just not getting it. I know once someone points me in the right direction, I’ll be like “duh” I know I could just write it all out in the simplest terms but I don’t want to do that. It isn’t best practice. Thanks in advance

29th Dec 2019, 1:22 PM
Dan
18 Answers
+ 5
HonFu I really hate it when people start answering like this. Not even one single comma or point, just plain text and random sentences one after another, instead of one single complete answer. I really wish I could be a mod to just ban them of give them warnings, so they can understand how serious it should be.
29th Dec 2019, 1:58 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 4
1. If you want to read in a string containing whitespaces, std::cin won't get you anywhere. It is designed so that any sort of whitespace character acts as a delimiter. You will want to use std::getline() instead: https://en.cppreference.com/w/cpp/string/basic_string/getline 2. If you don't yet know how to split a string, have a look at how others tackled the problem for some inspiration: https://code.sololearn.com/cxr6SqIQOPGi/?ref=app https://code.sololearn.com/cBDrOBsf68Qv/?ref=app 3. If you combine the two approaches from above, you will end up with a container like std::vector https://en.cppreference.com/w/cpp/container/vector containing the different strings. All that is left is to go over the container and to compare each string to the possible orders. Depending on the result, add to the total price. This should be enough to get you started for a second (hopefully successful) approach. If you have any other issues, feel free to ask.
29th Dec 2019, 3:49 PM
Shadow
Shadow - avatar
+ 3
Why don't you share your attempt here so that people can take a look?
29th Dec 2019, 1:30 PM
HonFu
HonFu - avatar
+ 2
YCS VENOM, do you actually think before you post something? I was asking the poster of this question to share their attempt. This should be obvious.
29th Dec 2019, 1:49 PM
HonFu
HonFu - avatar
+ 1
YCS VENOM, your posts start to look like spam.
29th Dec 2019, 1:52 PM
HonFu
HonFu - avatar
+ 1
Aymane Boukrouh, it's not even a split-up answer yet - so far it's only babble.
29th Dec 2019, 2:00 PM
HonFu
HonFu - avatar
0
Hey Dan i can help you
29th Dec 2019, 1:26 PM
ycsvenom
ycsvenom - avatar
0
I dont know about detail yet
29th Dec 2019, 1:43 PM
ycsvenom
ycsvenom - avatar
0
Please keep calm we are in learn place not In street fighter
29th Dec 2019, 1:44 PM
ycsvenom
ycsvenom - avatar
0
Keep calm
29th Dec 2019, 1:50 PM
ycsvenom
ycsvenom - avatar
0
Why you are angry
29th Dec 2019, 1:50 PM
ycsvenom
ycsvenom - avatar
0
It's spam for who doesn't understand it
29th Dec 2019, 1:58 PM
ycsvenom
ycsvenom - avatar
0
Well... Thanks everyone for coming to my aid. I no longer have any code, unfortuantely. if the code I use completely fails, which it did, I would scrap and start again. I honestly don’t know where to begin. I dont know how to split the string; how to allow the cin function to read spaces; how to assign values to the input values etc my knowledge is a bit incomplete im afraid when it comes to these type of challenges. If I could even be pointed in the right direction I could have another try on my own. Thanks for all your help.
29th Dec 2019, 2:25 PM
Dan
0
Hi there, i tried going over the code and information you provided and still couldnt even get the first part working, nevermind continuing onto assigning values to the strings and totaling them up. Any further help you can provide would be great. On a side note, this challenge is cobsidered easy. this all seems complicated for an easy challenge. I wonder if this is easier on phython.
29th Dec 2019, 8:13 PM
Dan
29th Dec 2019, 8:56 PM
Dan
0
That’s where I have managed to get to but it isnt quite working. I will try using the playground
29th Dec 2019, 8:57 PM
Dan
29th Dec 2019, 8:59 PM
Dan
0
thank you for all your help with this. I believe in trying to complete this and getting your help, I lack the knowledge at this time to properly solve this challenge. However, I won’t abandon it. I will simply learn more and eventually, when I know enough, I will be able to solve it. If I attempted it again I might have gotten the answer but I wouldn’t understand it fully. Thank you for all your help.
30th Dec 2019, 10:12 AM
Dan