-
Posts
1,196 -
Joined
Content Type
Forums
Status Updates
Blogs
Events
Gallery
Downloads
Store Home
Posts posted by fizzlesticks
-
-
2 hours ago, AndrewZ said:
if(*(scores[k]) > *(scores[k+1])) {
scores[k] is a double. You can't dereference a double.
-
You can use anything you would would use in a normal if statement.
if wkd[1] == 'Sunday' or wkd[1] == 'Saturday'
or
if wkd[1] in ('Sunday', 'Saturday')
-
-
42 minutes ago, wasab said:
But what are you going to use to write a function?
Lambdas mostly.
-
2 hours ago, wasab said:
What are you going to use for indent?
You use things that don't need indenting. For example here's elpiops answer in 1 line:
print(dict((lambda d: (d, [d[name].add(item) for name, item in [("Thomas", "pen"), ("Mike", "pencilcase"), ("Thomas", "rubber"), ("Tom", "scissors")]])[0])(__import__('collections').defaultdict(set))))
- 0x21 and straight_stewie
- 1
- 1
-
2 minutes ago, wasab said:
Python compiler interpretor enforces indent so not possible. In java, everything can be squeeze into one line XD
Anything that can be written in Python can be written in 1 line, it might look silly sometimes though.
-
4 hours ago, Rakanoth said:
1.) They are supposed to store passwords in an encrypted form.
Hashed, not encrypted.
QuoteSo, can we say they store passwords in cleartext? If they do not store it in a clear text, how do they know the new password is too similar?
It could be encrypted, though that's almost as bad as plain text.
Quote2.) I change my passwords every 6 months. Some websites know my 10 year old passwords which was changed like 546546849897321 times in the past. Do they store all the passwords in the database? How safe is that?
Yes, many website store your last X passwords so you can't reuse them. They're still hashed and if they're not your current password that shouldn't be a problem.
-
1 hour ago, Kamjam66xx said:
why not a deque?
std::deques have tons of overhead and are inefficient in how they store data compared to a std::vector. For a smallish program like you'll never be able to notice the difference but it's something to keep in mind for other things.
Quotestd::deque<std::string> uMathCont(128);
...loop code...
std containers have constructors that can do this work for you.
std::deque<std::string> uMathCont(std::cbegin(uMathInput), std::cend(uMathInput));
However when you iterate over the input string you're iterating over characters not strings, so it should really be std::deque<char>.
edit: if you're using a c++17 compatible compiler (which you should be!) you can let the compiler figure that out for you and just write
std::deque deq(std::cbegin(uMathInput), std::cend(uMathInput));std::endl isn't just a way to write a newline character, it also forces a flush which can have a huge impact on performance (again not really noticeable in a small program like this.)
For more a bit more info on that you can check out these 2 videos
https://www.youtube.com/watch?v=GMqQOEZYVJQ
https://www.youtube.com/watch?v=lHGR_kH0PNA
Lastly when posting code please copy/paste into code tags instead of taking a picture.
-
1 hour ago, Kamjam66xx said:
Getting a single line entered by the user
std::getline
Quotestd::deque
Should pretty much not be used. Unless you plan on allowing equations that are millions of characters long std::vector will be better in every way (even push_front.)
-
9 minutes ago, wasab said:
Java normally which doesn't really have anything meaniful until lambda is introduce in java 8
Check out java.util.function, they have ways of doing the same thing. There's not really anything "non OOP" about storing then calling a function pointer.
-
30 minutes ago, wasab said:
but you are missing out on powerful features of OOP like design patterns.
What language do you usually use? Pretty much every popular language has some kind of function pointer like thing that works just like this.
-
object.bar is just a normal object. It has a __call__ member function that gets invoked when you call object.bar().
So object.bar() calls the object.bar object.
Libraries like pyqt need the reference to the object so they are able to invoke it whenever they need to. If you try passing object.bar() to set a listener your giving qt whatever the bar() method returns instead of the bar object itself.
-
16 minutes ago, Weber01 said:
As for the switch selection I can not put getline because it's an integer
You can get the input as a string and convert it yourself using the stoi function or using a stringstream to convert it in a way similar to cin.
-
4 minutes ago, Weber01 said:
then?
Don't mix input methods. Use getline everywhere.
-
Without seeing your code we can't really help. But I'm guessing you're using std::cin >> for input which will only read input up to a space character. You can use std::getline to get around that.
-
list(set(s) ^ set(t))
-
25 minutes ago, FreQUENCY said:
Are we on the same page? Cause i think i might be missing something.
I think so but it's hard to tell from the pictures. Do you still get the error after you moved the loop?
And for adding the '*'s you don't need to do a pop and insert you can just change the value directly.
met_data_list[j] = '*'
-
6 minutes ago, FreQUENCY said:
if i remove the for loop from the while the programm will hang
You have 1 for loop inside your other for loop, it should be outside that loop. Also if nesting loops you shouldn't use the same variable name for both.
-
Replacing the count with a * only needs to be done once, not every time through the main loop. After you get to 10 of some character you're trying to add '*' + 1.
-
You could either pipe the output from the program to a python script or use the subprocess module to run the program from the python script and capture the output that way.
To pipe the output, from the command line you would run
BarcodeReader.exe | py my_python_script.py
where my_python_script.py is using the input() function to get input.
Or using the subprocess module make a script that does something like:
import subprocess as sp proc = sp.Popen(['path/to/barcodereader.exe'], stdout=sp.PIPE) out = proc.stdout.read() print(out)
-
You need to import time. If you open a command window / terminal and run it from there the window will stay open and you can see what error you're getting.
-
35 minutes ago, Natsoup said:
It loops infinitely on the cout << "You are seeing this because something went wrong. \n";
that's also the location I'm confused about atm - the if !data
The eof flag gets set when something tries to read past the end of file, because of how the getline and >> functions work this will never happen. You need to use .good() or cast to bool instead of .eof().
-
11 hours ago, Sauron said:
it's weird they would leave this in a tutorial though
The sample code is written in Python 2 where '/' is integer division. To accomplish the same thing in Python 3 you can use '//'.
- Sauron and ZacoAttaco
- 1
- 1
-
31 minutes ago, fpo said:
This seemed to work very well however I had some trouble following the SDL guide.
I ended up finding this tutorial that covers how to use the Linker in VS.
After following your software ideal, I was a bit confused as to why functions were purple but hadn't had enough time to focus on it.If you use vcpkg you shouldn't need to do anything but the last step from that tutorial to set the subsystem (if you want something besides the default.)
And I use dark theme so purple is just a normal color for me so I have no idea what that might mean.
Unsolved reference in python
in Programming
Posted
--ignore--