Jump to content

Sensei

Senior Members
  • Joined

  • Last visited

Everything posted by Sensei

  1. 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
  2. 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.
  3. 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 ];
  4. 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); }
  5. 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.
  6. 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..
  7. 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.
  8. ...did not you just posted thread with title "what is the 3rd dimension?"..... ?
  9. 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.
  10. 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..
  11. 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.
  12. 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 ), (....)"
  13. Download, install and play with some 3D software. e.g. Blender, Lightwave, Maya etc (but majority of 3d apps have 30 day trials)..
  14. 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..
  15. @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
  16. 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.
  17. (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/
  18. 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.
  19. "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.
  20. https://en.wikipedia.org/wiki/Area_of_a_circle "Modern mathematics can obtain the area using the methods of integral calculus or its more sophisticated offspring, real analysis." e.g. you can calculate area of any shape using calculus.. "Using calculus, we can sum the area incrementally, partitioning the disk into thin concentric rings like the layers of an onion. This is the method of shell integration in two dimensions. For an infinitesimally thin ring of the "onion" of radius t, the accumulated area is 2πt dt, the circumferential length of the ring times its infinitesimal width (one can approximate this ring by a rectangle with width=2πt and height=dt). This gives an elementary integral for a disk of radius r."
  21. Your question is ambiguous. I am wondering whether you're talking about instructions of TCP protocol or instruction like command-line or what else? If you want to learn PID you can try: Dump all active processes to a text file before running something, dump it again after running something, compare the differences between text files.. and you will know which processes were created by "something". You can make a script. Dump, compare, display differences, wait 0.1-1s, repeat.
  22. Too long to quote. It will be fun only for programmers. https://hackernoon.com/how-it-feels-to-learn-javascript-in-2016-d3a717dd577f
  23. There is plenty of water in the far west just ahead of Los Angeles and other cities on the West Coast: the Pacific Ocean. https://en.wikipedia.org/wiki/Desalination "Desalination costs in 2013 ranged from US$0.45 to $1.00/cubic metre." https://www.google.com/search?q=desalination+cost+2020 "the cost of desalinated water in most regions could range from €0.32/m3 to €1.66 " They just should be powered from renewable energy sources..
  24. ...we have enough of members not bothering about non-empirical evidences.. they end up in Speculation part of this forum.. and then in Banned part.. ..how so.. ? You're mortal entity with limited amount of time here on the Earth.. and you spend it on asking and trying to answer questions you cannot get answers (which my post was about)... Entity living in where it is living is able to examine only place where it is living.. You cannot examine places which you don't live... You cannot prove or disprove places where you are not living.. By "true knowledge" I meant "empirically verifiable knowledge".. Why to waste time of (limited) human life time on things which are not verifiable.. ?

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.