Everything posted by Sensei
-
Are the regular expressions same?
Watch some regular expression video tutorials (even couple times!). e.g. https://www.youtube.com/watch?v=sa-TUpSx1JA It is pretty good. and read some regular expression tutorials...
-
Barriers to equal opportunity in education
Inequality later in life begins with the mother's pregnancy. The embryo receives too low quality food because the mother is poor and unable to purchase all the nutrients she needs, which is common in third world countries. As a result, the brain and body of newborns are not as well developed as they would be if the mother was well fed. Poor parents are usually not well educated by themselves. They spend the all day on fighting to survive yet another day of life. As a result they are unable to teach their children the everything what child should know. Brain of child should be properly stimulated by knowledge of parents (so they must have it in the first place!), discussions, intelligent toys, games, stimulating activities. Many wealthy parents do similar mistake. They are too busy with their career to spend valuable and fruitful time with their children. Many times, during walking on streets, I am sad to hear nothing, parents not talking with their little children on streets. There is so many things child has no idea about around him or her, so many reasons for discussions. Instead I hear nothing, or I hear yelling ("don't do this!", "don't do that!", "be nice!" by which they mean "don't do anything, so I have peace and quiet".. which teaches child that preferred state is "lack of activity".. which is exactly reverse of what they should teach!)
-
Should we reply to the WOW! Signal?
If you can travel 41 light years with a decent velocity, you can also create e.g. artificial meat, change genome of microorganisms to force production of any kind of organic chemical compounds, proteins, fats, sugars, etc. etc.
-
How Trump Could Steal The Election
Oh, John, Fox News is pro-republican (or anti-democrats). They would support any republican's candidate no matter what he or she would represent by himself/herself (which they actually did four years ago, by not "slapping" misogynist molester of women). They are not pro-Trump-at-any-cost, they are pro-republican-candidate-at-any-cost. At least until they have a chance to win the election. So the next step will be to "slap" at J.Biden (or his relatives) or Harris, to prepare ground for a new republican's candidate in 2024.
-
How Trump Could Steal The Election
Fox News interrupted broadcast from the White House conference, similar like CNN earlier this week, because of D.T.'s press secretary was lying.. https://www.businessinsider.com/fox-news-cut-trump-press-secretary-false-election-fraud-video-2020-11?IR=T
-
System of equations and one parameter
Wolfram Alpha output: https://www.wolframalpha.com/input/?i=+−x^2+%2B+10x+−+1%2F2y^2+%2B+6y+−+K+%3D+0+and+−2x^2+%2B+20x+%2B+3%2F2y^2+−+18y+%3D+0
-
Are you atheist?
It doesn't matter if you are an atheist or a believer. What really matters if you are a good *) person.. I know many good atheists, and many evil to the core, believers (claiming, pretending or fooling themselves, to be good).. *) The problem is that for different people "being good" means something else.. For instance, moral behaving like having regular sex without marriage, for religious extremists and fanatics, means being evil. At the same time they cut heads of disbelievers, murder people, force people to abandon their religion, impose their views on others, terrorize people, are attempting to stupidify people (e.g. "boko haram" means "(Western) education is forbidden"). etc. etc. For me, obviously, having sex without marriage is not existing problem (i.e. it is not a sin, or an evil act). Without sex, nobody would exist in this world, so it cannot be evil. For me, forcing somebody to abandon religion through terror, is evil act. Conversion must be voluntary. Otherwise it is worthless fake faith.
-
First Post on Primes
If code takes 5-7 seconds on Core i7, in program written in C/C++, in BASIC it will take hours for the same job.. Learn C/C++ on https://en.cppreference.com/w/ Which line of code you don't understand? Tell me which line, I will tell you what it does (even though everything is pretty plain basic, and understandable without words).. Maybe this? if ((a % primes[i]) == 0) % is modulo operator. https://www.google.com/search?q=modulo+operator+c It is equivalent to: end = end * primes[ i ];
-
First Post on Primes
What is wrong with the code? It takes 7 seconds on my machine to execute this code in Tina's case. That is covered by the first line of the loop in check(), isn't? Although, it could be handled better by simply skipping even numbers using: for( int i = 1; i < half; i += 2 ) { Now it takes 5 seconds in Tina's case. But is less readable. 64 bit integers version: #include <stdio.h> //int primes[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, -1 }; int primes[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, -1 }; // We're skipping prime 2, because of optimization in the main loop. bool check(__int64 a, __int64 b) { for (int i = 1; primes[i] > 0; i++) { if ((a % primes[i]) == 0) return(false); if ((b % primes[i]) == 0) return(false); } return(true); } int main(int argc, int *argv[]) { __int64 count = 0; __int64 end = 1; printf("Primes: "); for (int i = 0; primes[i] > 0; i++) { printf("%d ", primes[i]); end *= primes[i]; } printf("\n"); printf("End %lld\n", end); __int64 half = end / 2; //for (__int64 i = 0; i < half; i++) { // Original. for (__int64 i = 1; i < half; i +=2 ) { // optimized to skip dividable by 2. __int64 a = i; __int64 b = end - a; if (check(a, b)) { //printf("Found %lld %lld\n", a, b); //printf("Found %lld %lld %lld\n", a, b, a+b ); count++; } } printf("Count %lld\n", count); return(0); }
-
First Post on Primes
Yesterday, it was too late. OK. Now, I made program in C/C++: #include <stdio.h> //int primes[] = { 2, 3, 5, -1 }; int primes[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, -1 }; bool check(int a, int b) { for (int i = 0; primes[i] > 0; i++) { if ((a % primes[i]) == 0) return(false); if ((b % primes[i]) == 0) return(false); } return(true); } int main(int argc, int *argv[]) { int count = 0; int end = 1; printf("Primes: "); for (int i = 0; primes[i] > 0; i++) { printf("%d ", primes[i]); end *= primes[i]; } printf("\n"); printf("End %d\n", end); int half = end / 2; for (int i = 0; i < half; i++) { int a = i; int b = end - a; if (check(a, b)) { //printf("Found %d %d\n", a, b); count++; } } printf("Count %d\n", count); return(0); } For test case with 3 primes it gave: Which looks good. For OP problem with 9 primes it gave too many results to show them all (so had to disable printf()): 18 mln is over twice more than OP value.
-
First Post on Primes
I am surprised by your comment. Mathematics is strict discipline. I was just pointing out that she should say "natural numbers" rather than "numbers". I was just going to say it is not true, but see @joigus already did it for me..
-
First Post on Primes
No. You're not correct. There is actually infinite quantity of pairs which summed together will give you other number. e.g. how many pair of numbers will give you 2? 1+1=2 (obvious answer) -1+3=2 (ha!) -2+4=2 etc.etc. Also e.g. rational and irrational numbers can sum to 2.. 0.5+1.5=2 (ha!) 1.9+0.1=2 etc. etc. You didn't specify that only positive integers between 0...N are accepted as answers.. You didn't specify whether 0 is excluded or included in the considerations.
-
What is the 3rd dimension?
...did not you just posted thread with title "what is the 3rd dimension?"..... ?
-
Linux - Which files execute the first instructions when calling the sftp or ssh service on port 22?
Configuration through web browser? Seriously?
-
Linux - Which files execute the first instructions when calling the sftp or ssh service on port 22?
That's job of personal firewall. When I was using WinXP, in the past, I was using Sygate Personal Firewall. Unfortunately it does not work with any new Windows. During making connection from unknown app, to the Internet, it was asking and blocking connection, showing user dialog, with question whether to make such connection with the all details about it, IP, port, protocol, packet details etc. Packets could be logged, diagnosed, analyzed etc. etc.
-
U.S. presidential election modelling
Correct. Using built-in C/C++ srand()/rand(). But you are free to use alternative pRNG.. Pick up one https://en.wikipedia.org/wiki/List_of_random_number_generators That's not true (i.e. it can be easily bypassed).. You just need to restart with different random seed at random moment.. but you have to use milliseconds, microseconds or nanoseconds timers to initialize random seed for a start. That's also not true (i.e. it can be easily bypassed).. You just need to generate two or more random values, rather than just one. e.g. ( rand() * ( RAND_MAX+1 ) + rand() ) will give you RAND_MAX ^2 = 1 073 741 824 values between. Casting to float (32 bit) will even cut some digits (mantissa of single IEEE 754 has 23 bits). If intended to be used with double (64 bit), you can use 4x rand() merged together like above in a row. People learn on mistakes. So they must be clearly stated. If somebody will read these posts in the future, must know that there was some issue with it. Otherwise will think it's correct and will repeat your mistake by himself/herself. In your link there is example source code with much better implementation of pRNG code (with high precision timer, and better quality pRNG)... and you cut it out in your reply..
-
Linux - Which files execute the first instructions when calling the sftp or ssh service on port 22?
If you have script checking log file *) every second you will have just one second delay between connection and information to user. User won't be even able to read information in such short time.. So tell me why such delay is a problem? *) or use tail -f with grep. any update to a file will be printed to console. https://shapeshed.com/unix-tail/#how-to-watch-a-file-for-changes https://www.networkworld.com/article/3529891/watching-activity-on-linux-with-watch-and-tail-commands.html You could also try TCP proxy. Original app should connect to your proxy, and proxy make connection for real. Then you can even make it interactive with user consent or rejection of the connection.
-
Are the regular expressions same?
Simply, it is not true. Regular expression has some special characters with special meanings. "U" is not one of them. It is normal letter from point of view of regex. https://www.google.com/search?q=regular+expression+special+characters "In the regex flavors discussed in this tutorial, there are 12 characters with special meanings: the backslash \, the caret ^, the dollar sign $, the period or dot ., the vertical bar or pipe symbol |, the question mark ?, the asterisk or star *, the plus sign +, the opening parenthesis (, the closing parenthesis ), (....)"
-
What is the 3rd dimension?
Download, install and play with some 3D software. e.g. Blender, Lightwave, Maya etc (but majority of 3d apps have 30 day trials)..
-
Linux - Which files execute the first instructions when calling the sftp or ssh service on port 22?
If it is already in this file, why not to use e.g. grep on it, to extract it? or make Perl or Python or bash script to parse it..
-
U.S. presidential election modelling
@VenusPrincess Why are you adding 1 in the line: sample = (double)rand() / (RAND_MAX + 1.0); rand() result can be up to RAND_MAX, so RAND_MAX / ( RAND_MAX + 1 ) will never ever give you sample = 1.0 ... 32767 / 32768 = 0.999969482421875
-
Are the regular expressions same?
No, in regular expressions it does NOT mean union.... https://stackoverflow.com/questions/8020848/how-is-the-and-or-operator-represented-as-in-regular-expressions You mixed two different independent things. Regular expressions with mathematics (set theory).. If you would enter a sample regular expression with a sample text string into the online debugger, you should see that it doesn't work as you think.
-
Are the regular expressions same?
(text) creates "capturing group", which can be referenced during replacing by e.g. $1, $2 etc. (or other following digit) Use one of many on-line regular expressions debuggers, if you have any objections. Like this one for example: https://regex101.com/
-
Barriers to equal opportunity in education
Anonymization of exams is a good idea. A person should be judged by knowledge, not by the surname or the depth of the pockets of the parents.
-
What's The Point Of Calculus??
"Massless" means "having no rest-mass".. i.e. "having no frame of reference in which particle is at rest". In the case of massive particle e.g. electron or proton, you can use external forces like electrostatic, to keep particle at rest. In electromagnetic trap.