| resources | ||
| README.md | ||
Naomi Amethyst — Quora Answers
Naomi Amethyst, Site Reliability Architect · 251 answers on Quora
How do I find numbers having 15 HCF and 175 LCM?
Posted: ~2017 (8 years ago) Views: 924 views Source: https://www.quora.com/How-do-I-find-numbers-having-15-HCF-and-175-LCM/answer/Naomi-Amethyst-1
Answer
This can be done with prime factors:
\begin{align}HCF(x, y) = 15 &= 3 \times 5 \\ LCM(x, y) = 175 &= 5 \times 5 \times 7\end{align}
Since HCF is the common prime factors between x and y, and LCM is the complete set of prime factors (with the common factors only listed once) between x and y, by definition, all of the prime factors of the HCF must be in the prime factors of the LCM.
One of the prime factors of 15 is 3. But this is a problem. 3 is not a prime factor of 175. So there are no values x and y such that HCF = 15 and LCM = 175.
Symbolically: \nexists x, y \in \mathbb{Z}\text{ s. t. } HCF(x, y) = 15 \land LCM(x, y) = 175
Will solving problems at Project Euler help me to improve my programming skills?
Credential: Software Engineer Posted: ~2013 (12 years ago) Views: 6.6K views Source: https://www.quora.com/Will-solving-problems-at-Project-Euler-help-me-to-improve-my-programming-skills/answer/Naomi-Amethyst-1
Answer
In some ways.
Doing problems on Project Euler, even though they can often be solved with a "trick", does help you for a few reasons:
- It teaches you to think and reason about algorithms. And not even in a theoretical sense, but in a practical sense -- will this solution finish in under a minute? An hour? A day? A year? My lifetime? -- and how can I make it faster (or fast enough)?
- It teaches you the "tricks" which are not only constrained to ProjectEuler problems, but which do have real-world applications, like memoization for example.
- It teaches you how to deal with large numbers and how to reason about them. A lot of the intermediate results of some ProjectEuler problems will not fit in a 64-bit long.
- It also teaches you that brute force is almost never the best option, and sometimes isn't even an option that will work in your lifetime.
What is the best way to code a function rleEncode() that receives a string and encodes it in the following encoding Input: “AAAABCCCCCAAAAAAAAAAC” Output: [‘A’, 4,’B’, 1,’C’, 4, ‘A’, 10, ‘C’, 1]?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 94 views Source: https://www.quora.com/What-is-the-best-way-to-code-a-function-rleEncode-that-receives-a-string-and-encodes-it-in-the-following-encoding-Input-%E2%80%9CAAAABCCCCCAAAAAAAAAAC%E2%80%9D-Output-%E2%80%98A%E2%80%99-4-%E2%80%99B%E2%80%99-1-%E2%80%99C%E2%80%99-4-%E2%80%98A%E2%80%99-10-%E2%80%98C%E2%80%99-1/answer/Naomi-Amethyst-1
Answer
In Ruby:
def rleEncode(str)
str.each_char.reduce([]) do |m, e|
(m.last && m.last[0]) == e ?
m[0..-2] + [[e, m.last[1] + 1]] :
m + [[e, 1]]
end.flatten
end
Gives you this:
2.2.0 :007 > def rleEncode(str); str.each_char.reduce([]) { |m, e| (m.last && m.last[0]) == e ? m[0..-2] + [[e, m.last[1] + 1]] : m + [[e, 1]] }.flatten; end
=> :rleEncode
2.2.0 :008 > rleEncode("AAAABCCCCCAAAAAAAAAAC")
=> ["A", 4, "B", 1, "C", 5, "A", 10, "C", 1]
How do I implement pagination on Apache Cassandra Table that has dynamic columns?
Credential: Software Engineer Posted: ~2015 (10 years ago) Views: 737 views Source: https://www.quora.com/How-do-I-implement-pagination-on-Apache-Cassandra-Table-that-has-dynamic-columns/answer/Naomi-Amethyst-1
Answer
Generally you would execute the SELECT statement without a limit and a page size. Then you would save the page state and encode it as some form of continue token. When the client wants to fetch the rest of the results, they would pass in the continue token, and you would decode it into a paging state, which would then be passed back to Cassandra with the same query and it would continue where it left off.
See: Paging results
Why doesn't Google switch to using Alienware for the many benefits, such as raw power?
Posted: ~2017 (8 years ago) Views: 320 views Source: https://www.quora.com/Why-doesnt-Google-switch-to-using-Alienware-for-the-many-benefits-such-as-raw-power/answer/Naomi-Amethyst-1
Answer
Alienware isn’t the most powerful hardware.
But let’s assume that it was. Google has so much computing capacity that it doesn’t make sense to buy “the most powerful,” but rather “the most cost effective.” They have millions of servers. All designed to work together. I’d dare say it is one of the most powerful analytical clusters in existence.
When you can run jobs on a cluster like that, what do you need a super powerful laptop or desktop for? And, no, they’re not going to use Alienware for their servers because it’s far more cost effective to build their own and get exactly what they want.
But then again, that’s assuming that Alienware had the most powerful hardware. But they don’t. It’s not that unreasonable to think that a modern Google server built today might have 96 CPU cores, 2–4TB of ram, and a few TB of NVMe SSD storage. And for servers that need CUDA, probably 4-8 top-of-the-line GPGPUs. Alienware doesn’t produce anything that will even come close to those specs.
Jim draws 3 cards each from 5 decks. What is the probability that he draws 2 spades for 3 of the decks?
Posted: ~2019 (6 years ago) Views: 300 views Source: https://www.quora.com/Jim-draws-3-cards-each-from-5-decks-What-is-the-probability-that-he-draws-2-spades-for-3-of-the-decks/answer/Naomi-Amethyst-1
Answer
First we need to calculate the probability of drawing exactly 2 spades out of 3 cards drawn from a deck of cards, assuming 52 cards per deck. There are 3 ways to do this: Spade, spade, non-spade; spade, non-spade, spade; and non-spade, spade, spade. Drawing a spade has probability \frac{13}{52} because there are 52 cards in the deck and 13 of them are spades.
\begin{align}P(\text{Spade}) &= \frac{13}{52}\\P(\text{Spade} \mid \text{Spade}) &= \frac{12}{51}\\P(\text{Spade} \mid \text{Nonspade}) &= \frac{13}{51}\\P(\text{Spade} \mid \{\text{Spade}, \text{Spade}\}) &= \frac{11}{50}\\P(\text{Spade} \mid \{\text{Spade}, \text{Nonspade}\}) &= \frac{12}{50}\end{align}
So, now we can compose these into the three ways to draw 2 spades:
\begin{align}P(\{\text{Spade}, \text{Spade}, \text{Nonspade}\}) &= P(\text{Spade} \mid \{\text{Spade}, \text{Nonspade}\})\\& \times P(\text{Spade} \mid \text{Nonspade}) \times (1 - P(\text{Spade}))\\&= \frac{12}{50} \times \frac{13}{51} \times \frac{39}{52}\\P(\{\text{Spade}, \text{Nonspade}, \text{Spade}\}) &= P(\text{Spade} \mid \{\text{Spade}, \text{Nonspade}\})\\& \times (1 - P(\text{Spade} \mid \text{Spade})) \times P(\text{Spade})\\&= \frac{12}{50} \times \frac{39}{51} \times \frac{13}{52}\\P(\{\text{Nonspade}, \text{Spade}, \text{Spade}\}) &= (1 - P(\text{Spade} \mid \{\text{Spade}, \text{Spade}\}))\\& \times P(\text{Spade} \mid \text{Spade}) \times P(\text{Spade})\\&= \frac{50}{11} \times \frac{12}{51} \times \frac{13}{52}\end{align}
Finally, we can state the probability of drawing 3 cards from a deck and getting 2 spades by adding the probabilities of the 3 different ways to get it together:
\begin{align}P(&\text{3 cards and getting 2 spades from a deck})\\&= \frac{12}{50} \times \frac{13}{51} \times \frac{39}{52} + \frac{12}{50} \times \frac{39}{51} \times \frac{13}{52} + \frac{39}{50} \times \frac{12}{51} \times \frac{13}{52}\\&= \frac{117}{850}\end{align}
So, the probability of drawing two spades while drawing three cards from a deck of cards is \frac{117}{850}. Now we can calculate the probability of what we actually want: This happening exactly three times out of five tries. There are ten ways for this to happen:
- yes, yes, yes, no, no
- yes, yes, no, yes, no
- yes, yes, no, no, yes
- yes, no, yes, yes, no
- yes, no, yes, no, yes
- yes, no, no, yes, yes
- no, yes, yes, yes, no
- no, yes, yes, no, yes
- no, yes, no, yes, yes
- no, no, yes, yes, yes.
\begin{align}P(\text{way}) &= (\frac{117}{850})^3 \times (1 - \frac{117}{850})^2\\P(\text{any}) &= 10 \times P(\text{way}) = \frac{860529047157}{44370531250000} \approx 1.939\%\end{align}
Is it worth buying a TCP/IP book explaining everything about the protocol? How much is it important in computer security?
Posted: ~2018 (7 years ago) Views: 1.9K views Source: https://www.quora.com/Is-it-worth-buying-a-TCP-IP-book-explaining-everything-about-the-protocol-How-much-is-it-important-in-computer-security/answer/Naomi-Amethyst-1
Answer
Honestly, in my opinion, the relevant RFCs are freely available and are fairly good, so long as you don’t mind reading reference pages rather than prose. The RFCs are also usually what the people implementing the TCP/IP stacks use to build them, so are more likely to be correct, if you are looking for information on the protocols.
The UNIX man pages are fairly good reference material for the syscalls related to TCP/IP as well. There are also decent reference material on the Linux implementations of these protocols in the Documentation/networking directory of the Linux tree.
I like references, but I know that many people don’t. If you don’t like references, and would prefer to read prose that explains it to you, as I know many people do, don’t let me stop you from getting books on the subject.
Comments
Thanks for the point of view!
What is the largest number that rounds to 560,000?
Posted: ~2018 (7 years ago) Views: 254 views Source: https://www.quora.com/What-is-the-largest-number-that-rounds-to-560-000/answer/Naomi-Amethyst-1
Answer
It depends on how many significant digits or what decimal place you are rounding to.
If you are rounding to nearest whole number, the largest number that rounds to 560,000 is given by the following formula:
560000.5 - \epsilon\text{ for }\exists_{\epsilon \in \mathbb{R}} \forall_{k \in \mathbb{R^+}} 0 < \epsilon \le k
Comments
how about 559999.9 with a bar on top of last 9
Which ports does Cassandra use, and how are they used?
Credential: Site Reliability Architect Posted: ~2015 (10 years ago) Views: 10.7K views Source: https://www.quora.com/Which-ports-does-Cassandra-use-and-how-are-they-used/answer/Naomi-Amethyst-1
Answer
- 7000/tcp is used for inter-node communication (gossip/replication/proxied queries/etc)
- 7001/tcp is used for encrypted inter-node communication, if you enable TLS
- 7199/tcp is used for JMX management connections
- 9042/tcp is used for native clients, if enabled
- 9160/tcp is used for thrift clients, if enabled
For opscenter:
- 8888/tcp is used by the opscenter web UI.
- 61620/tcp is used by the opscenter daemon for in-bound connections
- 61621/tcp is used by the opscenter agents for in-bound connections
You have some numbers. They add up to 100. You then multiply all the numbers. What is the maximum possible product value?
Posted: ~2017 (8 years ago) Views: 3K views Source: https://www.quora.com/You-have-some-numbers-They-add-up-to-100-You-then-multiply-all-the-numbers-What-is-the-maximum-possible-product-value/answer/Naomi-Amethyst-1
Answer
Update: Anonymous’ answer is correct if you allow for non-integers. If you generalize it a little, \frac{100}{e} * e = 100, e^{\frac{100}{e}} \approx 9,479,842,689,868,732.463121780 \ldots
The answer appears to lie somewhere between all 2s and all 4s. All 3s is a decent choice at:
3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 3 * 2 * 2 = 7,412,080,755,407,364
And
3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 3 + 2 + 2 = 100
If you roll a fair six-sided die and a fair four-sided die, what is the probability that the dice add to 7777?
Posted: ~2017 (8 years ago) Views: 120 views Source: https://www.quora.com/If-you-roll-a-fair-six-sided-die-and-a-fair-four-sided-die-what-is-the-probability-that-the-dice-add-to-7777/answer/Naomi-Amethyst-1
Answer
Assuming the six-sided die is labeled 1 through 6 and the four-sided die is labeled 1 through 4, the maximum achievable sum would be 6 + 4 = 10. Therefore, the probability of achieving a sum of 7777 is 0, meaning it is impossible.
I wake up as you tomorrow and decide to fake it till I make it. What is the first thing I screw up?
Posted: ~2018 (7 years ago) Views: 143 views Source: https://www.quora.com/I-wake-up-as-you-tomorrow-and-decide-to-fake-it-till-I-make-it-What-is-the-first-thing-I-screw-up/answer/Naomi-Amethyst-1
Answer
I work remotely for a company in the security space. So, the first thing you’ll have to do is unlock my work computer with a password, then you’ll need to use a different password to log into the work VPN, and then you’ll need to use a different password to log into the various SaaS sites we make use of, all of which reasonably complex following modern security recommendations (and MFA, but I’ll assume that since you wake up as me, you’ll have access to my physical factors). Without that, you won’t be able to attend meetings or do any work at all.
My first meeting in the morning is a scrum stand-up — a meeting where we discuss in technical detail what we are working on today, and what was worked on yesterday.
The next meeting tomorrow is a discussion on technical aspects of our infrastructure that I am expected to contribute significantly to.
Then I have a 1:1 with my manager where we will discuss how the new hires are coming along in training. After that, I’ve got to support and train two new hires in the technical aspects of our infrastructure, shadow the SRE on-call for a company we acquired, make changes to a PR I got feedback on today, begin writing technical documentation for an API that we have, and make sure all of the end-of-month tasks are done by the end of the week.
Good luck.
If 8 is an even number, how do you prove it using the contradictory method?
Posted: ~2017 (8 years ago) Views: 206 views Source: https://www.quora.com/If-8-is-an-even-number-how-do-you-prove-it-using-the-contradictory-method/answer/Naomi-Amethyst-1
Answer
Assume not. Assume that 8 is not even.
It must, therefore, be odd.
That means that 2 must not divide 8.
Therefore, \frac{8}{2} must not be an integer. Therefore 4 must not be an integer.
Now we know that the set of integers is closed under addition, subtraction, and multiplication.
Therefore, no two integers added together can equal 4.
Since 2 + 2 = 4, 2 must not be an integer.
Since 1 + 1 = 2, 1 must not be an integer.
This is a contradiction, because we know that by definition, \mathbb{N} \subset \mathbb{Z}, and that 1 is the first element of \mathbb{N}.
Therefore, 8 must be even.
Is there any way to make a function pick a number from 1 to 100 in C without using rand?
Credential: Software Engineer Posted: ~2020 (5 years ago) Views: 1.1K views Source: https://www.quora.com/Is-there-any-way-to-make-a-function-pick-a-number-from-1-to-100-in-C-without-using-rand/answer/Naomi-Amethyst-1
Answer
#include <time.h>
#include <stdio.h>
static unsigned long int next = 0;
void seed() {
next = time(NULL);
}
int num() {
next = next * 1103515245 + 12345;
return (unsigned)(next/65536) % 100 + 1;
}
int main() {
int i;
seed();
for(i = 0; i < 25; i++)
printf("%d\n", num());
return 0;
}
See? No call to rand(). And yet, compile it and run it:
$ gcc -o test_rand test_rand.c
$ ./test_rand
64
98
36
5
23
4
75
1
86
12
6
37
80
75
25
36
47
74
19
40
8
47
95
97
5
And you get 25 random numbers between 1 and 100. Run it again:
$ ./test_rand
85
25
37
50
6
96
64
22
53
85
2
18
10
9
68
53
68
17
83
28
26
36
43
37
37
And you get 25 more.
Comments
Well done Naomi!! I am quite certain that this is the type of answer that the questioner was hoping for. I remember back in the late 1970’s running a FORTRAN program and we had our own Random Number Generator it wasn’t that complicated but it worked - as does yours!
How do you simplify the complex fraction, \frac{\frac{c}{d} - \frac{d}{c}}{\frac{d}{c}+2} ?
Posted: ~2017 (8 years ago) Views: 188 views Source: https://www.quora.com/How-do-you-simplify-the-complex-fraction-frac-frac-c-d-frac-d-c-frac-d-c-2/answer/Naomi-Amethyst-1
Answer
\frac{\frac{c \times cd}{d \times cd}-\frac{d \times cd}{c \times cd}}{\frac{d}{c} + 2}
\frac{\frac{c^2}{cd}-\frac{d^2}{cd}}{\frac{d}{c} + \frac{2c}{c}}
\frac{\frac{c^2 - d^2}{cd}}{\frac{d + 2c}{c}}
\frac{c^2 - d^2}{cd} \times \frac{c}{d + 2c}
\frac{(c^2 - d^2) \times c}{cd \times (d + 2c)}
\frac{(c + d)(c - d)}{d \times (d + 2c)}
Is a variable the storage location of a value or is it the name of the storage location?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 2.4K views Source: https://www.quora.com/Is-a-variable-the-storage-location-of-a-value-or-is-it-the-name-of-the-storage-location/answer/Naomi-Amethyst-1
Answer
Unless this is a question on a test or homework, the answer is in some sense “both”. If it is on a test or homework, then you should ask your professor/teacher.
A variable is a named block of memory. That is, it is both the storage location and the name of that storage location.
Of course, that assumes that your compiler didn’t just optimize it away and store it in registers for the short period of time it was used. In which case, it doesn’t have a location in memory.
Note that variables can also be pointers or references, and in that case, the value stored in memory that the variable represents is the address of another location in memory.
If you look at Wikipedia:
In computer programming, a variable or scalar is a storage location paired with an associated symbolic name (an identifier), which contains some known or unknown quantity of information referred to as a value.
—Variable (computer science) - Wikipedia
Note that an identifier is just the name part.
What is the difference between AWS's Python awscli bundle and the general linux AWS command line tools (e.g. ec2-describe-instances)?
Posted: ~2013 (12 years ago) Views: 1.9K views Source: https://www.quora.com/What-is-the-difference-between-AWSs-Python-awscli-bundle-and-the-general-linux-AWS-command-line-tools-e-g-ec2-describe-instances/answer/Naomi-Amethyst-1
Answer
The Python command line tools feel a lot more like a unified suite of tools in much the same way that the git suite feels like a unified suite of tools.
Secondly, the Python command line tools support a much wider range of services and APIs than the old ec2 tools.
Thirdly, the Python command line tools are written in Python instead of Java, which makes them start up a lot faster. This is not that noticeable on fast desktops or larger instances, but on instances like the m1.small and t1.micro, the older Java tools are so very slow to start, which is a problem for a command line tool.
Finally, the Python command line tools are newer and I believe they are intended to obsolete the old Java tools.
Has there been a work you've submitted that was too advanced for a teacher to grade?
Posted: ~2018 (7 years ago) Views: 15.1K views Source: https://www.quora.com/Has-there-been-a-work-youve-submitted-that-was-too-advanced-for-a-teacher-to-grade/answer/Naomi-Amethyst-1
Answer
Many years back, I took CS125 (Introduction to Programming for CS Majors) at UIUC my first semester.
I ended up taking it because, despite having been programming for many years prior, the proficiency exam was in Java and up until then, I had been programming in C/C++/Perl/PHP, among other languages, so they nicked me points for every syntax issue. Fair enough.
I picked up Java on my own reasonably quickly, as anyone with several years of programming with several different languages would, and then had no issues with any of the programming exercises, as they were all computer-graded. I did, however, have issues with the written exams. None of these stood after I took it up with the professor, but still, I think they are relevant to this question.
Anyway, examples:
Write some Java code that will raise an IndexOutOfBoundsException:
Clearly they were expecting something along the lines of:
int[] myArr = new int[] { 1, 2, 3 };
System.out.println(myArr[3]);
But, that’s far too indirect. I wrote:
throw new ArrayIndexOutOfBoundsException();
Apparently, we hadn’t discussed throwing our own exceptions yet. Oops.
Write some Java code that will raise a NullPointerException:
Same story:
throw new NullPointerException();
Given an int array myArray, write a loop to print each element of the array out on its own line:
Today, I might use something like System.out.println(Joiner.on("\n").join(myArray)); for small arrays, but that’s not a loop, and also requires Guava.
At the time, I wrote:
for(final int entry : myArray)
System.out.println(entry);
Short, simple, and accomplishes the task.
Apparently, we hadn’t learned about the for-each construct yet. Or final. Oops.
They had wanted something closer to:
for(int i = 0; i < myArray.length; i++) {
System.out.println(myArray[i]);
}
Oh well.
There were others, but those are the most interesting ones I remember. The professor was good about correcting it when I brought it to his attention. He had actually worked on some of HotSpot’s JIT optimizer. Unfortunately, his graders weren’t as knowledgeable.
What is the largest number which is a factor of both 48 and 72?
Posted: ~2017 (8 years ago) Views: 184 views Source: https://www.quora.com/What-is-the-largest-number-which-is-a-factor-of-both-48-and-72-1/answer/Naomi-Amethyst-1
Answer
Let’s factor them both into primes:
48 = 2 \times 2 \times 2 \times 2 \times 3 \\ 72 = 2 \times 2 \times 2 \times 3 \times 3
The largest number which is a factor of both is the list of common prime factors multiplied together.
In this case, we’ve got three 2s and one 3 common to them both. So:
2 \times 2 \times 2 \times 3 = 24
So, \frac{48}{24} = 2 and \frac{72}{24} = 3.
The answer is 24.
Say I want to start a new chat service. My start up would use only AWS services. How could I estimate the amount/size of AWS resources (EC2, S3, DynamoDB, Lambda etc.) I might need? I do not have any estimate about number of subscribers I might get.
Credential: I work with AWS daily Posted: ~2017 (8 years ago) Views: 382 views Source: https://www.quora.com/Say-I-want-to-start-a-new-chat-service-My-start-up-would-use-only-AWS-services-How-could-I-estimate-the-amount-size-of-AWS-resources-EC2-S3-DynamoDB-Lambda-etc-I-might-need-I-do-not-have-any-estimate-about-number-of-subscribers-I-might-get/answer/Naomi-Amethyst-1
Answer
Depends highly on what resources your chat system that you write uses. For example, highly-optimized C would probably be able to serve many more concurrent users than something written poorly in something like Ruby.
Most people start small, and up-size their AWS services as they grow and as they need to. That’s one of the big advantages of AWS. You can start small and pay little-to-no costs per month, and when you get bigger, you can get more resources from them, but hopefully you have monetized your platform as you get bigger and the cost of more infrastructure from AWS is just a percentage of your revenue.
A word of warning, though: With Slack, HipChat, and Discord — I am not too sure how ready the chat ecosystem is for yet another contender.
Why do I get 8 when I add and multiply 2+2×2 on calculator?
Posted: ~2017 (8 years ago) Views: 850 views Source: https://www.quora.com/Why-do-I-get-8-when-I-add-and-multiply-2+2%C3%972-on-calculator/answer/Naomi-Amethyst-1
Answer
Most basic calculators get it wrong when you deal with multiple operations. A general rule is that if the calculator does not display the full expression that you typed on the screen in addition to the answer, it most likely won’t get it right.
Any decent scientific or engineering calculator will do the right thing. And most decent computer-based calculators will do the right thing:
> 2+2*2
=> 6
Why is SQL in such high demand when I can use Excel and do half of the work, and never have to enter code again? I can literally write a macro and have a button.
Posted: ~2017 (8 years ago) Views: 1.3K views Source: https://www.quora.com/Why-is-SQL-in-such-high-demand-when-I-can-use-Excel-and-do-half-of-the-work-and-never-have-to-enter-code-again-I-can-literally-write-a-macro-and-have-a-button/answer/Naomi-Amethyst-1
Answer
Let’s pick a relatively small-ish database. Let’s say it’s 480GB, and has 200 or so tables (sheets). Load that up in Excel. I dare you. It’ll be fun.
Now, querying this small-ish database using Excel will take ages to find what you want. It doesn’t really matter what clever tricks you use, Excel is not designed to handle this much data.
Now, a database of this small-ish size probably needs concurrent access. Everyone in the company, and perhaps the website too, will want to be able to read/create/update/delete information from this database. If it is in Excel, you have to coordinate with each other and use a network share or something to copy the .xlsx file between computers. This is not fun at all when you are talking about a 480GB xlsx file. Since simply saving it will probably take 30 minutes to an hour. And so will opening it.
Now, let’s imagine a small-to-medium sized 24TB database of user behaviors. I don’t think there is a computer in the world that Excel would even be able to load a file that large.
Or the really big databases in the 100s of TB or even PB ranges.
And I haven’t even gotten into ACID semantics yet.
—
If you doubt my claims, you can download one of the datasets that Amazon hosts and try to load it into Excel. I recommend this one: AWS Public Data Set
Comments
The Data Model in Excel together with PowerQuery can recreate database tables and queries and provides dashboard functionality in worksheets. There is no size limit. The subsequently created Data Model can, if required, be imported into SQL Server.
Someone told me: “Animation doesn't have to be 44k individual drawings, there is software that helps with inbetweening.” What software helps with inbetweening?
Credential: Software Engineer Posted: ~2019 (6 years ago) Views: 444 views Source: https://www.quora.com/Someone-told-me-Animation-doesnt-have-to-be-44k-individual-drawings-there-is-software-that-helps-with-inbetweening-What-software-helps-with-inbetweening/answer/Naomi-Amethyst-1
Answer
Autodesk Maya and Blender are the big two competing products.
Maya has been used to create many of the big name animated films. Sure, it is a whole lot of work, but they aren’t inbetweening manually anymore. From small creators on YouTube to huge production companies:
Blender has been used to create many short films from indie producers:
So, I pour my heart into these answers and get zero, or a handful of upvotes. I'm ready to quit Quora. What should I do?
Posted: ~2017 (8 years ago) Views: 284 views Upvotes: 850 upvotes Source: https://www.quora.com/So-I-pour-my-heart-into-these-answers-and-get-zero-or-a-handful-of-upvotes-Im-ready-to-quit-Quora-What-should-I-do/answer/Naomi-Amethyst-1
Answer
Looking at your recent answer history shows that you are getting upvotes.
Let’s see:
User-9958851197411723867's answer to What seemingly small thing has made you lose interest in someone? has 2k upvotes
User-9958851197411723867's answer to What's the most interesting discovery you've found while researching family history? has 850 upvotes
User-9958851197411723867's answer to What is the strangest thing you have found in your child's browsing history? has 250 upvotes
User-9958851197411723867's answer to What are the greatest pleasures of human existence? has 120 upvotes
User-9958851197411723867's answer to Has there ever been a time when your kid did something so bad that you weren’t sure how to punish them? has 200 upvotes
User-9958851197411723867's answer to What is the smoothest thing a woman has ever said to you? has 23k upvotes
User-9958851197411723867's answer to What is the saddest experience you have ever had? has 550 upvotes
User-9958851197411723867's answer to What is the coolest line in history? has 550 upvotes
User-9958851197411723867's answer to What made you sad today? has 750 upvotes
I don’t really think you can say you “get like zero” upvotes.
What’s to prevent a VPN server from saving my passwords before sending them off to the bank server?
Posted: ~2017 (8 years ago) Views: 284 views Source: https://www.quora.com/What%E2%80%99s-to-prevent-a-VPN-server-from-saving-my-passwords-before-sending-them-off-to-the-bank-server/answer/Naomi-Amethyst-1
Answer
TLS.
Nearly any website you go to today, the URL starts with “https://”. Note the s in https. That indicates that your computer has negotiated encryption using TLS from your browser to the server providing that website.
Now, next to that, you should see a green lock. That indicates that your browser has verified that the other side is who they claim to be, and was vouched for by a trusted third party (a certificate authority).
Now, if the verification fails, you’ll see something that looks like this:
Why don't we hear echoes in small rooms?
Posted: ~2013 (12 years ago) Views: 3.2K views Source: https://www.quora.com/Why-dont-we-hear-echoes-in-small-rooms/answer/Naomi-Amethyst-1
Answer
You can hear echos in small room. You probably just don't interpret them as such. You probably perceive it as normal.
If you actually go into a sound-isolation room, sounds sound very different. This is because of the lack of echos. In fact, many studios have rooms like this, and the recordings then have to have artificial echo/reverb added back to the track later for it to sound normal.
Comments
If u can't perceive it how can u state that an echo is present? (only scientifically!!!!)
How can I calculate the sum and product of three numbers using algorithms?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 15.5K views Source: https://www.quora.com/How-can-I-calculate-the-sum-and-product-of-three-numbers-using-algorithms/answer/Naomi-Amethyst-1
Answer
.text
.globl calculate_prod_and_sum
.type calculate_prod_and_sum, @function
calculate_prod_and_sum:
push rbp # Set up our stack frame
mov rsp, rbp
mov edi, -36(rbp) # Count of elements
mov rsi, -48(rbp) # Array of elements
mov 0x1, -16(rbp) # Product
mov 0x0, -12(rbp) # Sum
mov 0x0, -20(rbp) # Iterator
jmp loop_cond
loop_body:
mov -16(rbp), edx # Put product in edx
mov -20(rbp), eax # Put iterator in eax
cltq # Convert iterator to index
lea 0(,rax,4), rcx # Load address of element into rcx
mov -48(rbp), rax # Put base address of elements in rax
add rcx, rax # Add rcx to rax
mov (rax), eax # Load element into eax
imul edx, eax # Multiply edx by eax
mov eax, -16(rbp) # Save eax back to product
mov -12(rbp), edx # Put sum in edx
mov -20(rbp), eax # Put iterator in eax
cltq # Convert iterator to index
lea 0(,rax,4), rcx # Load address of element into rcx
mov -48(rbp), rax # Put base address of elements in rax
add rcx, rax # Add rcx to rax
mov (rax), eax # Load element into eax
add edx, eax # Add edx to eax
mov eax, -12(rbp) # Save eax back to sum
add 0x1, -20(rbp) # Increment iterator
loop_cond:
mov -20(rbp), eax # Iterator
cmp -36(rbp), eax # Count of elements
jl loop_body # Our loop condition
mov -16(rbp), rax # Get ready to return our data
pop rbp # Tear down our stack frame
ret # Return
There are obviously some opportunities for optimization here, but I’ve left it totally unoptimized for clarity. This assumes you are using a modern x86_64 system and that you pass in the number of elements as edi and the base of the array of elements as rsi. The returned product will be in (rax) and the sum will be in (rax+4).
How does 1 gigabyte equal to 1,024 megabytes?
Posted: ~2018 (7 years ago) Views: 4K views Source: https://www.quora.com/How-does-1-gigabyte-equal-to-1-024-megabytes/answer/Naomi-Amethyst-1
Answer
By definition.
You see, computers tend to work better with powers-of-two because it corresponds directly with how many bits you need. If you have n bits, you can address 2^n different bytes. So, instead of using 10^3 = 1000, prefixes for bytes use 2^{10} = 1024.
So you get:
\begin{align*}\text{byte} &= 2^0 &= 1\\ \text{kilobyte} &= 2^{10} &= 1,024\\ \text{megabyte} &= 2^{20} &= 1,048,576\\ \text{gigabyte} &= 2^{30} &= 1,073,741,824\\ \text{terabyte} &= 2^{40} &= 1,099,511,627,776\end{align*}
… and so on.
What's the difference between a framework and a library?
Posted: ~2017 (8 years ago) Views: 311 views Source: https://www.quora.com/Whats-the-difference-between-a-framework-and-a-library/answer/Naomi-Amethyst-1
Answer
You call libraries. Frameworks, like in Soviet Russia, call you.
How can I compare two arrays in C?
Posted: ~2017 (8 years ago) Views: 1.4K views Source: https://www.quora.com/How-can-I-compare-two-arrays-in-C/answer/Naomi-Amethyst-1
Answer
#include <string.h>
int arycmp(const void *ary1, const void *ary2, size_t size1, size_t size2) {
return size1 == size2 && !memcmp(ary1, ary2, size1);
}
How do you move 100 files from a folder containing thousands in Linux via the command line?
Credential: Software Engineer Posted: Updated 6y Views: 1.2K views Source: https://www.quora.com/How-do-you-move-100-files-from-a-folder-containing-thousands-in-Linux-via-the-command-line/answer/Naomi-Amethyst-1
Answer
find source/ -maxdepth 1 -type f -print0 \
| cut -d '' -f 1-100 \
| xargs -0 mv -t target/
Comments
I snorted my coffee. Excellent.
cut -d ‘’ will not work with embedded linux/busybox & possibly MacOS cut.
Sadly the bash $’\0′ won’t work either.
Does each byte in memory have a memory address? If so, then when we allocate memory for an int like this: int* ptr=malloc (sizeof(int)); which one of those four addresses is returned?
Credential: Software Engineer Posted: ~2018 (7 years ago) Views: 598 views Source: https://www.quora.com/Does-each-byte-in-memory-have-a-memory-address-If-so-then-when-we-allocate-memory-for-an-int-like-this-int-ptr-malloc-sizeof-int-which-one-of-those-four-addresses-is-returned/answer/Naomi-Amethyst-1
Answer
malloc returns the base address (the lowest address).
How that int is stored is another matter, and depends on endianness of the system.
Let’s take, for example, 0xAABBCCDD as our int.
uint8_t *p = malloc(sizeof(int));
*((int *) p) = 0xAABBCCDD;
| p+0 | p+1 | p+2 | p+3 |
--------------+------+------+------+------+
Big Endian | 0xAA | 0xBB | 0xCC | 0xDD |
Middle Endian | 0xBB | 0xAA | 0xDD | 0xCC |
Little Endian | 0xDD | 0xCC | 0xBB | 0xAA |
All x86 systems use Little Endian, so the least significant byte comes first, and the most significant byte comes last.
Comments
Middle Endian is MIPS-endian really (is there any other architecture?)
How can I prove that sinx is a periodic function?
Posted: ~2017 (8 years ago) Views: 411 views Source: https://www.quora.com/How-can-I-prove-that-sinx-is-a-periodic-function/answer/Naomi-Amethyst-1
Answer
A function f is periodic iff \exists k \text{ s.t. } \forall x f(x + k) = f(x).
Let’s apply this to sin. sin is periodic iff \exists k \text{ s.t. } \forall x sin(x + k) = sin(x).
So, we need to pick a k. I’m going to pick 2\pi (or \tau or 360^\circ).
We now have sin is periodic iff \forall x sin(x + 2\pi) = sin(x)
Now, we know that sin takes an angle as a parameter. We also know that 2\pi = 0 in radian angles.
So we can simplify: sin is periodic iff \forall x sin(x + 0) = sin(x)
Because 0 is the additive identity, any number added to it is that number itself. So we simplify: sin is periodic iff \forall x sin(x) = sin(x).
Because functions are deterministic, and equals is reflexive, we can say that the last bit is a tautology: sin is periodic iff true.
The iff operator can be simplified away when the condition is tautological: sin is periodic.
Which is what we wanted to prove.
How do you type exponents in Quora on Windows?
Posted: ~2017 (8 years ago) Views: 238 views Source: https://www.quora.com/How-do-you-type-exponents-in-Quora-on-Windows/answer/Naomi-Amethyst-1
Answer
By typing this: [math]2^{4096}[/math] which shows up like 2^{4096}
Why is it “this->”, but not “this.”, in C++, while we use “this.” in Java?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 321 views Source: https://www.quora.com/Why-is-it-%E2%80%9Cthis-%E2%80%9D-but-not-%E2%80%9Cthis-%E2%80%9D-in-C++-while-we-use-%E2%80%9Cthis-%E2%80%9D-in-Java/answer/Naomi-Amethyst-1
Answer
In a class T, this is a pointer-to-T type (T*), which makes *this of type T. So, you can use (*this).foo, but that is clunky and because of the clunkiness, predating even C++, in C, x->foo is short-hand for (*x).foo. And so C++ picked up this->foo syntax.
Now, if you are asking why this is a pointer and not a reference, Michael Veksler's answer to Why is it “this->”, but not “this.”, in C++, while we use “this.” in Java? has a good explanation of that, so I won’t repeat it here.
Finally, because Java only has references and not pointers, they opted for the simpler syntax.
If 1∘4=5, 2∘5=12, 3∘6=21 , what is 6∘11?
Posted: ~2017 (8 years ago) Views: 1.3K views Source: https://www.quora.com/If-1%E2%88%984-5-2%E2%88%985-12-3%E2%88%986-21-what-is-6%E2%88%9811/answer/Naomi-Amethyst-1
Answer
42.
x∘y: \mathbb{Z}^+, \mathbb{Z}^+ \implies \mathbb{Z}^+
x∘y \stackrel{\text{def}}{=} \begin{cases} 5, & \text{for } (x, y) = (1, 4)\\ 12, & \text{for } (x, y) = (2, 5)\\21, & \text{for } (x, y) = (3, 6)\\ 42, & \text{otherwise} \end{cases}
Comments
One of the only answer to show there is not an answer, but an infinite amount. Even if there was a pattern, there would not be a single one.
What is subnetting? Why it is used? What are the advantages?
Posted: Updated 8y Views: 3K views Source: https://www.quora.com/What-is-subnetting-Why-it-is-used-What-are-the-advantages/answer/Naomi-Amethyst-1
Answer
Subnetting is the practice of grouping IP addresses together into smaller “sub-networks”.
The main reason is to keep the Internet routing tables of a manageable size.
There are 4 billion different valid IP addresses. A router needs to take a destination IP address and figure out where to send it. Your home router may have something simple like two or three routes:
0.0.0.0/0 dev eth0 via 24.40.131.1
24.40.130.0/23 dev eth0 direct
127.0.0.1/32 dev lo direct
192.168.0.0/24 dev eth1 direct
Routers on the open Internet, however, may have tens of thousands of entries in this table. So how do you make routing decisions quickly?
Well, there are a few ways you can search this table. The naive solution is to simply iterate over the table but this gets too slow with large tables.
Another solution is to build a route table that has a “slot” for each possible IP address. Let’s say that you use 6 bytes to store a device and via address for each IP. This would use 24GiB of memory to do efficiently. Not only is this a huge waste of memory, but also only reasonable from a cost perspective in the past 10 or so years. It is also problematic for IPv6. For IPv6, you have 2^{128} different valid addresses, and each address takes up 16 bytes to store, plus 2 or 4 for the device. To use this method for IPv6 is completely impractical because it would require 4,951,760,157,141,521,099,596,496,896 TiB of memory.
So, what most devices actually do is store the route table as a trie, with prefixes that route to certain routes:
This allows for much faster lookups, and a much smaller memory requirement if there are subnets rather than just random addresses in random locations on the Internet.
You can think of it kind of like why we have zipcodes. So that the post office doesn’t have to worry about the rest of the address if it’s not the zipcode for that post office, just make sure it is on the same truck as all of the other letters to that zipcode.
How do I convert a data URL to a normal URL?
Posted: ~2020 (5 years ago) Views: 1.3K views Source: https://www.quora.com/How-do-I-convert-a-data-URL-to-a-normal-URL/answer/Naomi-Amethyst-1
Answer
You can’t.
A data URL (such as data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==) does not link to any specific server or website. The data to be retrieved lives in the URL itself. The image/png part says it is an image, specifically a png image. The base64 part says that the rest of it is encoded in base-64. And the iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg== part is the actual image data (encoded as base-64).
Now, I’ve chosen a small red dot because it is not a large image. Larger data urls can hold larger images or other objects.
Who developed the first Linux kernel?
Credential: Software Engineer Posted: ~2018 (7 years ago) Views: 206 views Source: https://www.quora.com/Who-developed-the-first-Linux-kernel/answer/Naomi-Amethyst-1
Answer
Linus Torvalds.
He started the project and wrote the initial kernel. The name Linux is even a portmanteau between Linus and Unix.
How would I change this to a do-while loop?
Credential: Software Engineer Posted: ~2016 (9 years ago) Views: 736 views Source: https://www.quora.com/How-would-I-change-this-to-a-do-while-loop/answer/Naomi-Amethyst-1
Answer
do {
x3 = (f2 * x1 - f1 * x2) / (f2 - f1);
if(fabs((x3 - x2) / x3) > E) {
x1 = x2;
f1 = f2;
x2 = x3;
f2 = f(x3);
} else
break;
} while(true);
cout << "The root is " << x3 << "." << endl;
return 0;
}
Who can help me with translating C++ to MIPS? I've already written most of the codes.
Credential: Software Engineer Posted: ~2018 (7 years ago) Views: 7.9K views Source: https://www.quora.com/Who-can-help-me-with-translating-C-to-MIPS-Ive-already-written-most-of-the-codes/answer/Naomi-Amethyst-1
Answer
This is literally the job of the compiler. Don’t get someone to do it. We have tools for this, and they are very good.
Find a nice C++ compiler that targets MIPS and compile the C++ down into MIPS. Tell the compiler to output assembly instead of assembling it for you if you want.
See, for example, Compiler Explorer - C++ (MIPS gcc 5.4)
You roll a die 1000 times, you add up the numbers you have rolled, and you get 3698. Do you think it is a fair die?
Posted: ~2017 (8 years ago) Views: 175 views Source: https://www.quora.com/You-roll-a-die-1000-times-you-add-up-the-numbers-you-have-rolled-and-you-get-3698-Do-you-think-it-is-a-fair-die/answer/Naomi-Amethyst-1
Answer
No.
I rolled a fair die 1,000 times and added it up 1,000,000 times. And out of those million trials, I only got 3698 or higher 114 times:
1_000_000.times.reduce(0) do |m, e|
m + (1_000.times.reduce(0) do |m, e|
m + rand(1..6)
end >= 3698 ? 1 : 0)
end
=> 114
Can my ISP see what I am watching on YouTube?
Posted: ~2017 (8 years ago) Views: 89.5K views Source: https://www.quora.com/Can-my-ISP-see-what-I-am-watching-on-YouTube/answer/Naomi-Amethyst-1
Answer
OK, so every other single answer so far is wrong in one way or another.
YouTube makes use of TLS (the successor to SSL). Most websites these days do. You can tell that TLS is being used by the “https://” instead of “http://” in the address bar of your browser. Browsers often also have a green lock and sometimes the word “Secure”.
For any website that is protected by TLS, your ISP, along with any other router between you and the website’s server, can see the IP address of the website you are talking to, which for big websites, translates to the domain name of the website. So your ISP could see that you were on youtube.com, but not the path or the video ID. Your ISP, along with any other router between you and the website’s server, can also see how much data was exchanged.
TLS uses industry-standard strong encryption between your computer and the website’s server. This encryption is built on top of long-standing math problems that are known or believed to be exceptionally difficult to solve quickly — like thousands-of-years-for-millions-of-computers difficult to break if you are not the intended recipient.
Note that Google (who owns YouTube) does track what you watch, but they can do this because they own the servers that provide the content. Your browser will also keep track of history locally on your computer. If you have any programs installed on your computer designed to track your web browsing, those could track which YouTube videos you watch as well because those are on your computer, not in between.
So long as your computer isn’t compromised, it is so far beyond technical feasibility that anyone that says that ISPs can see what content is exchanged with other websites is either misinformed or spreading FUD.
Comments
Your ISP can’t see what you’re doing… unless they’ve snuck a certificate onto your computer! https://www.grc.com/fingerprints.htm
Right but still they can passively cooy the server certificate and keys and can decrypt the data offline. In fact this was the issue which was addressed by TLS 1.3 using epehermal keys.
Should probably add that depending on the TLS Extension used the requested server name is also sent in cleartext so that the server can send the right certificate for that hostname. See Server Name Indication - Wikipedia
Can you add 3 odd numbers to get 30?
Posted: ~2017 (8 years ago) Views: 3.9K views Source: https://www.quora.com/Can-you-add-3-odd-numbers-to-get-30-1/answer/Naomi-Amethyst-1
Answer
Let i, j, k \in \mathbb{Z} such that 2i + 1 is the first odd number, 2j + 1 is the second odd number, and 2k + 1 is the third odd number.
(2i + 1) + (2j + 1) + (2k + 1) = 30
2i + 1 + 2j + 1 + 2k + 1 = 30
2i + 2j + 2k + 3 = 30
2i + 2j + 2k = 27
2 \times (i + j + k) = 27
i + j + k = \frac{27}{2}
Here we have a problem: \frac{27}{2} \notin \mathbb{Z}
Because it is impossible for 3 integers to sum together to a non-integer, it must not be possible to add 3 odd numbers to get 30.
Comments
What a load of rubbish.
Care to clarify where the issue is?
why all the mathematical formula when the easiest answer is 27+9/3=30
That's not adding 3 numbers, you're adding two numbers, 27 27 and 9 3 9 3 (which is just 3 3 by the way). Adding means addition.
What is the true meaning of unconditional?
Posted: ~2017 (8 years ago) Views: 1.2K views Source: https://www.quora.com/What-is-the-true-meaning-of-unconditional/answer/Naomi-Amethyst-1
Answer
Unconditional means without conditions.
There are very few things that are truly unconditional, but many great examples can be found in the more abstract studies.
In Mathematics, for example, 1 + 1 is unconditionally the same as 2.
In Computer Science, we have conditional jumps (sometimes referred to as branches), which will change the flow of the process depending on some condition, and then we have unconditional jumps, which always change the flow of the process.
Which is greater: \frac{1}{0} or \frac{2}{0}?
Posted: ~2017 (8 years ago) Views: 136 views Source: https://www.quora.com/Which-is-greater-frac-1-0-or-frac-2-0/answer/Naomi-Amethyst-1
Answer
The result of dividing by zero is undefined. Undefined is incomparable. Attempting to compare incomparable numbers is itself undefined.
So the answer to your question is undefined, because:
\frac{1}{0} \stackrel{?}{>} \frac{2}{0}
undefined \stackrel{?}{>} undefined
undefined
How do I find roots of the 3rd order polynomial without using a graphic calculator on the exam -( 5x^3−21x^2−11x+3=0)?
Posted: ~2017 (8 years ago) Views: 583 views Source: https://www.quora.com/How-do-I-find-roots-of-the-3rd-order-polynomial-without-using-a-graphic-calculator-on-the-exam-5x-3-21x-2-11x-3-0/answer/Naomi-Amethyst-1
Answer
\begin{align}5x^3 - 21x^2 - 11x + 3 &= 0 \\ (5x - 1)(x^2 - 4x - 3) &= 0\end{align}
So, now, we can set both of the factors equal to 0:
\begin{align}5x - 1 &= 0 \\ 5x &= 1 \\ x &= \frac{1}{5}\end{align}
Plug that back into the original to make sure it works. That one was easy, let’s try the other one:
\begin{align}x^2 - 4x - 3 &= 0 \\ x &= \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} \\ x &= \frac{4 \pm \sqrt{16 + 4 \times 3}}{2} \\ x &= \frac{4 \pm \sqrt{28}}{2} \\ x &= \frac{4 \pm \sqrt{2^2 \times 7}}{2} \\ x &= \frac{4 \pm 2\sqrt{7}}{2} \\ x &= 2 \pm \sqrt{7} \\ x &= 2 + \sqrt{7} \land x = 2 - \sqrt{7}\end{align}
So plug those two back into the original to make sure they work. The ones that work are your roots.
Imagine a 3 digit number, for example 110. Reverse it and you get (0) 11. When you add the two together, you get 121, which is 11 squared. What other 3 digit numbers result in a square number when this rule is applied?
Credential: Site Reliability Architect (2013–present)8y Posted: ~2017 (8 years ago) Views: 119 views Source: https://www.quora.com/Imagine-a-3-digit-number-for-example-110-Reverse-it-and-you-get-0-11-When-you-add-the-two-together-you-get-121-which-is-11-squared-What-other-3-digit-numbers-result-in-a-square-number-when-this-rule-is-applied/answer/Naomi-Amethyst-1
Answer
ruby -e 'p (100..999).select { |x| Math.sqrt(x + x.to_s.reverse.to_i).modulo(1).zero? }'
[110, 143, 164, 198, 242, 263, 297, 341, 362, 396, 440, 461, 495, 560, 594, 693, 792, 891, 990]
How is (-1) into (-1) = 1?
Posted: ~2017 (8 years ago) Views: 165 views Source: https://www.quora.com/How-is-1-into-1-1/answer/Naomi-Amethyst-1
Answer
If you have a debt of 1 dollar, and you wanted to split it into debts of 1 dollar each, how many debts would you have now? You’d have 1.
If you have a debt of 12 dollars, and you wanted to split it into debts of 2 dollars each, how many debts would you have? You’d have 6.
Negative numbers work the same as positive numbers.
How is Dropbox able to give us a free account when they are actually using S3 for storage? If I directly use S3 as my storage for more than 5GB, will it cost me money?
Credential: I work with AWS daily Posted: ~2020 (5 years ago) Views: 390 views Source: https://www.quora.com/How-is-Dropbox-able-to-give-us-a-free-account-when-they-are-actually-using-S3-for-storage-If-I-directly-use-S3-as-my-storage-for-more-than-5GB-will-it-cost-me-money/answer/Naomi-Amethyst-1
Answer
S3 charges per byte per month, prorated, meaning that if I use 5GB for 5 minutes, it will cost less than if I use 5GB for 10 minutes.
S3 also charges per byte transferred out of S3, and per request to S3. All tiny numbers when you get down to the per-byte and per-request actual numbers that they’re usually quoted in per gigabyte and per-10000-requests, but they’re prorated, not lumped into fixed groups of gigabytes or 10,000 requests.
Dropbox, on the other hand, charges based on quota — that is, they charge you $X for access to Y GB for 1 month. You cannot get less than a certain amount. For example, if I needed to store 53.785GB for 7 days, I’d still have to pay for 100GB for 1 month. Dropbox only has to pay S3 for the 53.785GB for 7 days.
Dropbox relies on the fact that people have more quota than they are using to provide small amounts of quota to free users and still make a profit.
What is the best dorm at UIUC for incoming computer engineers?
Credential: CS@UIUC Posted: ~2015 (10 years ago) Views: 6.6K views Source: https://www.quora.com/What-is-the-best-dorm-at-UIUC-for-incoming-computer-engineers/answer/Naomi-Amethyst-1
Answer
I lived in both Allen Hall and ISR while I was at UIUC. I must say, Allen Hall is a long walk to Siebel Center, DCL, and the rest of the Engineering Quad. It wasn't so bad when the 21 Quad bus used to run every 5 minutes, but they stopped running that route.
Allen Hall had a more friendly atmosphere, but the distance meant that some nights, especially during the cold of winter, I would sleep in ACM in Siebel Center rather than try to go back home after staying up late working on things.
I knew some people in PAR, FAR, and the 6-Pack (Ike North and Ike South as some now call it) were even farther away then Allen Hall.
I liked ISR for the convenience. It was close to the Engineering Quad, and very close to the Main Quad, which was certainly nice when it was cold in the winter and when I had stayed up way too late. But, ISR was definitely less social than Allen Hall.
I eventually moved into an apartment and got a car and got a parking spot at the garage north of NCSA.
If you remove all prime numbers, would you get composite numbers?
Posted: ~2017 (8 years ago) Views: 123 views Source: https://www.quora.com/If-you-remove-all-prime-numbers-would-you-get-composite-numbers/answer/Naomi-Amethyst-1
Answer
You would get 1.
Let \mathbb{N} be the set of numbers about which we are talking.
In ascending sorted order, the first element is 1. The second element must be prime, as there are no smaller numbers to be factors other than 1. So we remove it.
Now we can repeat this process forever.
For example:
\mathbb{N} = \{ 1, 2, 3, 4, 5, 6, 7, \ldots \}
\mathbb{N}_2 = 2
So, 2 is prime. So we remove that number. Now \mathbb{N} = \{ 1, 3, 4, 5, 6, 7, \ldots \}.
We repeat the process. 3 is prime. So we remove that. \mathbb{N} = \{ 1, 4, 5, 6, 7, \ldots \}.
Repeating again, 4 must be prime since 2 no longer exists in our system. So we remove 4. \mathbb{N} = \{ 1, 5, 6, 7, \ldots \}.
And so on and so forth.
Could you please prove that 4 is a rational number? Prove that by telling that if it was an irrational number, what would be the problems.
Posted: ~2017 (8 years ago) Views: 666 views Source: https://www.quora.com/Could-you-please-prove-that-4-is-a-rational-number-Prove-that-by-telling-that-if-it-was-an-irrational-number-what-would-be-the-problems/answer/Naomi-Amethyst-1
Answer
Let’s assume 4 is irrational.
That means that \nexists p, q \in \mathbb{Z} s.t. \frac{p}{q} = 4.
Since \frac{8}{2} = 4, 8 \notin \mathbb{Z} \lor 2 \notin \mathbb{Z}.
Since \mathbb{Z} is closed under addition, and 1 + 1 = 2, 8 \notin \mathbb{Z} \lor 1 \notin \mathbb{Z}.
Since 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 8, 1 \notin \mathbb{Z}.
Since \mathbb{N} \subset \mathbb{Z}, and 1 is the first element of \mathbb{N} by definition, we’ve reached a contradiction.
How can I prove that \left(\frac{1+\sqrt{-3}}2\right)^9+\left(\frac{1-\sqrt{-3}}2\right)^9=-2 ?
Posted: ~2017 (8 years ago) Views: 10.4K views Source: https://www.quora.com/How-can-I-prove-that-displaystyle-left-frac-1-sqrt-3-2-right-9-left-frac-1-sqrt-3-2-right-9-2/answer/Naomi-Amethyst-1
Answer
First, let’s simplify the fractions by adding them together:
\frac{(1+\sqrt{-3})^9}{2^9} + \frac{(1-\sqrt{-3})^9}{2^9}
\frac{(1+\sqrt{-3})^9 + (1-\sqrt{-3})^9}{2^9}
Now, let’s multiply out the numerators. We know when we multiply a binomial in the form of (x + y)^n, we start with x^n and end with y^n, with coefficients from Pascal’s Triangle. So:
\frac{1^9 + 9 \times 1^8 \times (-3)^\frac{1}{2} + 36 \times 1^7 \times (-3)^\frac{2}{2} + 84 \times 1^6 \times (-3)^\frac{3}{2} + 126 \times 1^5 \times (-3)^\frac{4}{2} + 126 \times 1^4 \times (-3)^\frac{5}{2} + 84 \times 1^3 \times (-3)^\frac{6}{2} + 36 \times 1^2 \times (-3)^\frac{7}{2} + 9 \times 1^1 \times (-3)^\frac{8}{2} + (-3)^\frac{9}{2} + (1-\sqrt{-3})^9}{2^9}
Let’s simplify that a bit:
\frac{1 + 9 \times (-3)^\frac{1}{2} + 36 \times -3 + 84 \times (-3)^\frac{3}{2} + 126 \times (-3)^2 + 126 \times (-3)^\frac{5}{2} + 84 \times (-3)^3 + 36 \times (-3)^\frac{7}{2} + 9 \times (-3)^4 + (-3)^\frac{9}{2} + (1-\sqrt{-3})^9}{2^9}
\frac{1 + 9 \times (-3)^\frac{1}{2} - 108 + 84 \times (-3)^\frac{3}{2} + 1134 + 126 \times (-3)^\frac{5}{2} - 2268 + 36 \times (-3)^\frac{7}{2} + 729 + (-3)^\frac{9}{2} + (1-\sqrt{-3})^9}{2^9}
\frac{- 512 + 9 \times (-3)^\frac{1}{2} + 84 \times (-3)^\frac{3}{2} + 126 \times (-3)^\frac{5}{2} + 36 \times (-3)^\frac{7}{2} + (-3)^\frac{9}{2} + (1-\sqrt{-3})^9}{2^9}
Now let’s crunch out the other binomial:
\frac{- 512 + 9 \times (-3)^\frac{1}{2} + 84 \times (-3)^\frac{3}{2} + 126 \times (-3)^\frac{5}{2} + 36 \times (-3)^\frac{7}{2} + (-3)^\frac{9}{2} + 1^9 - 9 \times 1^8 \times (-3)^\frac{1}{2} + 36 \times 1^7 \times (-3)^\frac{2}{2} - 84 \times 1^6 \times (-3)^\frac{3}{2} + 126 \times 1^5 \times (-3)^\frac{4}{2} - 126 \times 1^4 \times (-3)^\frac{5}{2} + 84 \times 1^3 \times (-3)^\frac{6}{2} - 36 \times 1^2 \times (-3)^\frac{7}{2} + 9 \times 1^1 \times (-3)^\frac{8}{2} - (-3)^\frac{9}{2}}{2^9}
More simplification:
\frac{- 512 + 9 \times (-3)^\frac{1}{2} + 84 \times (-3)^\frac{3}{2} + 126 \times (-3)^\frac{5}{2} + 36 \times (-3)^\frac{7}{2} + (-3)^\frac{9}{2} + 1 - 9 \times (-3)^\frac{1}{2} + 36 \times -3 - 84 \times (-3)^\frac{3}{2} + 126 \times (-3)^2 - 126 \times (-3)^\frac{5}{2} + 84 \times (-3)^3 - 36 \times (-3)^\frac{7}{2} + 9 \times (-3)^4 - (-3)^\frac{9}{2}}{2^9}
Look at all of those n \times (-3)^\frac{k}{2} - n \times (-3)^\frac{k}{2}! Those all go to 0, so we can remove them:
\frac{- 512 + 1 + 36 \times -3 + 126 \times (-3)^2 + 84 \times (-3)^3 + 9 \times (-3)^4}{2^9}
Now more simplification:
\frac{- 512 + 1 - 108 + 1134 - 2268 + 729}{2^9}
\frac{- 1024}{2^9}
-\frac{2^{10}}{2^9}
-\frac{2^1}{2^0}
-\frac{2}{1}
-2
How fault-tolerant is Cassandra?
Credential: Site Reliability Architect Posted: ~2015 (10 years ago) Views: 2.8K views Source: https://www.quora.com/How-fault-tolerant-is-Cassandra/answer/Naomi-Amethyst-1
Answer
Cassandra is tolerant of both network partitions and nodes dying.
In a network partition, Cassandra will store writes for other nodes until those nodes come back (see "hinted-handoff"). If the node(s) recover, the changes on both sides will be replayed and last write per column will win.
If your write consistency level + read consistency level <= replication factor, then your reads may return stale data, but you have a better chance of being able to read and write in a network partition. If not, then a network partition will cause Cassandra to return errors to your application, but you won't read stale data.
In a node dying, when you bring up a new node (or tell the cluster that node isn't going to be replaced), the data will be replicated back up to the replication factor you specify in your keyspace definition.
What is -1?
Credential: Site Reliability Architect (2013–present)8y Posted: ~2017 (8 years ago) Views: 95 views Source: https://www.quora.com/What-is-1-9/answer/Naomi-Amethyst-1
Answer
It is the negated multiplicative identity.
What is the value of this expression 'float s=1/34/4-6/2+2/36/3;' in C, and how?
Credential: Software Engineer Posted: ~2019 (6 years ago) Views: 1.1K views Source: https://www.quora.com/What-is-the-value-of-this-expression-float-s-1-3-4-4-6-2-2-3-6-3-in-C-and-how/answer/Naomi-Amethyst-1
Answer
C syntax means that expressions where both operands are integer constants will be resolved with integer arithmetic. Only after it’s been resolved with integer arithmetic will it be converted to a float.
In most cases, this will be resolved by the compiler itself:
/* Simplifying: */
float s=1/3*4/4-6/2+2/3*6/3;
float s=0*4/4-3+0*6/3;
float s=0/4-3+0/3;
float s=0-3+0;
float s=-3;
So, in a simple C program:
#include <stdio.h>
int main() {
float s=1/3*4/4-6/2+2/3*6/3;
printf("%f\n", s);
return 0;
}
The C compiler will convert it to:
.LC1:
.string "%f\n"
main:
push rbp
mov rbp, rsp
sub rsp, 16
movss xmm0, DWORD PTR .LC0[rip]
movss DWORD PTR [rbp-4], xmm0
cvtss2sd xmm0, DWORD PTR [rbp-4]
mov edi, OFFSET FLAT:.LC1
mov eax, 1
call printf
mov eax, 0
leave
ret
.LC0:
.long 3225419776
The important part is:
movss xmm0, DWORD PTR .LC0[rip]
...
.LC0:
.long 3225419776
Which is where the compiler has resolved the expression and in-lined it into the assembly. “But,” I hear you ask, “what is 3225419776 about?” Well, in hex, it’s 0xc0400000 and in IEEE 754 format:
It looks like:
sign = 1 (0x1 / 0b1)
exponent = 128 (0x80 / 0b10000000)
fraction = 4194304 (0x400000 / 0b10000000000000000000000)
So, the number is negative (because sign is 1). To calculate the number, we need to put it in this formula:
(-1)^{\text{sign}} \times 2^{\text{exponent} - 127} \times 1.\text{fraction}
Filling in, we get:
(-1)^1 \times 2^{128 - 127} \times 1.5 = -2^1 \times 1.5 = -3
Comments
Hi there! Thanks a lot for your answer. I am a beginner programmer. So, I can’t understand the last part of your answer related to compiler. Will you please suggest any book so that i can understand the last part?
What do binaries refer to in Linux?
Credential: Software Engineer Posted: ~2016 (9 years ago) Views: 297 views Source: https://www.quora.com/What-do-binaries-refer-to-in-Linux/answer/Naomi-Amethyst-1
Answer
Technically any file that contains unprintable US-ASCII or UTF-8 characters (or more generally, any file that contains unprintable characters in the current character set) is called a binary file.
But more colloquially, people tend to call any executable that fits the above description a binary. (I’ve even heard it used about executables that don’t fit the above description.)
An executable is any file that has the executable file mode set. (But most commonly ELF-formatted linker output and scripts with a shebang line at the top)
ELF-formatted linker output designed for the current architecture is what most people mean by Linux binaries, and they are typically stored in $PATH.
A family of 5 persons need 60 kg of rice in a month. If there are 3 guests, how much rice will they need?
Posted: ~2017 (8 years ago) Views: 6.4K views Source: https://www.quora.com/A-family-of-5-persons-need-60-kg-of-rice-in-a-month-If-there-are-3-guests-how-much-rice-will-they-need/answer/Naomi-Amethyst-1
Answer
There isn’t enough information to answer the question. We don’t know if each person in the family requires the same amount of rice each month. We don’t know if the guests require the same amount of rice as the family. We don’t know how long the guests are staying.
However, we can make a guess. Let’s say that the family is 2 adults and 3 children, and that the children are aged 5, 7, and 9. Let’s also assume that rice is all that is being eaten. Now, let’s also assume that the 9 year old eats 75% of what the adults eat, and that the 7 year old eats 75% of what the 9 year old eats, and that the 5 year old eats 75% of what the 7 year old eats.
Now we can do algebra:
x + x + 0.75x + 0.75^2x + 0.75^3x = 60
2x + \frac{3x}{4} + \frac{9x}{16} + \frac{27x}{64} = 60
\frac{128x}{64} + \frac{48x}{64} + \frac{36x}{64} + \frac{27x}{64} = 60
\frac{128x + 48x + 36x + 27x}{64} = 60
\frac{239x}{64} = 60
239x = 3840
x = \frac{3840}{239}
So we know that each parent eats \frac{3840}{239} kg of rice each month. And the 9 year old eats \frac{3840 \times 3}{239 \times 4} = \frac{2880}{239} kg, the 7 year old eats \frac{2880 \times 3}{239 \times 4} = \frac{2160}{239} kg, and finally the 5 year old eats \frac{2160 \times 3}{239 \times 4} = \frac{1620}{239} kg
Now let’s assume the 3 guests is another family, 2 adults and 1 child aged 7, and assume they eat as much as their counterparts in the family. And let’s assume they stay for one month.
So, we have 2 \times \frac{3840}{239} + \frac{2160}{239} = \frac{7680 + 2160}{239} = \frac{9840}{239} kg of extra food, or \frac{24180}{239} kg total.
These are just assumptions and your numbers may be different.
How do I multiply every element in array by 2 in Java? In example: int[] input = {8, 25, 7} => int[] result = {16, 50, 14} int[] input = {21, 0, 8, -12} => int[] result = {42, 0, 16, -24}
Posted: ~2017 (8 years ago) Views: 4.5K views Source: https://www.quora.com/How-do-I-multiply-every-element-in-array-by-2-in-Java-In-example-int-input-8-25-7-int-result-16-50-14-int-input-21-0-8-12-int-result-42-0-16-24/answer/Naomi-Amethyst-1
Answer
private static int[] dbl(final int[] input) {
return Arrays.stream(input)
.map(x -> x * 2)
.toArray();
}
Running it in Java REPL gives:
java> dbl(new int[]{1,2,3,4})
int[] res0 = [2, 4, 6, 8]
Why did this line of code z[0]='a' caused a problem?
Credential: Software Engineer Posted: ~2015 (10 years ago) Views: 231 views Source: https://www.quora.com/Why-did-this-line-of-code-z-0-a-caused-a-problem/answer/Naomi-Amethyst-1
Answer
Let's simplify your code:
int main(int argc, char *argv) {
char *z = "Hello";
z[0] = 'a';
printf("%s\n", z);
return 0;
}
This will fail on line 3, for the same reason. The string literal "Hello" is stored in the ".rodata" section, and z is just a pointer to it:
Contents of section .rodata:
4005e0 01000200 48656c6c 6f00 ....Hello.
Since that section is read-only, you cannot manipulate it, and attempting to do so is a segmentation fault:
Program received signal SIGSEGV, Segmentation fault.
0x0000000000400548 in main (argc=0x1, argv=0x7fffffffe2a8 "\253\345\377\377\377\177") at test.c:3
3 z[0] = 'a';
Comments
The commented line in his example is where it segfaults. And that is after the z = "Hello"
Thanks for pointing this out, my mistake! I was reading that comment as "here's what happens when it executes that line of my code"
If 1=4, 2=8, 3=12, and 4=?
Posted: ~2017 (8 years ago) Views: 493 views Source: https://www.quora.com/If-1-4-2-8-3-12-and-4/answer/Naomi-Amethyst-1
Answer
4=1, obviously. You stated 1=4 in your condition and = is commutative.
Comments
I do not understand the need for such silly questions.
Can AWS Instance Storage to CPU/RAM ratio be tuned?
Posted: ~2015 (10 years ago) Views: 802 views Source: https://www.quora.com/Can-AWS-Instance-Storage-to-CPU-RAM-ratio-be-tuned/answer/Naomi-Amethyst-1
Answer
Most people use EBS to configure their storage needs. EBS is persistent, and with PIOPS, it can be very fast storage as well. This is networked storage, however. It isn't local to the instance, but for most purposes, that doesn't really matter: It still appears as a disk on the instance, but you can attach it, detach it, move it to another instance, or even snapshot it and clone it.
Amazon has 3 different kinds of EBS:
- Standard/Magnetic EBS. This is the cheapest per GB/mo. It is also slow: About 100 I/O ops/s.
- GP2/SSD. This is about twice as expensive as standard is per GB/mo, but it can be much faster, bursting up to 3,000 I/O ops/s.
- IO1/Provisioned IOPS. This is more expensive, costing per provisioned IOPS/mo and per GB/mo. You tell Amazon how many I/O ops/s you want, up to a limit, and they will provision the storage so that you will get that many I/O ops/s consistently.
What does (? i) mean in a Java regular expression?
Credential: Software Engineer8y Posted: ~2017 (8 years ago) Views: 40 views Source: https://www.quora.com/What-does-i-mean-in-a-Java-regular-expression/answer/Naomi-Amethyst-1
Answer
It means the next part is case-insensitive.
What happens if you write a C++ program that writes past the end of an array?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 336 views Source: https://www.quora.com/What-happens-if-you-write-a-C++-program-that-writes-past-the-end-of-an-array/answer/Naomi-Amethyst-1
Answer
Just like in C, when you write past the end of an array, you write into memory that is being used for other things in your program (causing weirdness to happen), or you write into an unmapped page, which causes a pagefault followed shortly by a segmentation fault.
Unless, of course, you are in real mode, in which case, you just clobber things.
What is the use of booting?
Credential: Site Reliability Architect Posted: ~2017 (8 years ago) Views: 4.6K views Source: https://www.quora.com/What-is-the-use-of-booting/answer/Naomi-Amethyst-1
Answer
In computer terminology, booting is a shorten form of bootstrapping. There are a number of interesting problems to solve when a computer is just starting up, and because of this, programmers likened it to pulling oneself up by the straps of their shoes. This was later shortened to “bootstrapping,” then later to “booting.”
The computer first performs a Power-On Self Test (POST) that is controlled by the BIOS, which is built into a chip on your motherboard.
The BIOS then needs to find a disk drive that it can load the operating system (OS) from and transfer control to the OS. The problem is that the BIOS is generic and doesn’t know any specifics of what OS or how the OS is laid out on the disk.
So, it assumes that there will be a Master Boot Record (MBR) at the beginning of at least one of the disks. The MBR has 446 bytes of space for the operating system to install what is known as a “bootloader,” which is a small executable that knows how the OS uses the disks and what the OS expects to be already set up. So, when the BIOS finds the MBR, it will load those 446 bytes off of the disk into memory and transfer control to the bootloader.
The bootloader will then need to read the disk to find out where the kernel image is stored. To do this, it might first need to read more bootloader code off the disk if the bootloader is bigger than 446 bytes. This is what is called a staged bootloader. Once the bootloader has found the kernel image, and potentially also an initial ramdisk for early OS initialization, it will load the kernel image (and initial ramdisk, if applicable) into system memory, and will transfer control over to the kernel.
The kernel will then do a scan of hardware to figure out what the computer has attached to it, load any modules or drivers necessary, initialize all of the various hardware components, set up memory management, and transition the CPU to protected mode, which will protect the OS from normal programs.
The kernel will then locate and execute the initialization program for the userland (programs that run inside the operating system). On Linux and other Unixes, this program is called init, and is responsible for starting all of the rest of the programs that are necessary or desired for the system to operate, including the graphical login prompt or the text-based login prompt. I am less familiar with Windows, but I’d bet that the Windows equivalent is responsible for starting all of the system services, and the graphical login prompt.
So, because of these numerous steps to get to a running OS, as well as because someone early on said it was like pulling oneself up by the straps of one’s boots, it became known as bootstrapping, and then booting.
How many prime numbers are there between 1 to 2000?
Credential: Site Reliability Architect (2013–present)8y Posted: ~2017 (8 years ago) Views: 301 views Source: https://www.quora.com/How-many-prime-numbers-are-there-between-1-to-2000/answer/Naomi-Amethyst-1
Answer
303:
2.2.0 :001 > class Fixnum; def prime?; (2...self).all? { |d| self % d != 0 }; end; end
=> :prime?
2.2.0 :002 > (2...2000).select(&:prime?)
=> [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999]
2.2.0 :003 > _.count
=> 303
How do I find the unit digit of 5^{1021} \times 7^{2000} \times 17^{1700}?
Credential: Site Reliability Architect (2013–present)8y Posted: ~2017 (8 years ago) Views: 144 views Source: https://www.quora.com/How-do-I-find-the-unit-digit-of-5-1021-times-7-2000-times-17-1700/answer/Naomi-Amethyst-1
Answer
You could just calculate out the answer:
5^{1021} \times 7^{2000} \times 17^{1700} =
405154622891769403511969573987539533263144987123980\ddots
184061289388915066910477742371352223705025694261336\ddots
560025762729651900872956659920539085733818214782982\ddots
905048930944733223679985711934095146328961951020009\ddots
803328059072458241543307963184401382960487770128816\ddots
589780029908437994777311113210788456575452134223070\ddots
510096676925151798608121118370262894736710314621835\ddots
393827619614305325342246320676346650770703585427245\ddots
907003170907851331181422803646171536931972180322581\ddots
682757257050109319747485212415395010266745817285140\ddots
215478220904798794335546510335204427225596182332828\ddots
913267853203283273249734912504061342807560204584267\ddots
084157023246891675862960010522436783683053702603750\ddots
232618942211971707220121908726871226514758878370856\ddots
107536868700566563324640783727216739648681045667961\ddots
314940639213463058653882872234699895560871382106561\ddots
145517841640969766828699415420555496798532130814586\ddots
351436839264533389089155449983180362527221844796507\ddots
832667037087064970016377015450045283590885756288558\ddots
772258142394472229089600369903359514944431184859018\ddots
868787044453814964083750722336521399550070604333517\ddots
275371227415814504828099365174703861475411046583353\ddots
939637632640808404301557764631061834111312534479889\ddots
906405686429131195242386951626466300458326367016802\ddots
417340891062805815041213766431951907462036704702553\ddots
686946664425840563854729929396235817950651012572598\ddots
552949051445746058722096355711814886518576159427849\ddots
343405506876608964429437995219527721773756669340014\ddots
517309871711996703952220027826816287217924809141913\ddots
733606425987003550685096818037042560814235721125171\ddots
634214331017416781147681755919655669703778709849219\ddots
159935961033601594577671497947653958961884748291387\ddots
033378412133724974319015728149682509494190598338934\ddots
458072646845688762077147476542933967011449061235371\ddots
940211881052087388393306394620633304420222581141941\ddots
849838191169636936989504987751168537122085274841437\ddots
980910264134868460142202406601768631140253120040179\ddots
981498644596719233351239828720274339755807284275919\ddots
591679423180475913989648450229068776065704307591975\ddots
939981894401380350509020166497750754620154491899918\ddots
398855249258074494621902962050502005234912689153871\ddots
616649875111344741714075647042960523984791017556139\ddots
752271292011573720021286962233493652459308183436101\ddots
979435301543164024713387826622730369775209812664057\ddots
416130285574311498578972271230080938604479746563820\ddots
842400262004641250727571543178300688239841079307453\ddots
018996955078943095475633067617012186668338757543226\ddots
793713333219967069217395266305719101768437332213573\ddots
390558647596439467690890441005734576560031142228768\ddots
499352402938400580577459435498049101134031596504794\ddots
342869834311359097568446516093932212798490632306619\ddots
751327649174648662647861348793234617190264677067882\ddots
799650813799953054883958761869574839218565795054621\ddots
468354858040070963469037154364072657350274153287948\ddots
709156266542530888230248349951524062895274261113305\ddots
634548223007918797470890091345709229222839258755286\ddots
829325302330641920675768317532432055010363983746428\ddots
176443733455869864725043105924907834798598347069277\ddots
510335617167354691998959559584958261700811583579510\ddots
088995592096785363843775294420536807893950033088603\ddots
873639000664387698385323303325954686264073130530236\ddots
729894748582950114381288443811895164434871801463115\ddots
404528173720790380324737983161399960730703835019724\ddots
168410242098023766159459457876799190772428111113546\ddots
986451756395846507571014408754548374189381364669838\ddots
537041469913954064604846285769035956553108987914321\ddots
655119688430719781909702082395076827104747908224209\ddots
038451672132668939480810413594498803653318172085556\ddots
020142130251779093271927565834465069545449714257627\ddots
201481675881914694972798513159850346229492519317275\ddots
237896898434146616822535949427521697653278314241781\ddots
511823914295188786546822484663191614101184012087608\ddots
371260450080170527990239554017149607833801536034835\ddots
486499347811948740068817097138447360909380786621902\ddots
719468219681634655494977518233705338528448448640089\ddots
261425284480522979519843701918945983118714739223243\ddots
554200779101063902892935327079801368696515255734315\ddots
218940318886524505694458350289243039543551626463928\ddots
562797469956527210938887197254028408832424407251671\ddots
809960139870489238177996954015306346423349676144338\ddots
136311986523112506053065949586592735025251107876710\ddots
970537576655417057748797677521836763517832522636610\ddots
982047859611582006531743731068378437926807715625160\ddots
585677403416107341939933608543743388795845785307021\ddots
861141816781848782804417906751189654374181585583420\ddots
035276452017635173453765881324964771990625531969513\ddots
345212328277210035326011013058194958173806822811340\ddots
590846091581331321965220304548438434721902012825012\ddots
20703125
So the answer is 5.
Comments
Simple when you know how.
I assume that the person asking the question understands powers and basic multiplication. You simply multiply 5 5 by itself 1020 1020 times, multiply 7 7 by itself 1999 1999 times, and multiply 17 17 by itself 1699 1699 times, and then multiply these products together.
If you’re a tad bit clever, you can also use Exponentiation by squaring - Wikipedia
How do I solve square roots, specifically the square root of 72/square root of 2?
Posted: ~2017 (8 years ago) Views: 348 views Source: https://www.quora.com/How-do-I-solve-square-roots-specifically-the-square-root-of-72-square-root-of-2/answer/Naomi-Amethyst-1
Answer
\frac{\sqrt{72}}{\sqrt{2}} = \sqrt{\frac{72}{2}} = \sqrt{36} = \sqrt{2 \times 2 \times 3 \times 3} = \sqrt{2^2 \times 3^2} = \sqrt{(2 \times 3)^2} = 2 \times 3 = 6
How would you write a program that gives all possible monetary change?
Credential: Software Engineer Posted: ~2016 (9 years ago) Views: 216 views Source: https://www.quora.com/How-would-you-write-a-program-that-gives-all-possible-monetary-change/answer/Naomi-Amethyst-1
Answer
This is not particularly efficient, nor is it in C. I figure that once the algorithm is understood, implementing it in any language you care to should be trivial. I have implemented it in Ruby because it was the easiest language to show the algorithm off in:
DENOMINATIONS = [1, 5, 10, 25, 50, 100, 200, 500, 1000, 2000, 5000, 10000]
WAYS_TO_PAY_CACHE = {}
def _ways_to_pay(amount)
return [{}] if amount == 0
DENOMINATIONS.select do |denomination|
denomination <= amount
end.map do |denomination|
ways_to_pay(amount - denomination).map do |way_to_pay|
new_way_to_pay = {}.merge(way_to_pay)
new_way_to_pay[denomination] ||= 0
new_way_to_pay[denomination] += 1
Hash[new_way_to_pay.sort]
end
end.flatten(1).uniq
end
def ways_to_pay(amount)
WAYS_TO_PAY_CACHE[amount] ||= _ways_to_pay(amount)
end
def pretty_print(way_to_pay)
way_to_pay.map do |denomination, count|
"#{count}*$#{denomination / 100.0}"
end.join(", ")
end
puts ways_to_pay(ARGV[0].to_i).map { |w| pretty_print(w) }.join("\n")
The basic idea here is:
- if the amount due is 0 cents, then there is one way to pay that, and that is by paying no money of any denomination.
- otherwise, for every denomination that is less than or equal to the amount due, you can pay using that denomination. How? Well, you subtract that denomination from the amount due, and you then figure out all of the different ways to pay
n - dwhich we can do by just running our function again, and finally you add the denomination to the results that came back.
Running the code above produces something like this:
$ ruby ways_to_pay.rb 20
20*$0.01
15*$0.01, 1*$0.05
10*$0.01, 2*$0.05
10*$0.01, 1*$0.1
5*$0.01, 3*$0.05
5*$0.01, 1*$0.05, 1*$0.1
4*$0.05
2*$0.05, 1*$0.1
2*$0.1
If the mother is coded as UHKWRP, how will the father be coded?
Credential: Software Engineer8y Posted: ~2017 (8 years ago) Views: 235 views Source: https://www.quora.com/If-the-mother-is-coded-as-UHKWRP-how-will-the-father-be-coded/answer/Naomi-Amethyst-1
Answer
You’re probably thinking that it should encode to “UHKWDI” (right-shift-3 keyed Caesar Cipher; followed by reversing the resultant string).
But you could make an argument that it should encode to “N:KWRP” if we assume the cipher is a tad bit more advanced:
> "father".each_char.zip(
"mother".each_char.zip("UHKWRP".each_char).map { |uncoded, coded|
coded.ord - uncoded.ord
}
).map { |uncoded, key|
(uncoded.ord + key).chr
}.join
=> "N:KWRP"
Why my boyfriend don't want to give me his Instagram password?
Posted: ~2019 (6 years ago) Views: 2.5K views Source: https://www.quora.com/Why-my-boyfriend-dont-want-to-give-me-his-Instagram-password/answer/Naomi-Amethyst-1
Answer
What you are asking him to do is a violation of Instagram’s Terms of Service which you both (since you both have an account) are contractually obligated to abide:
- You can't […] use login credentials […] of other users.
Not to mention, it’s a huge invasion of privacy; a huge red flag for unhealthy relationships; and a jerk move.
How could I check the number of files in a folder without counting them?
Credential: Site Reliability Architect Posted: ~2018 (7 years ago) Views: 2.1K views Source: https://www.quora.com/How-could-I-check-the-number-of-files-in-a-folder-without-counting-them/answer/Naomi-Amethyst-1
Answer
Ultimately, you must count them. Win32, Linux, and POSIX all give no direct way to get a count of files in a directory, but rather just provide a method to list the dirents. To get a count, one must then iterate over that list and tally them up.
Even if they did provide a count of the number of dirents in a directory, not all dirents are files. They may be other folders, symbolic links (shortcuts), or special devices, among other things.
Not that counting is particularly hard, and most UIs provide for counting the files automatically without much interaction. And counting files is, unless you have a ridiculous number of files, very fast.
In C++, I'm trying to do a calculator program. However, I want to make it so that I can write an equation such as '18+32-43*15'. Is that possible?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 667 views Source: https://www.quora.com/In-C++-Im-trying-to-do-a-calculator-program-However-I-want-to-make-it-so-that-I-can-write-an-equation-such-as-18+32-43*15-Is-that-possible/answer/Naomi-Amethyst-1
Answer
It’s not pretty, but here’s a parser that does what you ask:
#include <stdio.h>
#include <string.h>
struct token {
int type;
int value;
int len;
};
struct parse_element {
int type;
int state;
int (*reduce)(int, int);
};
struct token lex(char *buf, char *end) {
struct token tok = {0};
if(buf == end)
return tok;
switch(*buf) {
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
tok.type = 1;
tok.len = 1;
tok.value = *buf - '0';
struct token next = lex(buf + 1, end);
if(next.type == tok.type) {
while(next.len--) {
tok.value *= 10;
tok.len++;
}
tok.value += next.value;
}
return tok;
case '+':
tok.type = 2;
tok.len = 1;
return tok;
case '-':
tok.type = 3;
tok.len = 1;
return tok;
case '*':
tok.type = 4;
tok.len = 1;
return tok;
case ' ':
return lex(buf + 1, end);
default:
tok.type = -1;
return tok;
}
}
int add(int x, int y) {
return x + y;
}
int sub(int x, int y) {
return x - y;
}
int mul(int x, int y) {
return x * y;
}
struct parse_element parse_table[8][5] = {
{ {0}, {1, 1, NULL}, {0}, {0}, {0} },
{ {3, 0, NULL}, {0}, {1, 2, NULL}, {1, 3, NULL}, {1, 4, NULL} },
{ {0}, {1, 5, NULL}, {0}, {0}, {0} },
{ {0}, {1, 6, NULL}, {0}, {0}, {0} },
{ {0}, {1, 7, NULL}, {0}, {0}, {0} },
{ {2, 0, &add}, {0}, {2, 0, &add}, {2, 0, &add}, {1, 4, NULL} },
{ {2, 0, &sub}, {0}, {2, 0, &sub}, {2, 0, &sub}, {1, 4, NULL} },
{ {2, 0, &mul}, {0}, {2, 0, &mul}, {2, 0, &mul}, {2, 0, &mul} }
};
int parse(char *buf, char *end) {
int state = 0;
struct token stack[10];
int state_stack[10];
int depth = 0;
for(;;) {
struct token cur_token = lex(buf, end);
if(cur_token.type == -1) {
printf("Lex error at: \"%s\"\n", buf);
return -1;
}
struct parse_element element = parse_table[state][cur_token.type];
switch(element.type) {
case 0:
printf("Parse error: state=%d, depth=%d, tok=%d, val=%d\n", state, depth, cur_token.type, cur_token.value);
return -1;
case 1:
state_stack[depth] = state;
state = element.state;
stack[depth++] = cur_token;
buf += cur_token.len;
break;
case 2:
state = parse_table[state_stack[depth-3]][1].state;
stack[depth-3].type = 1;
stack[depth-3].value = (*element.reduce)(stack[depth-3].value, stack[depth-1].value);
stack[depth-3].len = 0;
depth -= 2;
break;
case 3:
return stack[depth-1].value;
}
}
}
int main(int argc, char **argv) {
if(argc != 2) {
printf("Usage: %s <expr>\n", argv[0]);
return 1;
}
printf("%d\n", parse(argv[1], argv[1] + strlen(argv[1])));
return 0;
}
Compile with:
gcc -o expr_parse expr_parse.c
Run with:
$ ./expr_parse '5-42886593*43'
-1844123494
$ ./expr_parse '18+32-43*15'
-595
$ ./expr_parse '18+32-43*15*'
Parse error: state=4, depth=4, tok=0, val=0
-1
$ ./expr_parse '18+32-43*15*c'
Lex error at: "c"
-1
$ ./expr_parse ''
Parse error: state=0, depth=0, tok=0, val=0
-1
How can I stay the right side of an INTP?
Credential: Site Reliability Architect (2013–present)7y Posted: ~2018 (7 years ago) Views: 43 views Source: https://www.quora.com/How-can-I-stay-the-right-side-of-an-INTP/answer/Naomi-Amethyst-1
Answer
By translating as necessary as they rotate about their longitudinal axis.
What is the function of assembly language?
Posted: ~2017 (8 years ago) Views: 2.5K views Source: https://www.quora.com/What-is-the-function-of-assembly-language/answer/Naomi-Amethyst-1
Answer
Assembly languages are a notation for making sense of machine code.
Processors have a set of instructions that the processor understands and causes certain actions (state transitions) to take place within the processor. These instructions are encoded as binary numbers, and the processor decodes them into other binary control lines to process the instructions.
However, we as humans aren’t great at reading numbers and understanding which number maps to which function. So assembly language is simply taking the numbers that represent different functions within the processor and giving them short names.
In x86 machine code, we have something that looks like this in hex:
0xB040B32828D8
What does it do? Well, let’s split it into some instructions. In this case, each instruction is two bytes, but that is not always the case, and depends on the specific instruction, so you can’t just group them in groups of 4:
0xB040 0xB328 0x28D8
The first instruction (0xB040) moves (0xB) the value 0x40 (the last part of the instruction) into register al (0xB0). In assembly, we’d write it: mov al, 0x40 which is short for “move into al the value 0x40”.
The second instruction (0xB328) moves (0xB) the value 0x28 (the last part of the instruction) into register bl (0xB3). In assembly, we’d write it: mov bl, 0x28 which is short for “move into bl the value 0x28”.
The third instruction (0x28D8) subtracts (0x28) the register bl from the register al (0xD8 = 0b11011000 = 0b11 0b011 0b000; 0b11 = both are registers, 0b011 = bl, 0b000 = al). In assembly, we’d write it: sub al, bl which is short for “subtract from al, bl”.
In assembly, these three instructions together would be written like:
mov al, 0x40
mov bl, 0x28
sub al, bl
Because even in hexadecimal, some instructions require bit-wise interpretation, this is difficult and annoying to do when you just want to figure out what some machine-code does, or if you want to write machine-code. So, if you work that low to the processor as an engineer, you most likely use assembly because there are tools that can convert between assembly and machine-code and back.
Why does Google translate German words and phrases into English very badly?
Posted: ~2017 (8 years ago) Views: 244 views Source: https://www.quora.com/Why-does-Google-translate-German-words-and-phrases-into-English-very-badly/answer/Naomi-Amethyst-1
Answer
Tom Scott has a really great video explaining this on YouTube:
What are the numbers less than 100 that have 4 as their ones digit?
Credential: Site Reliability Architect (2013–present)7y Posted: ~2018 (7 years ago) Views: 52 views Source: https://www.quora.com/What-are-the-numbers-less-than-100-that-have-4-as-their-ones-digit/answer/Naomi-Amethyst-1
Answer
94
84
74
64
54
44
34
24
14
4
-4
-14
-24
-34
-44
-54
-64
-74
-84
-94
-104
...
and it keeps going.
Can you actually make anything with C language?
Credential: Software Engineer Posted: ~2015 (10 years ago) Views: 1K views Source: https://www.quora.com/Can-you-actually-make-anything-with-C-language/answer/Naomi-Amethyst-1
Answer
There are very few things that C cannot do natively, and we have inline assembly blocks for that.
I'd suggest taking a look at this article:
The Unreasonable Effectiveness of C
If you had to guess the experience level of the programmer that wrote this script based on their code, what would you guess?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 908 views Source: https://www.quora.com/If-you-had-to-guess-the-experience-level-of-the-programmer-that-wrote-this-script-based-on-their-code-what-would-you-guess/answer/Naomi-Amethyst-1
Answer
The indentation bothers me. Other than that, I echo pretty much what everyone else has said: It’s beginner code. No real use of OOP. And that massive conditional needs to be broken up. When using the builder pattern, typically builders are their own objects, so that more than one can be built at any given time. Constants or objects are better to use than strings for configuration parameters (“higher”/”lower”). Also, that compareSymptoms function should return a set of matching symptoms rather than alerting the user about it. The bracing inconsistency (and other style inconsistencies) also bothers me.
Finally, the indentation bothers me.
Comments
Some really hardcore programmers I know think OOP is boogers.
And if that were the only thing wrong this this snippet of code, perhaps. But it’s not. And there is a difference between using something like C and not making use of OOP practices and using Javascript. And this example shows that there was an attempt made to use OOP, but a lack of understanding.
Yeah I noticed that. There was a failed attempt at using OOP. I was just mentioning that I know some big guys who think OOP sucks in a very theoretical way. I don’t agree with them because OOP is easier in the head, but I lack the knowledge to even understand their points.
Carrie and Brent leave home at the same time. Carrie drives due east at a rate of 40 mph while Brent drives due south at a rates of 50 mph. How far apart are they after 5 hours?
Posted: ~2019 (6 years ago) Views: 403 views Source: https://www.quora.com/Carrie-and-Brent-leave-home-at-the-same-time-Carrie-drives-due-east-at-a-rate-of-40-mph-while-Brent-drives-due-south-at-a-rates-of-50-mph-How-far-apart-are-they-after-5-hours/answer/Naomi-Amethyst-1
Answer
We’ll assume that this is on Earth, since you mention East and South. You do not specify where on Earth, so I’ll assume 0, 0 where the equator meets the prime meridian. This isn’t something feasible here, as it is over a body of water, but it’ll suffice.
Next, we draw some lines from there around the Earth for the speed times time of each person:
Now, we just need to connect the two endpoints of these lines to get the distance between the final locations of the two people:
Now, we just measure the length of that distance line:
And there we go, 320.073 miles.
—
P.S. Note that this is different from what we would have gotten if the Earth were flat:
Which is:
How do I turn the number 11 into 10 without subtracting?
Posted: ~2017 (8 years ago) Views: 5.3K views Source: https://www.quora.com/How-do-I-turn-the-number-11-into-10-without-subtracting/answer/Naomi-Amethyst-1
Answer
With a magnetic needle and a steady hand. Or butterflies:
(comic courtesy of XKCD)
—
Bit-wise and with 10:
11
& 10
----
= 10
You could also shift right and shift left:
11
>> 1
-----
= 01
<< 1
-----
= 10
You could bit-wise xor it with 1:
11
^ 1
----
= 10
Comments
Pass (1,1) as input to AND gate and XOR gate to get get (1,0) as output.
What are the integer solutions to a + b = ab ?
Posted: ~2017 (8 years ago) Views: 276 views Source: https://www.quora.com/What-are-the-integer-solutions-to-a-+-b-ab/answer/Naomi-Amethyst-1
Answer
a=b=0 \text{ or } a=b=2
I found out that a colleague access my laptop without my permission, should I report to the management?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 5.7K views Source: https://www.quora.com/I-found-out-that-a-colleague-access-my-laptop-without-my-permission-should-I-report-to-the-management/answer/Naomi-Amethyst-1
Answer
Where I work, we have a policy that all unattended computers must be locked.
Now, if your computer was locked, and they did anything other than leave a note that the lock password was weak/compromised, then they should be reported.
If your computer was not locked, then it depends on what the access was. If the access was just to lock the computer, or to leave a note or some other harmless action informing you that you left your computer unlocked, then you should be thankful that they didn’t report you to management/infosec.
If neither of the above apply, then sure, report them. But ask them why first, they might have had good, if ill-advised, intentions.
How does Cassandra handle highly concurrent write (update) operation?
Credential: Site Reliability Architect Posted: ~2017 (8 years ago) Views: 1.6K views Source: https://www.quora.com/How-does-Cassandra-handle-highly-concurrent-write-update-operation/answer/Naomi-Amethyst-1
Answer
Cassandra logs the write to its commitlog (which gets written to disk every 10 seconds) and then adds the write to its memtable in memory.
Once the memtable is full, Cassandra will sort, compress, index, and generate a bloom filter for the memtable, and write these out to disk as an SStable. When enough SStables have been generated, it will compact several small (relative to the output) SStables into one larger SStable.
So, writes happen very quickly and are generally non-contentious, meaning that highly concurrent write operations are generally well-tolerated.
Comments
Thanks for the answer. If there are two concurrent write operations that are updating the same row’s DIFFERENT columns, both should be persisted, correct?
Correct. And if they update the same column in the same row, the last one wins.
How does the Int32.Parse Method actually convert strings?
Credential: Software Engineer Posted: ~2016 (9 years ago) Views: 229 views Source: https://www.quora.com/How-does-the-Int32-Parse-Method-actually-convert-strings/answer/Naomi-Amethyst-1
Answer
I am not sure which language Int32.Parse belongs to in the question, but the general way that one would go about parsing integers out of strings with something like this, if you had no library function for it (in C):
int atoi(char *p) {
int ret = 0;
int neg = (p && *p == '-');
if(neg)
p++;
while(p && *p)
ret = ret * 10 + *(p++) - '0';
if(neg)
ret = -ret;
return ret;
}
Note: The above hasn’t really been tested much, and doesn’t deal with invalid input.
Is Amazon S3 really cheap?
Credential: I work with AWS daily Posted: ~2016 (9 years ago) Views: 3.8K views Source: https://www.quora.com/Is-Amazon-S3-really-cheap/answer/Naomi-Amethyst-1
Answer
Keep in mind that outbound traffic from S3 costs money. Either indirectly from EC2 (S3 to EC2 is free, EC2 to the Internet costs money), from Cloudfront (S3 to Cloudfront is free, Cloudfront to the Internet costs money), or from S3 directly (S3 to the Internet costs $0.09/GB, so if you average [6MB * 300,000 - 1GB (because the first GB is free)] * $0.09/GB, you pay about $161 for the bandwidth).
What protocol should I use to make servers communicate in a distributed system? I originally wanted to make my own but people suggested RPC. Is there any newer alternative that also doesn't necessarily require a reply to every request?
Posted: ~2018 (7 years ago) Views: 240 views Source: https://www.quora.com/What-protocol-should-I-use-to-make-servers-communicate-in-a-distributed-system-I-originally-wanted-to-make-my-own-but-people-suggested-RPC-Is-there-any-newer-alternative-that-also-doesnt-necessarily-require-a-reply/answer/Naomi-Amethyst-1
Answer
Queue-based distributed systems work well for notification-type interactions with other services.
In one of my personal projects, I have a bunch of microservices which each listen on a per-service primary event queue and a per-instance queue, along with a few other topics and specialized queues. I use protobufs for the message format that gets dropped on the queue.
For things that don’t require replies, the event is simply encoded and dropped on the appropriate service’s primary event queue. For things that do require replies, a request is encoded and dropped on the appropriate service’s queue, and the requester instance’s specific queue name is sent along with the request. When the service responds, it’ll encode a response and drop it on the requester’s instance specific queue. This specific project is in Java, so I use Futures for the RPC responses.
I happen to use Redis Cluster for the queues and topics because the project was already using Redis for other things, but RabbitMQ or Kafka or something like that should work just as well.
How can I translate this statement (p∧¬q) ∧ ((q∧¬q)->p) into a conjunctive normal form and a disjunctive normal form?
Posted: ~2017 (8 years ago) Views: 1.8K views Source: https://www.quora.com/How-can-I-translate-this-statement-p%E2%88%A7%C2%ACq-%E2%88%A7-q%E2%88%A7%C2%ACq-p-into-a-conjunctive-normal-form-and-a-disjunctive-normal-form/answer/Naomi-Amethyst-1
Answer
(p \land \lnot q) \land ((q \land \lnot q) \to p)
Well, q \land \lnot q is categorically false.
\text{false} \to p is categorically true.
So we get: (p \land \lnot q) \land \text{true}
We can simplify to just:
p \land \lnot q
Which, coincidentally, is both in the conjunctive normal form, and in the disjunctive normal form.
Alternatively, you could create a truth-table:
p
T F
+---+---+
T | F | F |
q +---+---+
F | T | F |
+---+---+
Because the truth-table only has T at one point, we can get the disjunctive normal form of that by conjoining the to parts into p, because the T value is in $p$’s T column, and \lnot q because the T value is in $q$’s F row. So we get: p \land \lnot q. We’d normally repeat this for any other Ts in the table, and disjoin them all together.
To get the conjunctive normal form, we need to look at where the Fs are. First, $p$’s F column is all Fs, so we can write \lnot p. And $q$’s T row is all Fs, so we can write q. Now we disjoin them: \lnot p \lor q. But we want the Ts, not the Fs, so we negate the whole thing: \lnot ( \lnot p \lor q ). But this isn’t in the normal form, so we distribute the negation out: \lnot \lnot p \land \lnot q, then we simply the double negation: p \land \lnot q.
This latter method is known as a Karnaugh map - Wikipedia
What is 4913 divisible by?
Posted: ~2017 (8 years ago) Views: 64 views Source: https://www.quora.com/What-is-4913-divisible-by/answer/Naomi-Amethyst-1
Answer
irb(main):002:0> (1..4913).select { |x| 4913 % x == 0 }
=> [1, 17, 289, 4913]
What is the square root of 1.040?
Posted: ~2017 (8 years ago) Views: 313 views Source: https://www.quora.com/What-is-the-square-root-of-1-040/answer/Naomi-Amethyst-1
Answer
So, you can simplify this by converting the decimal to a fraction, then simplifying:
\begin{align}\sqrt{1.040} &= \sqrt{\frac{1040}{1000}} \\ &= \sqrt{\frac{2^4 \times 5 \times 13}{2^3 \times 5^2}} \\ &= \frac{4 \times \sqrt{5} \times \sqrt{13}}{2 \times 5 \times \sqrt{2}} \\ &= \frac{2 \times \sqrt{5} \times \sqrt{13}}{5 \times \sqrt{2}}\end{align}
How many whole numbers have the sum 110?
Posted: ~2017 (8 years ago) Views: 4.2K views Source: https://www.quora.com/How-many-whole-numbers-have-the-sum-110/answer/Naomi-Amethyst-1
Answer
There are 607,163,746 partitions of 110.
Dave bought 46 stamps consisting of 15 cents and 50 cents stamps. The total cost was 13.20 pounds. How many 15 cents stamps did he buy?
Posted: ~2019 (6 years ago) Views: 350 views Source: https://www.quora.com/Dave-bought-46-stamps-consisting-of-15-cents-and-50-cents-stamps-The-total-cost-was-13-20-pounds-How-many-15-cents-stamps-did-he-buy/answer/Naomi-Amethyst-1
Answer
\begin{align}x+y&=46\\15x+50y&=1320\\y&=46-x\\15x+50(46-x)&=1320\\15x-50x&=1320-2300\\-35x&=-980\\x&=\frac{980}{35}\\&=28\\y&=46-28\\&=18\end{align}
So, 28 15-cent stamps and 18 50-cent stamps.
How are stacks used in a non-recursive function program?
Credential: Software Engineer Posted: ~2018 (7 years ago) Views: 2.2K views Source: https://www.quora.com/How-are-stacks-used-in-a-non-recursive-function-program/answer/Naomi-Amethyst-1
Answer
The same way they are used in a program with recursive functions.
The stack is used to keep track of what function called which other function.
int square(int x) {
return x * x;
}
int main() {
int a = square(64);
int b = square(2);
printf("a = %d, b = %d\n", a, b);
return 0;
}
In the example, without a stack, when line 2 is executed, how does it know whether to return to line 6 or line 7? The stack is used to store where to return to.
Why is 1/3 0.33, 2/3 0.66, but then 3/3 is somehow 1? Then what is 0.99 as a fraction?
Posted: ~2017 (8 years ago) Views: 405 views Source: https://www.quora.com/Why-is-1-3-0-33-2-3-0-66-but-then-3-3-is-somehow-1-Then-what-is-0-99-as-a-fraction/answer/Naomi-Amethyst-1
Answer
OK, let’s go into this in more detail. You know long division?
\frac{1}{3} means divide 1 by 3. So let’s do that:
0.333333...
+-------------
3 | 1.0000000...
- 0.9
-----
0.10
- 9
------
10
- 9
----
10
- 9
----
10
- 9
----
10
- 9
----
10
...
As you can see, it doesn’t stop. We’re not getting anywhere. You could keep doing that forever. What that means is that you don’t have a specific, finite decimal representation of \frac{1}{3}. So, we write it like 0.33\dots, 0.3333\dots, 0.\dot{3}, 0.\overline{3}, 0.(3), or a number of other ways. In all cases, this means that the $3$s go on forever, and don’t stop after 2 places.
Now, if they did stop, then it wouldn’t be \frac{1}{3}. For example, 0.33 = \frac{33}{100}, and 0.333333 = \frac{333333}{1000000}.
The same thing applies for \frac{2}{3}. Now, \frac{3}{3} = 1 because it divides cleanly. But also, 0.\overline{9} = 1, and there is a whole other discussion around that, but that is defined to be the same number in mathematics.
What do most software engineers not understand about computer security when writing their code?
Credential: Software Engineer Posted: ~2018 (7 years ago) Views: 1.1K views Source: https://www.quora.com/What-do-most-software-engineers-not-understand-about-computer-security-when-writing-their-code/answer/Naomi-Amethyst-1
Answer
User-supplied data can not be trusted.
It must be validated and treated carefully. Stack smashing, buffer overruns, SQL injections, most forms of application-level denial of service, XSRF, XSS, heartbleed, shellshock, and a number of other vulnerability classes are caused by trusting user-supplied data.
You should assume that the data you have been given is malicious until otherwise determined.
So many denial of service vulnerabilities are based on applications attempting to process data that has been maliciously crafted. Put limits on what you will process, and bail out early. This includes authentication credentials. Multi-factor authentication and geographical analysis can help prevent weak passwords from compromising your systems.
Any code executed by the user can not be trusted.
All of that Javascript validation you have that executes in the browser is great for quickly informing your user that they’ve done something wrong, but is totally useless against an attacker. Validation must happen on the server-side.
Cryptography is tricky to get right, don’t write your own.
Instead, use an industry-standard library with an industry-standard algorithm for doing cryptography.
For authentication systems, timing is important.
When checking authentication credentials, you should do so using a constant-time algorithm. Otherwise, it is possible for attackers to guess what percentage of the credential they guessed was correct. With this information an attacker can easily bypass the authentication system. Note that normal string comparison is not constant-time.
Software has bugs. Prepare for that with layers of defense.
For security especially, your software will have bugs, somewhere. Use multiple layers of security so that if one layer is compromised, the whole system is not compromised.
All network traffic can be intercepted and modified. Use encryption.
Encryption is lightweight enough now that there is no excuse for not using strong encryption when sending traffic over the network. Use encryption. Preferably encryption with perfect forward secrecy.
Comments
You might want to add a blurb on safe key exchange, such as two-factor identification.
How soon will 128-bit and 256-bit operating systems be available on the market?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 601 views Source: https://www.quora.com/How-soon-will-128-bit-and-256-bit-operating-systems-be-available-on-the-market/answer/Naomi-Amethyst-1
Answer
Well, for there to be such an operating system, there would have to be such CPUs readily available. There are not.
The reason that there are not CPUs with more than 64 bits of address space is quite frankly, in this day and age, we don’t need it. Let’s look at what this actually looks like:
16 bit address space allowed for the address space to be 64KB.
32 bit address space allowed for the address space to be 4GB.
64 bit address space allows for the address space to be 16EB. That’s Exabytes. An exabyte is roughly 1,000,000 TB.
Address space is primarily used to allow programs to use that much memory, or virtual memory at once. In the 32 bit days, computers could have more than 4GB of memory, but could only be “looking at” a 4GB chunk at a time, so individual processes had a hard time using more than 4GB, even if the OS allowed for more than 4GB of memory total.
The other thing that this typically means is how wide the general purpose registers are, which determines how fast you can do operations on numbers bigger than 2^64.
Now, let’s look at 128 and 256 bit address spaces:
128 bit address space would allow for the address space to be 281,500,000,000,000 YB. That’s Yottabytes. A yottabyte is roughly 1,000,000 EB.
256 bit address space would allow for the address space to be 95,780,971,304,118,053,647,396,689,196,894,323,976,171,195,136,475,136 YB.
That is an absolutely mind-boggling number of bytes.
So, because there is no market demand for it, I doubt we will see CPUs with 128 or 256 bit address space anytime soon.
When should I use Iterable vs Collection in Java? What are pros and cons of both?
Credential: Software Engineer Posted: ~2016 (9 years ago) Views: 3.3K views Source: https://www.quora.com/When-should-I-use-Iterable-vs-Collection-in-Java-What-are-pros-and-cons-of-both/answer/Naomi-Amethyst-1
Answer
Iterable is for objects where you only need to iterate over their contents.
Collection is for objects that are containers of other objects and allow you to see how many elements they contain, add elements, and remove elements from them, in addition to being Iterables.
How do I turn off a computer in 3 seconds?
Posted: ~2016 (9 years ago) Views: 1.5K views Source: https://www.quora.com/How-do-I-turn-off-a-computer-in-3-seconds/answer/Naomi-Amethyst-1
Answer
On Linux systems you can use:
sudo poweroff -f
Note that this does not sync the filesystem, or shut things down in an orderly fashion. The disk may become corrupted. No data from currently running processes will be allowed to save anything. This instructs the system to cease power to the system, and is just about as bad as pulling the plug.
… but, assuming you can type the command and your sudo password in 3 seconds, and the system is responsive enough to load the poweroff binary from disk as well in under 3 seconds, once it executes, the system is off in less than a second.
My mother wants my phone password, what should I do?
Posted: ~2019 (6 years ago) Views: 2.1K views Source: https://www.quora.com/My-mother-wants-my-phone-password-what-should-I-do/answer/Naomi-Amethyst-1
Answer
A good password is one that is sufficiently strong (not a dictionary word, or a manipulation of one, not any personal information, preferably more than 8 characters in length), used for a single purpose (not shared between, for example, your phone and your e-mail), and known only to you. Passwords that do not meet these criteria should be changed as soon as possible.
If you must, give the current password to her. It is now no longer a good password and is instead a compromised password, so change it. Repeat as necessary.
What is the square root of 45/5?
Posted: ~2017 (8 years ago) Views: 950 views Source: https://www.quora.com/What-is-the-square-root-of-rightarrow-sqrt-frac-45-5/answer/Naomi-Amethyst-1
Answer
\begin{align}\sqrt{\frac{45}{5}} &= \frac{\sqrt{45}}{\sqrt{5}} \\ &= \frac{\sqrt{3 \times 3 \times 5}}{\sqrt{5}} \\ &= \frac{\sqrt{3^2}\times\sqrt{5}}{\sqrt{5}} \\ &= \sqrt{3^2} \\ &= 3\end{align}
How should I treat ID/PW in C source code to hide them from a malicious attack?
Credential: Software Engineer Posted: ~2018 (7 years ago) Views: 182 views Source: https://www.quora.com/How-should-I-treat-ID-PW-in-C-source-code-to-hide-them-from-a-malicious-attack/answer/Naomi-Amethyst-1
Answer
Don’t store credentials in source code.
Are you trying to make a login system? If so, you should be using a cryptographically secure hashing algorithm, like SHA-256 and generating random tokens using a cryptographically secure PRNG. If you are allowing the user to supply the password, you instead need something like scrypt and salting.
If you are trying to prevent against unauthorized use of your application, should someone get the compiled output file, you’ll probably need to use some form of encryption, like AES-256 (in GCM or CBC mode) to encrypt the contents of the binary, and then have the main method prompt for the decryption key (or password, followed by a PBKDF function like PBKDF2), and decrypt the binary into memory and jump into it. This will only help so long as no one shares the password, however.
Comments
using SHA-256 or any plain hash for pw hashing is a major no-no, you have to use a method with salt and more computational effort than a normal hash function
Which of the following statements is true about recursion, ‘recursive functions can hog a lot of memory and cause system crashes’ or ‘all Python functions are recursive in nature’?
Credential: Software Engineer Posted: ~2018 (7 years ago) Views: 13K views Source: https://www.quora.com/Which-of-the-following-statements-is-true-about-recursion-recursive-functions-can-hog-a-lot-of-memory-and-cause-system-crashes-or-all-Python-functions-are-recursive-in-nature/answer/Naomi-Amethyst-1
Answer
The former, but not really for the implication it gives.
Let’s get the latter out of the way: It is perfectly acceptable and often desired to write non-recursive Python functions. And certainly not all (or even most) of them are recursive.
Now, back to the former: Any function can “hog a lot of memory,” not just recursive functions. Take, for example:
#include <unistd.h>
#include <stdlib.h>
int main() {
for(;;) {
calloc(1<<20, 16);
fork();
}
return 0;
}
There is no recursion in that function, and it will cause almost any non-hardened system to become so slow that is unusable.
However, this is different from a crash. A crash in this case occurs when the system hits a bug in how it handles out-of-memory situations. Because this is an edge case, such bugs are not super uncommon.
So, because recursive functions are functions, and because functions can hog a lot of memory, and because out-of-memory conditions sometimes trigger bugs that cause system crashes, the former statement is technically true.
Now, to address the reason that many people claim that recursive functions in particular are bad, and show why it doesn’t cause system crashes: Recursive functions, like all function calls, are implemented with a stack. Each time you call a function, the information about what function you are currently executing is put on the top of the stack so that when the function you are calling returns it knows where to return to.
If you don’t have a base case in your recursive function, or if the data you are operating on is sufficiently deep that you end up recursing a lot, you’ll have a large stack.
But operating systems put limits on the size of the stack, and when you exceed that size, they will kill your process with a segmentation fault (meaning you overstepped the bounds of the memory given to your process), and most stacks are limited to a few megabytes maximum. Far too little to put memory pressure on the system. People call this a crash, but it is a process crash, not a system crash. A system crash is a kernel panic or blue screen of death.
Comments
A good compiler will convert a tail recursive function to a loop … so not all recursive functions will use a stack frame per call.
Why are there so many server-side languages (yes, server sides specifically)?
Credential: Software Engineer Posted: Updated 5y Views: 692 views Source: https://www.quora.com/Why-are-there-so-many-server-side-languages-yes-server-sides-specifically/answer/Naomi-Amethyst-1
Answer
There are many because they each apply better to their own set of problems. Each language has its own pros and cons, and each language has its own community.
The question should be why are there so few client-side languages? Well, that is because only one is universally supported right now, and that is Javascript. You can control the server side, so you don’t need universal support for it, but you cannot control the client-side, so Javascript is pretty much the only option. WebAssembly is catching on, and that should allow more proliferation of client-side languages, but it is still not quite well enough supported for most people.
Why does Rice play Texas?
Credential: Site Reliability Architect (2013–present)6y Posted: ~2019 (6 years ago) Views: 304 views Source: https://www.quora.com/Why-does-Rice-play-Texas/answer/Naomi-Amethyst-1
Answer
John F. Kennedy answered that question with his immortal words: Not because it is easy, but because it is hard.
He follows that up with:
because that goal will serve to organize and measure the best of our energies and skills, because that challenge is one that we are willing to accept, one we are unwilling to postpone, and one which we intend to win, and the others, too.
Why does Google offer unlimited storage for photos via Google Photos app? What's in it for Google?
Posted: ~2017 (8 years ago) Views: 7.3K views Source: https://www.quora.com/Why-does-Google-offer-unlimited-storage-for-photos-via-Google-Photos-app-Whats-in-it-for-Google/answer/Naomi-Amethyst-1
Answer
Like with all things Google, if you aren’t paying for it, advertisers are.
Google provides useful services. In exchange, their algorithms build extremely accurate profiles about who you are, what you like, what you don’t like, and most importantly, what is the best advertisement in their massive portfolio of customers to show you right then.
Advertisers can select from a huge range of targetting options to target ads on all kinds of pieces of information, and Google will match up ads to you. Or advertisers can simply let Google’s algorithms try the ads out on different people until Google figures out what the ideal profile is to show that ad to.
The advertiser tells Google how they wish to pay for the ad, which can be one of three options last I checked. 1) per 1,000 impressions; 2) per click; or 3) per conversion. For options 2 and 3, it’s in Google’s best interest to make the most out of every impression, so the algorithms will calculate based on huge amounts of information it has collected about you and the ads, which you are most likely to click on versus which will pay the most if you click on to figure out which, on average, will make them the most money. If it’s per conversion, it is usually much steeper, price-wise, but that way Google will also track if you bought something after clicking on the ad, and they get paid when you buy something.
So, unless it is simply brand awareness, most ads are paid per click or per conversion. And every time you click, Google makes anywhere from $0.50 to $6-ish, depending on the competition and budget of the advertiser. If Google was showing that ad on a non-google site, or in front of a YouTube video, then a portion of those earnings would be split between Google and the content owner.
So, why does Google offer unlimited storage for photos? Because they can offset the cost with the amount of profile information they will now know about you, and hopefully will get you to click on an ad somewhere on the Internet that they picked out specifically for you. Google doesn’t share your pictures with others; they’re your pictures, but Google will process them and add them to your profile, which it will use to match you to advertisers.
Because I don’t find targetted advertisements that annoying, and because Google generally makes good products and offers useful services, this is an arrangement that I am happy to agree to.
What does a computer language compiler do?
Credential: Software Engineer Posted: ~2018 (7 years ago) Views: 716 views Source: https://www.quora.com/What-does-a-computer-language-compiler-do/answer/Naomi-Amethyst-1
Answer
A compiler translates a programming language into a actual machine code that the processor can understand.
A compiler usually has four or more components or phases of translation:
The lexer is responsible for turning text into meaningful tokens. This process is often called lexing or scanning. It turns something like:
if (foo + 1 >= 20) {
return;
}
into an array or stream of tokens like:
[
T_IF, T_OPAREN, T_LABEL("foo"), T_PLUS,
T_INTLITERAL(1), T_GTE, T_INTLITERAL(20),
T_CPAREN, T_OBRACE, T_RETURN, T_SEMICOLON,
T_CBRACE
]
The parser is responsible for taking the token stream and converting it into an abstract syntax tree or AST. This process is often called parsing or recognizing. It turns the above into something like:
(IfStatement){
condition: (GreaterThanOrEqualsExpression){
left: (AddExpression){
left: (LabelExpression){
label: "foo"
},
right: (IntegerLiteralExpression){
value: 1
}
},
right: (IntegerLiteralExpression){
value: 20
}
},
body: (Block){
statements: [
(ReturnStatement) {}
]
}
}
The optimizer is responsible for taking the AST and converting it into a more optimized AST. This process is called optimization or optimizing. It turns the above into something like:
(IfStatement){
condition: (GreaterThanOrEqualsExpression){
left: (LabelExpression){
label: "foo"
},
right: (IntegerLiteralExpression){
value: 19
}
},
body: (Block){
statements: [
(ReturnStatement) {}
]
}
}
The code generator is responsible for taking the AST and generating target-specific code. This is usually some form of assembly. This process is called code generation. It turns the above into something like:
ld r1, foo
ldi r2, 0x13
cmp r1, r2
jl ifend
ret
ifend:
Then there is usually a register mapping pass over the assembly, where real registers are allocated to the virtual registers, and virtual registers that cannot be mapped to a real register are replaced with register spills to memory, usually the stack. Labels are allocated space either on the stacks of functions or globally, depending on scope, unless they can be converted to immediate values by the optimizer.
Then the assembler is responsible for translating the assembly into machine code. This is called assembling.
Then the linker is responsible for linking all of the translation units together. This process is called linking.
Finally a valid executable is written out.
In more complex compilers, there may be more stages, especially of optimization, since that can happen at many different layers.
If f(x) is equal to f(y), can we say x=y?
Posted: ~2017 (8 years ago) Views: 1.6K views Source: https://www.quora.com/If-f-x-is-equal-to-f-y-can-we-say-x-y/answer/Naomi-Amethyst-1
Answer
Suppose f(x) \overset{\mathrm{def}}{=} x^2.
Let x = -12 and y = 12.
Therefore, f(x) = f(-12) = (-12)^2 = 144 and f(y) = f(12) = 12^2 = 144.
So, f(x) = f(y) but x \neq y.
What is the difference between Tree and Binary Tree?
Posted: ~2018 (7 years ago) Views: 2.3K views Source: https://www.quora.com/What-is-the-difference-between-Tree-and-Binary-Tree/answer/Naomi-Amethyst-1
Answer
A tree is a data structure where there is a root node, and then each node can have “children” or “leaf” nodes.
A binary tree is a tree where each node has at most two child nodes.
What are the best restaurants near the University of Illinois's campus?
Posted: ~2016 (9 years ago) Views: 169 views Source: https://www.quora.com/What-are-the-best-restaurants-near-the-University-of-Illinoiss-campus/answer/Naomi-Amethyst-1
Answer
Fast/quick:
- Za’s has a location on Green St (and Neil St)
- McAlister’s has a location in the Illini Union (and Neil St)
There’s also a huge number of dine-in restaurants on North Prospect just north of the interstate.
Can you write a code which gets the "n" and prints the below problem's answer in the output. (s=1-2-3+4-5-6-7-8+9-…-(n-1) ^2+n^2) (~the ratios of complete square numbers are + and others are -] substantive)?
Credential: Software Engineer Posted: ~2020 (5 years ago) Views: 418 views Source: https://www.quora.com/Can-you-write-a-code-which-gets-the-n-and-prints-the-below-problems-answer-in-the-output-s-1-2-3-4-5-6-7-8-9-n-1-2-n-2-the-ratios-of-complete-square-numbers-are-and-others-are-substantive/answer/Naomi-Amethyst-1
Answer
In Wolfram Language:
f[n_]:=2Sum[x^2,{x,0,n}]-Sum[x,{x,0,n^2}]
How can a program be made in C that gives you the numbers from 1 to 10?
Credential: Software Engineer Posted: ~2019 (6 years ago) Views: 1.8K views Source: https://www.quora.com/How-can-a-program-be-made-in-C-that-gives-you-the-numbers-from-1-to-10/answer/Naomi-Amethyst-1
Answer
#include <stdio.h>
typedef struct {
int character;
FILE *destination;
} write_character_request_t;
typedef struct {
int status;
int error;
} write_character_response_t;
typedef struct {
int digit;
FILE *destination;
} write_digit_request_t;
typedef struct {
int status;
write_character_response_t encapsulated_error;
} write_digit_response_t;
typedef struct {
int value;
FILE *destination;
} write_int_request_t;
typedef struct {
int status;
write_digit_response_t encapsulated_error;
} write_int_response_t;
typedef struct {
int start;
int end;
int step;
int delimiter;
FILE *destination;
} write_int_range_request_t;
typedef struct {
int status;
write_int_response_t encapsulated_error;
} write_int_range_response_t;
int BASE = 0x0A, NEWLINE = 0x0A, NEGATIVE = 0x2D, SUCCESS = 0x01, ZERO = 0x00;
int CONVERT_DIGIT_TO_CHARACTER_MAP[] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39};
int convert_file_error(FILE *stream) {
return ferror(stream);
}
int convert_digit_to_character(int digit) {
return CONVERT_DIGIT_TO_CHARACTER_MAP[digit];
}
write_character_response_t write_character(write_character_request_t write_character_request) {
write_character_response_t write_character_response;
write_character_response.status = fputc(write_character_request.character,
write_character_request.destination) == write_character_request.character;
if (!write_character_response.status) {
write_character_response.error = convert_file_error(write_character_request.destination);
}
return write_character_response;
}
write_digit_response_t write_digit(write_digit_request_t write_digit_request) {
write_digit_response_t write_digit_response;
write_character_response_t write_character_response;
write_character_request_t write_character_request;
write_character_request.destination = write_digit_request.destination;
write_character_request.character = convert_digit_to_character(write_digit_request.digit);
write_character_response = write_character(write_character_request);
write_digit_response.status = write_character_response.status;
write_digit_response.encapsulated_error = write_character_response;
return write_digit_response;
}
write_int_response_t write_int(write_int_request_t write_int_request) {
write_int_response_t write_int_response;
write_character_request_t write_character_request;
write_character_response_t write_character_response;
write_digit_request_t write_digit_request;
write_int_response.status = SUCCESS;
if (write_int_request.value < ZERO) {
write_character_request.destination = write_int_request.destination;
write_character_request.character = NEGATIVE;
write_character_response = write_character(write_character_request);
if (!write_character_response.status) {
write_int_response.status = write_character_response.status;
return write_int_response;
}
write_int_request.value = -write_int_request.value;
}
write_digit_request.digit = write_int_request.value % BASE;
write_digit_request.destination = write_int_request.destination;
write_int_request.value = write_int_request.value / BASE;
if (write_int_request.value) {
write_int_response = write_int(write_int_request);
if (!write_int_response.status) {
return write_int_response;
}
}
write_int_response.encapsulated_error = write_digit(write_digit_request);
write_int_response.status = write_int_response.status && write_int_response.encapsulated_error.status;
return write_int_response;
}
write_int_range_response_t write_int_range(write_int_range_request_t write_int_range_request) {
write_int_range_response_t write_int_range_response;
write_int_request_t write_int_request;
write_character_request_t write_character_request;
write_character_response_t write_character_response;
write_int_range_response.status = SUCCESS;
write_character_request.destination = write_int_range_request.destination;
write_int_request.destination = write_int_range_request.destination;
write_int_request.value = write_int_range_request.start;
write_int_range_response.encapsulated_error = write_int(write_int_request);
if (!write_int_range_response.encapsulated_error.status) {
write_int_range_response.status = !SUCCESS;
return write_int_range_response;
}
write_character_request.character = write_int_range_request.delimiter;
write_character_response = write_character(write_character_request);
if (!write_character_response.status) {
write_int_range_response.status = write_character_response.status;
return write_int_range_response;
}
write_int_range_request.start += write_int_range_request.step;
if (write_int_range_request.start <= write_int_range_request.end) {
return write_int_range(write_int_range_request);
}
return write_int_range_response;
}
int main() {
write_int_range_request_t write_int_range_request;
write_int_range_request.start = 1;
write_int_range_request.end = 10;
write_int_range_request.step = 1;
write_int_range_request.delimiter = NEWLINE;
write_int_range_request.destination = stdout;
return !write_int_range(write_int_range_request).status;
}
Comments
Wow. You really simplified it.
Hahahahaha :)
I was about to write something like “printf(“1\n2\n3….”) and please do your homework yourself”
You have all my respect for the time taken to write this very nice answer.
printf(“1 2 3 4 5 6 7 8 9 10”);
Is it how code is written at the production level? :D
How long will it take until 100 terabytes of cloud storage will be affordable for everyone?
Credential: Site Reliability Architect (2013–present)8y Posted: ~2017 (8 years ago) Views: 117 views Source: https://www.quora.com/How-long-will-it-take-until-100-terabytes-of-cloud-storage-will-be-affordable-for-everyone/answer/Naomi-Amethyst-1
Answer
For about $50/mo, you can get a Google G Suite Business account with 5 users that gives you unlimited space.
Or for about $75/mo, you can get a DropBox Business account with 3 users that gives you “as much space as you need,” but that means you have to keep asking them to bump up the limit when you are close to running out.
How do I know if an open-source code is safe?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 3.2K views Source: https://www.quora.com/How-do-I-know-if-an-open-source-code-is-safe/answer/Naomi-Amethyst-1
Answer
By reading and analyzing it, paying someone else to read and analyze it, or trusting that someone out there has done so and was satisfied because no complaints about the code have been made.
Comments
You’re making it sound like it might not be worth my time to use open-source code if it isn’t very widespread.
How would one write a Java program to find the number between 100 and 1000 which is prime and a palindrome both by using a user-defined function?
Posted: Updated 7y Views: 222 views Source: https://www.quora.com/How-would-one-write-a-Java-program-to-find-the-number-between-100-and-1000-which-is-prime-and-a-palindrome-both-by-using-a-user-defined-function/answer/Naomi-Amethyst-1
Answer
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Spliterator;
import java.util.function.LongConsumer;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
class Scratch {
private class SieveOfEratosthenes
implements Spliterator.OfLong {
private List<Long> primes = new ArrayList<>();
private long currentPos = 1;
private final long end;
SieveOfEratosthenes(long end) {
this.end = end;
}
@Override
public Spliterator.OfLong trySplit() {
return null;
}
@Override
public long estimateSize() {
return Long.MAX_VALUE;
}
@Override
public int characteristics() {
return ORDERED | DISTINCT | SORTED | NONNULL
| IMMUTABLE;
}
@Override
public Comparator<? super Long> getComparator() {
return null;
}
@Override
public boolean tryAdvance(final LongConsumer action) {
final long nextPrime = nextPrime();
if(nextPrime != -1)
action.accept(nextPrime);
return nextPrime != -1;
}
private long nextPrime() {
for(currentPos++; !isPrime(currentPos); currentPos++)
if(currentPos > end)
return -1;
primes.add(currentPos);
return currentPos;
}
private boolean isPrime(final long candidate) {
return primes.stream()
.noneMatch(x -> candidate % x == 0);
}
}
private List<Long> findNumbers() {
return StreamSupport.longStream(
new SieveOfEratosthenes(1000), false)
.filter(x -> x > 100)
.filter(this::isPalindrome)
.boxed()
.collect(Collectors.toList());
}
private boolean isPalindrome(final long x) {
final String stringValue = String.valueOf(x);
final List<Integer> characters = stringValue.chars()
.boxed()
.collect(Collectors.toList());
Collections.reverse(characters);
return stringValue.chars()
.boxed()
.collect(Collectors.toList())
.equals(characters);
}
public static void main(String[] args) {
System.out.println("Numbers found: "
+ new Scratch().findNumbers());
}
}
Running it yields:
Numbers found: [101, 131, 151, 181, 191, 313, 353, 373, 383,
727, 757, 787, 797, 919, 929]
How do programmers remember so much syntax? Using File I/O to read from a file can be around 10 lines of code for example.
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 318 views Source: https://www.quora.com/How-do-programmers-remember-so-much-syntax-Using-File-I-O-to-read-from-a-file-can-be-around-10-lines-of-code-for-example/answer/Naomi-Amethyst-1
Answer
First off, file I/O is almost always library usage, not syntax. Syntax is the symbols and arrangement of the symbols that you type themselves that the compiler interprets as a valid source file. Libraries define functions that you can call, just like you can define functions to call.
Good programmers understand the basic abstractions that their standard library gives them for doing things. With the exception of a very few in common use (coughPHPcough), most languages have a standard library that is really consistent throughout. And most of the time, file I/O is done just the same as any other kind of I/O: You can write stuff to an output stream, or read stuff from an input stream.
In C, on POSIX systems, you have your fread and fwrite to read and write data to FILE *s (essentially the C version of an input/output stream. In C++, you also have std::istream and std::ostream. In Java, you have java.io.InputStream and java.io.OutputStream. In PHP, it’s fread and fwrite or a whole slew of other methods built on top of that. In Ruby, you’ve got IO with IO#read and IO#write. In Perl, you’ve got line noise.
Now, you specifically wanted File I/O and not I/O in general. Now, files generally need to be opened when you want to access them, and closed when you no longer need them. So, in C, again on POSIX systems, you have fopen to get a FILE * and fclose to close it. In C++, you have the constructors for std::ifstream and std::ofstream to get a std::istream or std::ostream, and the destructor closes the file. In Java, you have the java.io.FileInputStream and java.io.FileOutputStream constructors to get a java.io.InputStream or java.io.OutputStream object, and there is a close method to close them. In PHP, it’s fopen to get a file handle, and fclose to close it. In Ruby, you’ve got File.open to get an IO object, and there is IO#close to close it. In Perl, you again have line noise.
See a pattern here? All of these are very similar, and they follow the same rules for network I/O (just use a socket version to open it in most cases), and console I/O (stdin, stdout, and stderr are already opened for you).
The names of these things follow the naming conventions of the language’s standard library in which they live.
How do you prove that any integer amount of postage from 18 cents and up can be made using only 4-cent and 7-cent stamps assuming an infinite supply of stamps (discrete mathematics)?
Posted: ~2019 (6 years ago) Views: 786 views Source: https://www.quora.com/How-do-you-prove-that-any-integer-amount-of-postage-from-18-cents-and-up-can-be-made-using-only-4-cent-and-7-cent-stamps-assuming-an-infinite-supply-of-stamps-discrete-mathematics/answer/Naomi-Amethyst-1
Answer
$\textbf{Proof (by Induction).}\\text{Let f(n) be a function}\\text{$f:{n \mid n \in \mathbb{Z^+} \land n \ge 18 } \rightarrow {(x, y) \mid x \in \mathbb{Z^+} \land y \in \mathbb{Z^+} }$}\\text{that returns a tuple (x, y) such that 4x + 7y = n. In this case, $x$}\\text{will represent the number of $4$-cent stamps and y will represent the}\\text{number of $7$-cent stamps required.}\\textbf{Base Case}\\text{Let f(18) = (1, 2), f(19) = (3, 1), f(20) = (5, 0), $f(21) = (0, 3)$}\\textbf{Inductive Hypothesis}\\text{f(n - 4) is defined \forall n \ge 22.}\\textbf{Induction}\\text{Because f(n - 4) is defined, and adding an additional $4$-cent stamp to}\\text{f(n - 4) will give us a value for f(n).}\\text{Therefore, we can define $f(n) = (f(n - 4)_1 + 1, f(n - 4)_2)}.
If the average of 4 consecutive even numbers is 65, what is the largest number?
Posted: ~2017 (8 years ago) Views: 765 views Source: https://www.quora.com/If-the-average-of-4-consecutive-even-numbers-is-65-what-is-the-largest-number/answer/Naomi-Amethyst-1
Answer
So, we have 4 consecutive even numbers. Let’s call them 2(k-3), 2(k-2), 2(k-1), 2k for k \in \mathbb{Z}^+ \land k > 3.
We can sum them up and divide by 4 to get the average:
\frac{2(k-3) + 2(k-2) + 2(k-1) + 2k}{4} = 65
Simplifying a bit, we get:
\frac{2k - 6 + 2k - 4 + 2k - 2 + 2k}{4} = 65
\frac{8k - 12}{4} = 65
2k - 3 = 65
2k = 68
And since 2k is the largest number as we picked above, 68 is the value for that.
What are all the prime numbers in the world?
Posted: ~2017 (8 years ago) Views: 125 views Source: https://www.quora.com/What-are-all-the-prime-numbers-in-the-world/answer/Naomi-Amethyst-1
Answer
\mathbb{P} = \{ x \mid x \in \mathbb{N}^+ \land x > 1 \land \nexists_y \in \mathbb{N}^+ \text{ s.t. } y \neq 1 \land y \neq x \land y \vert x \}
The set of \mathbb{P} is your primes.
How would the Boolean expression, A(\overline{B})(\overline{C})+\overline{A}BD+(\overline{B})(\overline{D})+\overline{A}C+A\overline{D}+BC, be simplified?
Posted: ~2017 (8 years ago) Views: 406 views Source: https://www.quora.com/How-would-the-Boolean-expression-A-overline-B-overline-C-+-overline-A-BD+-overline-B-overline-D-+-overline-A-C+A-overline-D-+BC-be-simplified/answer/Naomi-Amethyst-1
Answer
AB
00 | 01 | 11 | 10
+----+----+----+----+
00 | 1 | 0 | 1 | 1
CD 01 | 0 | 1 | 0 | 0
11 | 1 | 1 | 1 | 0
10 | 1 | 1 | 1 | 1
So, for Sum of Products, we have \overline{A}C + A\overline{D} + BC + \overline{A}BD + \overline{ABC}
And for Product of Sums, we have (\overline{A} + C + \overline{D})(B + C + \overline{D})(\overline{A} + B + \overline{D})(A + \overline{B} + C + D)
The HCF and LCM of two numbers are 6 and 336 respectively. What are the two numbers if the difference between them is 6?
Posted: Updated 8y Views: 2.3K views Source: https://www.quora.com/The-HCF-and-LCM-of-two-numbers-are-6-and-336-respectively-What-are-the-two-numbers-if-the-difference-between-them-is-6/answer/Naomi-Amethyst-1
Answer
Let’s break this down a bit.
HCF(a, b) = 6. That means that:
6 divides a and 6 divides b and that 6 is the highest number for which this is true.
LCM(a, b) = 336. That means that:
a divides 336 and b divides 336 and 336 is the lowest number for which this is true.
Now, what does it mean that x divides y? It means that the set of prime factors of x is a subset of the set of prime factors of y. So let’s get the prime factors of all of the numbers involved here:
336 = 2 \times 2 \times 2 \times 2 \times 3 \times 7
6 = 2 \times 3
Now, we have two numbers a and b that are not the same, but must together use all of the prime factors of 336 and no more, and must both contain the prime factors of 6, but have no more factors in common.
So, let’s start off with a = 2 \times 3 \times \ldots. Now we have two options: Either we can tack on more $2$s to the end, or we can tack on a 7. Note that if we tack on one 2, we have to tack on all the $2$s because otherwise b would have to take those $2$s and that would make the common factors larger, and the HCF higher than 6.
So, let’s set a = 2 \times 2 \times 2 \times 2 \times 3 and b = 2 \times 3 \times 7. If you look, they only have 2 \times 3 in common, so HCF(a, b) = 2 \times 3 = 6 and together they cover 2 \times 2 \times 2 \times 2 \times 3 \times 7, so LCM(a, b) = 2 \times 2 \times 2 \times 2 \times 3 \times 7 = 336.
So what are these numbers? a = 2 \times 2 \times 2 \times 2 \times 3 = 48 and b = 2 \times 3 \times 7 = 42.
Now we check, is the difference between the two 6? 48 - 42 = 6. Yes.
So, the numbers are 42 and 48.
Where can I learn to access computers on the same network? How can I learn the basics?
Credential: Software Engineer8y Posted: ~2017 (8 years ago) Views: 155 views Source: https://www.quora.com/Where-can-I-learn-to-access-computers-on-the-same-network-How-can-I-learn-the-basics/answer/Naomi-Amethyst-1
Answer
It’s usually done via the socket implementation in your language of choice.
In C, that’s the (int) socket(int, int, int) system call to create the socket, the (int) bind(int, struct sockaddr *, socklen_t) system call to bind the socket to a given address, and the (int) connect(int, struct sockaddr *, socklen_t) system call to connect the socket to a remote host. You could instead use the (int) listen(int, int) and (int) accept(int, struct sockaddr *, socklen_t *) to wait for remote hosts to connect to you.
Once you have an open socket, you can use the (ssize_t) read(int, void *, size_t) system call to read data the other side has sent and the (ssize_t) write(int, void *, size_t) system call to send data to the other side.
You can also use recv, recvfrom, and recvmsg variants to get more detailed information about the data received, and the send, sendto, and sendmsg variants to send with specific options.
Finally, when you are done with a socket, you should close it with (int) close(int) or (int) shutdown(int, int).
Now, what things are valid to write, and what you expect read, and what connection options to use are only restricted by conventions that we call protocols. Protocols are documented standards for how two computers can communicate over a socket. For example, websites use HTTP, which is the hypertext transfer protocol. HTTP is documented as RFC 7230 through RFC 7235 [1][2][3][4][5]. And there are many, many more protocols out there, or you can use your own to talk between your own programs.
—
[1] Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing
[2] Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content
[3] Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests
[4] Hypertext Transfer Protocol (HTTP/1.1): Range Requests
[5] Hypertext Transfer Protocol (HTTP/1.1): Caching
[6] Hypertext Transfer Protocol (HTTP/1.1): Authentication
I am creating a self response program in C language but to select the answer to the asked question using switch it is not accepting a string as its variable what can I do?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 78 views Source: https://www.quora.com/I-am-creating-a-self-response-program-in-C-language-but-to-select-the-answer-to-the-asked-question-using-switch-it-is-not-accepting-a-string-as-its-variable-what-can-I-do/answer/Naomi-Amethyst-1
Answer
C uses a switch block to build a jump table, generally. It doesn’t support strings.
That being said, you can build a data structure of some kind — say a map from the string to function pointers, or something like that. Or you could lex all of the valid strings into integer tokens and then switch on the tokens.
Or if it is just a few examples, you could just use the dreaded if(!strncmp(…)) { … } else if (!strncmp(…)){ … } else if …
Many protocol parsers either use a trie, hash map, or some form of balanced tree; and the more complex ones use flex/bison.
Comments
The using integers i can try but i want to sometging like keeping all the text and number in one file and accsess it in run time like
String 1
String 2
'string' 'integer'
Something like this in text file and the program will use the text file to find the string to the corresponding integer. How can i do it
Now what can i do if i want to add such content(integers and strins and additional case) after compiling.
How do I write a complete program to evaluate the expression y = x^2+2x+1 assuming x and y are two 8-bit variables stored in memory at $1000 and $1001, respectively, and when x is 5, -14, and 11 in assembly language?
Credential: Software Engineer Posted: ~2019 (6 years ago) Views: 364 views Source: https://www.quora.com/How-do-I-write-a-complete-program-to-evaluate-the-expression-y-x-2-2x-1-assuming-x-and-y-are-two-8-bit-variables-stored-in-memory-at-1000-and-1001-respectively-and-when-x-is-5-14-and-11-in-assembly-language/answer/Naomi-Amethyst-1
Answer
main:
mov BYTE PTR ds:4096, 5
movzx eax, BYTE PTR ds:4096
movzx ecx, BYTE PTR ds:4096
movzx edx, BYTE PTR ds:4096
imul eax, ecx
lea edx, [rax+1+rdx*2]
mov BYTE PTR ds:4097, dl
mov BYTE PTR ds:4096, -14
movzx eax, BYTE PTR ds:4096
movzx ecx, BYTE PTR ds:4096
movzx edx, BYTE PTR ds:4096
imul eax, ecx
lea edx, [rax+1+rdx*2]
mov BYTE PTR ds:4097, dl
mov BYTE PTR ds:4096, 11
movzx eax, BYTE PTR ds:4096
movzx ecx, BYTE PTR ds:4096
movzx edx, BYTE PTR ds:4096
imul eax, ecx
lea edx, [rax+1+rdx*2]
mov BYTE PTR ds:4097, dl
xor eax, eax
ret
What are the characteristics of even numbers?
Posted: Updated 5y Views: 2.7K views Source: https://www.quora.com/What-are-the-characteristics-of-even-numbers/answer/Naomi-Amethyst-1
Answer
Even numbers are integers (\mathbb{Z}) whose prime factors include at least one 2.
The set of all even numbers is \{ 2 \} \times \mathbb{Z} or \{ 2x | x \in \mathbb{Z} \}.
The generalized form of an even number is 2k, for k \in \mathbb{Z}.
An odd number is an integer that is not even.
The generalized form of an odd number is 2k + 1, for k \in \mathbb{Z}.
When you add an even number to an even number, you get 2k + 2l = 2(k + l) which is an even number. When you add an even number to an odd number, you get 2k + 2l + 1 = 2(k + l) + 1 which is an odd number. When you add two odd numbers, you get 2k + 1 + 2l + 1 = 2k + 2l + 2 = 2(k + l + 1) which is an even number.
If you count up or down repeatedly (adding or subtracting 1 each time), you will alternate between even and odd numbers.
In any base system that has an even base, as all bases that are in common use today (decimal, binary, hexadecimal, octal, base 64), an even or odd number can be determined by examining whether the least significant digit is even or odd.
What is the lowest whole possible number?
Posted: ~2017 (8 years ago) Views: 1.1K views Source: https://www.quora.com/What-is-the-lowest-whole-possible-number/answer/Naomi-Amethyst-1
Answer
Most people define whole numbers to be equal to \mathbb{Z} - \mathbb{Z}^-
Or another way of stating that is: \{0\} \cup \mathbb{N}
Given that 0 is categorically less than all natural numbers (\mathbb{N}, or: \forall_{x \in \mathbb{N}} 0 < x), we can say that 0 is the lowest whole number possible.
Now, if you define whole numbers to be equal to \mathbb{N}, then the answer is 1, though these are often called Natural Numbers instead.
One other interpretation of whole numbers makes them equal to \mathbb{Z}, but most people will just call these Integers. In this case, there is no lowest possible since both ends of \mathbb{Z} are unbounded.
What is 9+9+9+9+9+9+9+9+9+9+6+9+9+9+9×0+9?
Credential: Site Reliability Architect (2013–present)8y Posted: ~2017 (8 years ago) Views: 42 views Source: https://www.quora.com/What-is-9+9+9+9+9+9+9+9+9+9+6+9+9+9+9%C3%970+9/answer/Naomi-Amethyst-1
Answer
irb(main):001:0> 9+9+9+9+9+9+9+9+9+9+6+9+9+9+9*0+9
=> 132
Can a variable store anything other than a value, like a method?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 363 views Source: https://www.quora.com/Can-a-variable-store-anything-other-than-a-value-like-a-method/answer/Naomi-Amethyst-1
Answer
Depends on the language.
In C and C++, variables can be pointers. Pointers are a memory location stored in a variable, and they can point to other variables, or to functions:
int a = 5;
int *b = &a; // b now points to the memory address of a.
int add(int x, int y) {
return x + y;
}
int (*c)(int, int) = &add; // c now points to the memory address of add.
printf("%d\n", (*c)(5, 5)); // prints 10
In Java, you have reflection, Callable<T>, and Runnable:
Runnable a = new Runnable() {
@Override
public void run() {
System.out.println(5);
}
};
a.run(); // prints 5
Callable<Integer> b = () -> 5;
b.call(); // returns 5
Function<Integer, Integer> c = x -> 2 * x;
c.apply(5); // returns 10
Method d = System.out.getClass().getMethod("println", String.class);
d.invoke(System.out, "!noitcelfeR ,olleH"); // prints !noitcelfeR ,olleH
In Javascript, functions are values:
var myLog = console.log;
myLog("Hello, World!"); // prints Hello, World!
In Ruby, you have reflection, procs, and lambdas:
def add(x, y)
x + y
end
a = :add
puts send(a, 5, 5) # prints 10
b = proc do |x|
2 * x
end
puts b[5] # prints 10
c = ->(x) { 2 * x }
puts c[5] # prints 10
In Bash, you have all kinds of fun:
function foo() { echo $1; }
a=foo
$a "Hello, World!" # prints Hello, World!
How do I learn C language? Never contact before, where to start learning? It is very hard? This language really can control the computer do things?
Credential: Software Engineer8y Posted: ~2017 (8 years ago) Views: 107 views Source: https://www.quora.com/How-do-I-learn-C-language-Never-contact-before-where-to-start-learning-It-is-very-hard-This-language-really-can-control-the-computer-do-things/answer/Naomi-Amethyst-1
Answer
K&R (rest in peace) is widely regarded as the authority on the C language:
Why can't we use the hexadecimal number system for fiber optic data transfer instead of binary? Would this be faster but too expensive? Slower?
Posted: ~2017 (8 years ago) Views: 912 views Source: https://www.quora.com/Why-cant-we-use-the-hexadecimal-number-system-for-fiber-optic-data-transfer-instead-of-binary-Would-this-be-faster-but-too-expensive-Slower/answer/Naomi-Amethyst-1
Answer
Keep in mind that we do this already, just at a higher layer. It is not uncommon to have bonded fiber. It is also not uncommon to have multipath BGP on the open Internet.
Bonded links (Link Aggregation, 802.3ad, Link aggregation - Wikipedia) is an ethernet-layer configuration for running multiple links between two devices where individual frames can be transmitted over multiple different physical links. There are many ways that a link can be selected for a given frame — the simplest being round-robin, where after you transmit a frame on one link, you go to the next link, until all links have transmitted a frame, and then you start over at the first link. However, in many use-cases, people prefer to bind a particular (src, dest) MAC pair to a given link so that frames won’t get re-ordered on the other side, if they get received slightly out of order.
Multipath BGP is where IP packets are routed via multiple different next hops. Again, a simple way to do this is round-robin, but in many cases people prefer to bind a particular next hop to a (src, dest) IP pair, for similar reasons as above.
Both of these solutions provide better fault tolerance and jitter tolerance than attempting to bond links at the symbol layer. It also allows for much more robust error correction.
For example, let’s say we have 32 fiber optic cables, with transceivers on each end, each capable of transceiving at ten gigabits per second. Not particularly fast, but a moderate transceiver. Now, simple math would say that we should be able to sum the speeds of the links to get 320 Gbps. Now let’s say that one of the 32 links has an issue and the transceivers for that link decide to renegotiate to 1 Gbps in order to more reliably decipher what the other is sending over a noisy/broken link. If you are using link aggregations or multipathing BGP, you now have 311 Gbps of usable speed, because the other links will continue tranceiving at 10 Gbps, and the degraded one will be transceiving at 1 Gbps. However, if you are bonding these at the per symbol layer, and attempting to transmit DWORDs across the 32 links, now all of the rest have to slow down as well to the speed of the slowest link, so now they all downgrade to 1 Gbps, for a total of 32 Gbps vs 311 Gbps in this degraded state.
There are other issues as well, but in general, treating individual links as separate, at least for the framing layer, and perhaps even up to the IP layer, allows for many more failure cases to be tolerated.
1 megabyte is 1,000,000 bytes, why do people assume that it is 1,048,576 bytes?
Posted: ~2017 (8 years ago) Views: 2K views Source: https://www.quora.com/1-megabyte-is-1-000-000-bytes-why-do-people-assume-that-it-is-1-048-576-bytes/answer/Naomi-Amethyst-1
Answer
If you look at where terms like megabyte originated, it has always been 1024^2 bytes. This is because, while your normal SI prefixes normally count in powers of 1,000 (1000^1 = kilo, 1000^2 = mega, 1000^3 = giga, 1000^4 = tera, and so on), numbers in computers typically are in binary, and so they count by 10000000000_2 = 1024_{10}. When you square that, you get 10000000000_2^{10_2} = 1024_{10}^{2_{10}} = 100000000000000000000_2 = 1048576_{10}.
Now, more recently hard drive manufacturers decided that they could sell less storage for more, and do it legally by saying that they consider a kilobyte to be 1,000 bytes like the SI prefix, so they sell you 24 bytes less for every kilobyte, and 24 kilobytes less for every megabyte, and 24 megabytes less for every gigabyte, and 24 gigabytes less for every terabyte. And this caused confusion. So someone came up with the idea that to solve this, we just rename the original definition of kilobytes to kibibytes, which looks and sounds weird, but that was what was chosen. Then continue by replacing the last to characters of SI prefixes with “bi” to indicate this power-of-2 counting, and we get “kibi-”, “mebi-”, “gibi-”, “tebi-”, and so on.
Standards organizations liked this because standardization is better than confusion, and so now we have standards for “megabyte” and “mebibyte” and by standards, they are different. But in practice, because it was so common for a megabyte to be 1048576 bytes, and because us geeks really hate that this all got ruined by marketing people who don’t really understand it, no one has really changed.
Comments
So technically a Gigabyte IS 1,048,576 bytes?
“we dont” because i will never follow such stupidity :P
How many times does the digit 5 in all integers between 0 and 60?
Posted: ~2017 (8 years ago) Views: 34 views Source: https://www.quora.com/How-many-times-does-the-digit-5-in-all-integers-between-0-and-60/answer/Naomi-Amethyst-1
Answer
16 times:
> (0..60).reduce(0) { |m, e| m += e.to_s.count("5") }
=> 16
You are at a job interview for an IT position. You answer all of the technical questions extremely well and you feel like you nailed the interview. All of a sudden the interviewer is asking questions about politics and religion. What do you do now?
Credential: Software Engineer Posted: ~2018 (7 years ago) Views: 240 views Source: https://www.quora.com/You-are-at-a-job-interview-for-an-IT-position-You-answer-all-of-the-technical-questions-extremely-well-and-you-feel-like-you-nailed-the-interview-All-of-a-sudden-the-interviewer-is-asking-questions-about-politics/answer/Naomi-Amethyst-1
Answer
“I don’t think that my political or religious beliefs, or lack thereof, are relevant to this job.”
That’s a major faux pas for an interviewer, at least in the US, and I would hope that that response would trigger an immediate back off and apology. You could probably be a little more forceful and mention that religion is a protected class in anti-discrimination law, but that’s a bit less tactful.
Honestly, that’s the kind of thing though that would cause me to look elsewhere, though. Do you really want to work for someone who is going to bring up politics and religion in an interview?
How do strings work at the compiler level?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 688 views Source: https://www.quora.com/How-do-strings-work-at-the-compiler-level/answer/Naomi-Amethyst-1
Answer
In C, and most other C-like languages, strings are byte arrays that are terminated with a NUL character (a byte with value 0).
String literals, what you get when you type "hello world", are recognized by the lexer in the compiler, and passed through the parser into the abstract syntax tree, which is a data-structure that represents the translation unit in a way that can be reasoned about by the compiler.
The compiler then performs analysis of the abstract syntax tree and optimizes it. Once optimization has happened, the compiler may generate an intermediate representation, followed by some more rounds of optimizing.
Once the compiler is ready to generate assembly, string literals are located in the .rodata section as byte sequences followed by NUL characters, and the references to the string literals is replaced with a reference to the location in .rodata.
The assembler will translate the assembly into machine code, which will involve copying the strings in the .rodata section into a contiguous block in the file and translating references to it to offsets into the file, which will ultimately be offsets into virtual memory when the object is loaded by the dynamic linker’s interpreter, executed directly, or any other method of loading into an executing process.
With gcc, you can have it stop before assembling the assembly with the -S option, or you can use other options to have it emit the intermediate representation. You can also use tools like objdump or readelf on an assembled file to get the parsed sections of the file and look for your strings in the .rodata section. Another tool is strings which will look for sequential runs of printable characters in a file. Finally, you can use a hex editor or dumper like xxd to simply view the binary contents of an assembled object file and look for the strings in that manner.
What is a regular expression that can match anything, except if it contains a certain string?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 3.8K views Source: https://www.quora.com/What-is-a-regular-expression-that-can-match-anything-except-if-it-contains-a-certain-string/answer/Naomi-Amethyst-1
Answer
To do this correctly, you need zero-width negative look-ahead assertions. This is not something that the theoretical model of regular expressions supports, but is something that many modern PCRE engines do. /^(?!.*some string).*$/ will match any string that does not contain “some string”.
However, it is not a true regular expression, just a PCRE.
The way Big sigma (summation) symbol can be used to represent an addition of n integers, what notation is used to represent logical ORing of n Boolean variables?
Posted: ~2017 (8 years ago) Views: 32 views Source: https://www.quora.com/The-way-Big-sigma-summation-symbol-can-be-used-to-represent-an-addition-of-n-integers-what-notation-is-used-to-represent-logical-ORing-of-n-Boolean-variables/answer/Naomi-Amethyst-1
Answer
In Ruby, it’s .any? on the end of an array (really, on the end of any enumerable):
irb(main):002:0> [true, false, false, true].any?
=> true
irb(main):003:0> [true, false, false, false].any?
=> true
irb(main):004:0> [false, false, false, false].any?
=> false
In more math-y notation, you might see it as:
|\sigma_\text{true}(S)| > 0
\exists_{\alpha \in S} \text{ s.t. } \alpha = \text{true}
|\{ x | x \in S \land x = \text{true} \}| > 0
\displaystyle \huge\mathop{\lor}\limits_x^S x
What is pipelining? How is it implemented in 8086?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 6.5K views Source: https://www.quora.com/What-is-pipelining-How-is-it-implemented-in-8086/answer/Naomi-Amethyst-1
Answer
I don’t have the specifics of the Intel 8086 processor in front of me, but pipelining is where the various parts of the processor are split up into separate units so that they can all be busy at the same time.
You can think of this the way that you would do laundry if you had many loads to do. You could put one load into the washing machine, wait for it to finish, then put it in the dryer, wait for it to finish, fold it, put it away, and then put the next load in the washing machine, and repeat. This wastes time because only one machine is busy at any given time.
What you would more likely do is put the first load in the washing machine, wait for it to finish, then put it in the dryer, and at the same time, put the next load into the washing machine, then start folding and putting away the load you took out of the dryer. When the dryer is finished with the next load, move the load in the washing machine to the dryer, put a new load in the washing machine, and start folding the load that just came out of the dryer and repeat. This is the idea behind pipelining.
In the processor, there are usually several different steps involved in executing and retiring an instruction. Such steps could include:
- Fetching the instruction from memory/cache
- Decoding the instruction (figuring out which control lines to use for the instruction)
- Load Registers
- ALU stages
- Store Registers
This is very simplified, because most modern processors have 20+-stage pipelines, but in my theoretical 5-stage pipeline above, executing 10 instructions looks something like this:
-
Cycle 1:
-
Fetch: The first instruction would be fetched.
-
Decode: NOP
-
Load: NOP
-
ALU: NOP
-
Store: NOP
-
Cycle 2:
-
Fetch: The second instruction would be fetched.
-
Decode: The first instruction would be decoded.
-
Load: NOP
-
ALU: NOP
-
Store: NOP
-
Cycle 3:
-
Fetch: The third instruction would be fetched.
-
Decode: The second instruction would be decoded.
-
Load: The first instruction would load from any registers needed.
-
ALU: NOP
-
Store: NOP
-
Cycle 4:
-
Fetch: The fourth instruction would be fetched.
-
Decode: The third instruction would be decoded.
-
Load: The second instruction would load from any registers needed.
-
ALU: The first instruction would be computed by the ALU.
-
Store: NOP
-
Cycle 5:
-
Fetch: The fifth instruction would be fetched.
-
Decode: The fourth instruction would be decoded.
-
Load: The third instruction would load from any registers needed.
-
ALU: The second instruction would be computed by the ALU.
-
Store: The first instruction would commit its results to the registers.
-
Cycle 6:
-
Fetch: The sixth instruction would be fetched.
-
Decode: The fifth instruction would be decoded.
-
Load: The fourth instruction would load from any registers needed.
-
ALU: The third instruction would be computed by the ALU.
-
Store: The second instruction would commit its results to the registers.
-
Cycle 7:
-
Fetch: The seventh instruction would be fetched.
-
Decode: The sixth instruction would be decoded.
-
Load: The fifth instruction would load from any registers needed.
-
ALU: The fourth instruction would be computed by the ALU.
-
Store: The third instruction would commit its results to the registers.
-
Cycle 8:
-
Fetch: The eighth instruction would be fetched.
-
Decode: The seventh instruction would be decoded.
-
Load: The sixth instruction would load from any registers needed.
-
ALU: The fifth instruction would be computed by the ALU.
-
Store: The fourth instruction would commit its results to the registers.
-
Cycle 9:
-
Fetch: The ninth instruction would be fetched.
-
Decode: The eighth instruction would be decoded.
-
Load: The seventh instruction would load from any registers needed.
-
ALU: The sixth instruction would be computed by the ALU.
-
Store: The fifth instruction would commit its results to the registers.
-
Cycle 10:
-
Fetch: The tenth instruction would be fetched.
-
Decode: The ninth instruction would be decoded.
-
Load: The eighth instruction would load from any registers needed.
-
ALU: The seventh instruction would be computed by the ALU.
-
Store: The sixth instruction would commit its results to the registers.
-
Cycle 11:
-
Fetch: NOP
-
Decode: The tenth instruction would be decoded.
-
Load: The ninth instruction would load from any registers needed.
-
ALU: The eighth instruction would be computed by the ALU.
-
Store: The seventh instruction would commit its results to the registers.
-
Cycle 12:
-
Fetch: NOP
-
Decode: NOP
-
Load: The tenth instruction would load from any registers needed.
-
ALU: The ninth instruction would be computed by the ALU.
-
Store: The eighth instruction would commit its results to the registers.
-
Cycle 13:
-
Fetch: NOP
-
Decode: NOP
-
Load: NOP
-
ALU: The tenth instruction would be computed by the ALU.
-
Store: The ninth instruction would commit its results to the registers.
-
Cycle 14:
-
Fetch: NOP
-
Decode: NOP
-
Load: NOP
-
ALU: NOP
-
Store: The tenth instruction would commit its results to the registers.
-
Cycle 15:
-
Fetch: NOP
-
Decode: NOP
-
Load: NOP
-
ALU: NOP
-
Store: NOP
Because the cycle time only needs to be the time required for the longest of these stages, it means we can clock the CPU faster, without sacrificing much overhead.
Now, there are problems with pipelining, because there are cases where the previous instruction hasn’t yet stored to the register that the very next instruction reads from. Generally in cases like this, the processor can use forwarding circuits to fix this, or forces the pipeline to stall by inserting NOPs into the pipeline. More intelligent processors can even reorder some instructions to fill the pipeline in such a way that stalling is not necessary.
How do I add numbers 1-99 in assembly language using a loop?
Credential: Software Engineer Posted: Updated 7y Views: 1.3K views Source: https://www.quora.com/How-do-I-add-numbers-1-99-in-assembly-language-using-a-loop/answer/Naomi-Amethyst-1
Answer
.section .rodata.str1.1,"aMS",@progbits,1
.LC2:
.string "%d\n"
.section .text.startup,"ax",@progbits
.p2align 4,,15
.globl main
.type main, @function
main:
.LFB0:
# Set xmm0 = 4, 4, 4, 4
vmovdqa .LC1(%rip), %xmm0
# Set eax = 0
xorl %eax, %eax
# Set xmm4 = 0, 0, 0, 0
vpxor %xmm4, %xmm4, %xmm4
# Set xmm5 = 0, 1, 2, 3
vmovdqa .LC0(%rip), %xmm5
jmp .L3
.p2align 4,,10
.p2align 3
.L14:
# Here we unroll the loop 8 times, adding
# with 4 different distributed counters,
# so we can use AVX instructions to add 4
# numbers at the same time.
# Roll 1:
# xmm7 = [4, 4, 4, 4] + xmm2
# xmm8 = xmm2 + xmm1
vpaddd %xmm0, %xmm2, %xmm7
vpaddd %xmm2, %xmm1, %xmm8
# Increment eax (our iterator) by 8.
addl $8, %eax
# Roll 2:
# xmm9 = [4, 4, 4, 4] + xmm7
# xmm10 = xmm7 + xmm8
vpaddd %xmm0, %xmm7, %xmm9
vpaddd %xmm7, %xmm8, %xmm10
# Roll 3:
# xmm11 = [4, 4, 4, 4] + xmm9
# xmm12 = xmm9 + xmm10
vpaddd %xmm0, %xmm9, %xmm11
vpaddd %xmm9, %xmm10, %xmm12
# Roll 4:
# xmm13 = [4, 4, 4, 4] + xmm11
# xmm14 = xmm11 + xmm12
vpaddd %xmm0, %xmm11, %xmm13
vpaddd %xmm11, %xmm12, %xmm14
# Roll 5:
# xmm15 = [4, 4, 4, 4] + xmm13
# xmm2 = xmm13 + xmm14
vpaddd %xmm0, %xmm13, %xmm15
vpaddd %xmm13, %xmm14, %xmm2
# Roll 6:
# xmm1 = [4, 4, 4, 4] + xmm15
# xmm3 = xmm15 + xmm2
vpaddd %xmm0, %xmm15, %xmm1
vpaddd %xmm15, %xmm2, %xmm3
# Roll 7:
# xmm5 = [4, 4, 4, 4] + xmm1
# xmm4 = xmm1 + xmm3
vpaddd %xmm1, %xmm3, %xmm4
vpaddd %xmm0, %xmm1, %xmm5
.L3:
# Roll 8:
# xmm2 = [4, 4, 4, 4] + xmm5
# xmm1 = xmm5 + xmm4
vpaddd %xmm0, %xmm5, %xmm2
# Compare eax to 24 (99 / 4)
cmpl $24, %eax
vpaddd %xmm5, %xmm4, %xmm1
# Loop while eax is not equal to 24.
jne .L14
# Add together the ints in xmm1 and eventually store in esi:
# xmm3 = xmm1 >> 64
vpsrldq $8, %xmm1, %xmm3
# Set up stack frame for call to printf
subq $8, %rsp
# Set up printf format string.
movl $.LC2, %edi
# xmm4 = xmm1 + xmm3
vpaddd %xmm1, %xmm3, %xmm4
# Clear eax
xorl %eax, %eax
# xmm5 = xmm4 >> 32
vpsrldq $4, %xmm4, %xmm5
# xmm6 = xmm4 + xmm5
vpaddd %xmm4, %xmm5, %xmm6
# esi = xmm6
vmovd %xmm6, %esi
# Print out the result.
call printf
# Clear eax
xorl %eax, %eax
# Tear down stack frame after call to printf
addq $8, %rsp
# Return.
ret
.LFE0:
.size main, .-main
.section .rodata.cst16,"aM",@progbits,16
.align 16
.LC0:
.long 0
.long 1
.long 2
.long 3
.align 16
.LC1:
.long 4
.long 4
.long 4
.long 4
Link with libc using the GNU assembler and linker.
Run on a system with support for AVX.
Comments
Is this compiler output? Because it’s way more complicated / less readable than it needs to be, and there’s no way it’s what the person asking the question was actually looking for. The loop itself only needs to be 4 lines… and that includes the branch and label!
How do I understand this code?
Credential: Software Engineer Posted: ~2013 (12 years ago) Views: 1.1K views Source: https://www.quora.com/How-do-I-understand-this-code-1/answer/Naomi-Amethyst-1
Answer
So float f = i; is converting the int into a float. That is pretty easy to understand, I think.
float f2 = (float)&i; This one's more complicated. Let's break it down:
- &i -- Get a pointer to i (memory location). This has type int*.
- (float*) -- Cast the int* to a float*. This is the casting between two memory locations, so no conversion takes place.
-
- -- Dereference the float* pointer. This takes the memory location of i, and treats the bits there, without conversion, as a float.
Floats have a very different memory layout than ints. Assuming little endian, the memory layout of the int looks something like: 0x25000000.
Treating this as a float, we get: sign: (0x25000000 & 0x00000001) >> 0 = 0x0 exp: (0x25000000 & 0x000001FE) >> 1 = 0x0 mantissa: (0x25000000 & 0xFFFFFE00) >> 9 = 0x128000
Which ends up getting interpreted as a really small value (Single-precision floating-point format) -- Something on the order of 2^-126.
Comments
It's important to note that Naomi includes that the architecture is little endian. Big endian will give a different answer. However, if sizeof(int) < sizeof(float), printing f2 could give a random value.
How many times will you write the numeral 2 if you write all the numbers from 201 to 300?
Posted: ~2017 (8 years ago) Views: 518 views Source: https://www.quora.com/How-many-times-will-you-write-the-numeral-2-if-you-write-all-the-numbers-from-201-to-300/answer/Naomi-Amethyst-1
Answer
irb(main):001:0> (201..300).map(&:to_s).map { |x| x.count("2") }.reduce(:+)
=> 119
How do I find my husbands other numbers that he added?
Posted: ~2017 (8 years ago) Views: 164 views Source: https://www.quora.com/How-do-I-find-my-husbands-other-numbers-that-he-added/answer/Naomi-Amethyst-1
Answer
By subtracting the known, pre-existing number from the sum, you get the sum of the numbers that were added.
For example, if the number before any new numbers were added was 10, and the number is now 24, then a simple subtraction gives us:
24 - 10 = 14
So, 14 was the number added in this example.
How would you describe the different variations of the Rubik's cube?
Posted: ~2017 (8 years ago) Views: 159 views Source: https://www.quora.com/How-would-you-describe-the-different-variations-of-the-Rubiks-cube/answer/Naomi-Amethyst-1
Answer
If you are talking about the 2-cube, 3-cube, 4-cube, 5-cube, and the other cubes and non-cubes, those are variations.
If you are talking about the particular pattern or arrangement of a given cube, that is a specific permutation or state. You could also call it an arrangement, pattern, or perhaps even a configuration, although configuration could be misinterpreted to mean a variation.
A turn or a rotation would change from one permutation to another permutation. A sequence of turns is a path. A path leading to a target state is a solution. The length of a path is the number of turns in the path. The better the solution, the smaller the length of the path. The best solution is the shortest path to the target state.
If the quotient is 37, the divisor is 35, and the remainder 29, what is the dividend?
Credential: Site Reliability Architect (2013–present)6y Posted: ~2019 (6 years ago) Views: 60 views Source: https://www.quora.com/If-the-quotient-is-37-the-divisor-is-35-and-the-remainder-29-what-is-the-dividend/answer/Naomi-Amethyst-1
Answer
\begin{align}\frac{x}{35} &= 37 + \frac{29}{35}\\x &= 35 \times 37 + 29\\x &=1295 + 29\\x &= 1324\end{align}
The ABC LTD network was assigned the Class C network 199.166.131.0 from the ISP. If the administrator at ABC LTD were to subnet this class C network using the 255.255.255.224 subnet mask, how may hosts will they be able to support on each subnet?
Credential: Software Engineer Posted: ~2020 (5 years ago) Views: 1.1K views Source: https://www.quora.com/The-ABC-LTD-network-was-assigned-the-Class-C-network-199-166-131-0-from-the-ISP-If-the-administrator-at-ABC-LTD-were-to-subnet-this-class-C-network-using-the-255-255-255-224-subnet-mask-how-may-hosts-will-they-be/answer/Naomi-Amethyst-1
Answer
ARIN, who would have assigned 199.166.131.0, does not use classful routing or assignments. So, 0.
How do you simplify (1-i)(1-2i)(1-3i)(1-4i)(1-5i)(1-6i)?
Posted: ~2017 (8 years ago) Views: 251 views Source: https://www.quora.com/How-do-you-simplify-1-i-1-2i-1-3i-1-4i-1-5i-1-6i/answer/Naomi-Amethyst-1
Answer
\begin{equation}\begin{split}(1 - i)(1 - 2i)&(1 - 3i)(1 - 4i)(1 - 5i)(1 - 6i)\\ & = \underbrace{(1 - 2i - i + 2i^2)}_{(1 - i)(1 - 2i)}\underbrace{(1 - 3i - 4i + 12i^2)}_{(1 - 3i)(1 - 4i)}\underbrace{(1 - 5i - 6i + 30i^2)}_{(1 - 5i)(1 - 6i)}\\ & = (1 - \underbrace{3i}_{- i - 2i} - \underbrace{2}_{2i^2})(1 - \underbrace{7i}_{- 3i - 4i} - \underbrace{12}_{12i^2})(1 - \underbrace{11i}_{- 5i - 6i} - \underbrace{30}_{30i^2})\\ & = (- \underbrace{1}_{1 - 2} - 3i)(- \underbrace{11}_{1 - 12} - 7i)(- \underbrace{29}_{1 - 30} - 11i)\\ & = \underbrace{(11 + 33i + 7i +21i^2)}_{(- 1 - 3i)(- 11 - 7i)}(- 29 - 11i)\\ & = (11 + \underbrace{40i}_{33i + 7i} - \underbrace{21}_{21i^2})(- 29 - 11i)\\ & = (- \underbrace{10}_{11 - 21} + 40i)(- 29 - 11i)\\ & = 290 - 1160i + 110i - 440i^2\\ & = 290 - \underbrace{1050i}_{- 1160i + 110i} + \underbrace{440}_{440i^2}\\ & = \underbrace{730}_{290 + 440} - 1050i\end{split}\end{equation}
What does it mean for a string to be a permutation of a palindrome?
Credential: Software Engineer Posted: ~2019 (6 years ago) Views: 306 views Source: https://www.quora.com/What-does-it-mean-for-a-string-to-be-a-permutation-of-a-palindrome/answer/Naomi-Amethyst-1
Answer
It means that the string is either the empty string; a string with an odd length where every unique codepoint's cardinality is even, except for one; or a string with an even length where every unique codepoint's cardinality is even.
Can a U.S. state secede from the Union? Is there a clause in the Constitution which allows states to secede from the Union, or can this process be done by voting?
Credential: Site Reliability Architect (2013–present)7y Posted: ~2018 (7 years ago) Views: 34 views Source: https://www.quora.com/Can-a-U-S-state-secede-from-the-Union-Is-there-a-clause-in-the-Constitution-which-allows-states-to-secede-from-the-Union-or-can-this-process-be-done-by-voting/answer/Naomi-Amethyst-1
Answer
34 views · [
How do I find out what these numbers are 08:DF:1af:2F:05:18?
Posted: ~2017 (8 years ago) Views: 63 views Source: https://www.quora.com/How-do-I-find-out-what-these-numbers-are-08-DF-1af-2F-05-18/answer/Naomi-Amethyst-1
Answer
It looks like a MAC address for a Bose device, but it looks like you’ve typo’d the third octet. It should be 08:DF:1F:2F:05:18.
Which might be the best way to translate English into Java?
Credential: Software Engineer7y Posted: ~2018 (7 years ago) Views: 34 views Source: https://www.quora.com/Which-might-be-the-best-way-to-translate-English-into-Java/answer/Naomi-Amethyst-1
Answer
A good software engineer. Possibly a whole team of them, depending on the complexity of the English.
How can we write a simple program in C++ to print a prime number just before the entered number? The program should be in the simplest form.
Credential: Software Engineer Posted: ~2019 (6 years ago) Views: 233 views Source: https://www.quora.com/How-can-we-write-a-simple-program-in-C-to-print-a-prime-number-just-before-the-entered-number-The-program-should-be-in-the-simplest-form/answer/Naomi-Amethyst-1
Answer
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
int main(int argc, char *argv[]) {
unsigned long long d;
mpz_t n;
do {
printf("Enter number:\n");
} while(scanf("%llu", &d) != 1);
mpz_init_set_ui(n, d);
for(mpz_sub_ui(n, n, 1);!mpz_probab_prime_p(n, 100);mpz_sub_ui(n, n, 1));
printf("%s\n", mpz_get_str(NULL, 10, n));
return 0;
}
Compile it:
$ g++ -O3 -o primes primes.c -lgmp
Test it:
$ ./primes
Enter number:
99
97
$ ./primes
Enter number:
18446744073709551556
18446744073709551533
Seems to work.
Which five numbers equal the sum of 395?
Credential: Site Reliability Architect (2013–present)8y Posted: ~2017 (8 years ago) Views: 71 views Source: https://www.quora.com/Which-five-numbers-equal-the-sum-of-395/answer/Naomi-Amethyst-1
Answer
There are 4,937,873,096,788,191,655 partitions of 395.
What is the difference between block storage and object storage and why would you choose one over the other?
Posted: ~2017 (8 years ago) Views: 3.1K views Source: https://www.quora.com/What-is-the-difference-between-block-storage-and-object-storage-and-why-would-you-choose-one-over-the-other/answer/Naomi-Amethyst-1
Answer
Block storage is just a bunch of blocks of bits, much like your hard drive before you put a filesystem on it. It does not have any structure to hold files.
Object storage is a system where you can store or retrieve whole (and sometimes parts of) files at a time. Each file is considered an object. But distributed object storage solutions often do not have the same consistency guarantees as local filesystems when it comes to concurrent access.
Now, you’d usually use block storage when you need storage for a specific machine to use on its own, because most block storage systems provide much lower latency and faster access than object storage systems. Examples include:
- Databases
- OS drives
- Temporary/scratch space
Object storage is typically used for storage of files that need to be shared by multiple computers, but do not require strict consistency guarantees. Or where random I/O is not expected. Examples include:
- Blob storage of user content (like images, or any other larger than normal data that shouldn’t go into a database)
- Mostly static web content
- Downloadable files
- Backups
- Config files
- Packaged software
Comments
Thank you very much for a very clear explanation!
How do I convert an integer to string with the atoi function in C?
Credential: Software Engineer Posted: ~2018 (7 years ago) Views: 873 views Source: https://www.quora.com/How-do-I-convert-an-integer-to-string-with-the-atoi-function-in-C/answer/Naomi-Amethyst-1
Answer
That’s not what atoi does. atoi converts a string into an integer. The non-standard itoa method will take an integer and give you a string:
#include <stdlib.h>
#include <stdio.h>
void main() {
int integer = 15;
char buf[10];
itoa(integer, buf, 10);
printf("%s\n", buf);
}
However, you probably don’t want to use itoa because it is non-standard, and prone to buffer overruns if you aren’t careful. What is much better is to use snprintf:
#include <stdio.h>
void main() {
int integer = 15;
char buf[10];
snprintf(buf, sizeof(buf), "%d", integer);
printf("%s\n", buf);
}
What are the tips and hacks for getting the classes that you want as a freshman at the University of Illinois?
Posted: ~2015 (10 years ago) Views: 711 views Source: https://www.quora.com/What-are-the-tips-and-hacks-for-getting-the-classes-that-you-want-as-a-freshman-at-the-University-of-Illinois/answer/Naomi-Amethyst-1
Answer
Many students will overbook their calendar with the plan to drop classes that they do not like in the first two weeks of class.
If you want to get into a class that has already filled up, then one option is to pick a "backup" course so even if you don't get into the course you want to, you will still have something to fill those credits that semester, and then go to the courses that you want to go to anyway on the first day (if it doesn't conflict), and after the first lecture, let the professor know your wishes. They may be able to open a seat for you, or they may also let you know when someone drops the class, and then check, every chance you get, if a slot has opened in the first week or two. If it has, grab it. If you don't get in in the first two weeks, the chances of getting in go down.
A code is compiled for processor X. Could it be executed on a processor Y? Why?
Credential: Software Engineer Posted: ~2019 (6 years ago) Views: 103 views Source: https://www.quora.com/A-code-is-compiled-for-processor-X-Could-it-be-executed-on-a-processor-Y-Why/answer/Naomi-Amethyst-1
Answer
It depends.
Most code compiled for x86 processors can be executed on nearly any x86 or x86_64 processor out there, which includes most Intel and AMD processors on the market. Most code compiled for x86_64 processors can be executed on nearly any x86_64 processor out there. Specific optimizations can change this, however.
But, for incompatible architectures (which most are with each other), that is not the case. For example, code compiled for MIPS cannot be run on ARM processors, and vice-versa. Code compiled for ARM processors cannot be executed on x86 processors, and vice-versa. Code compiled for x86_64 cannot be run on x86 processors.
So, as long as you stay within the same architecture, or a compatible one, and you don’t use extensions to that architecture, any processor in that architecture should be able to execute it.
What is the cheapest cloud storage that provides custom domain linking?
Credential: Site Reliability Architect (2013–present)7y Posted: ~2018 (7 years ago) Views: 444 views Source: https://www.quora.com/What-is-the-cheapest-cloud-storage-that-provides-custom-domain-linking/answer/Naomi-Amethyst-1
Answer
Amazon S3 does allow for this. S3 is Amazon’s enterprise-grade cloud object store. They are quite cheap at $0.023/GB/mo (2.3 cents per GB per month), and only charge based on usage. They do charge for bandwidth, too, at $0.09/GB of outgoing bandwidth. Incoming bandwidth is free, however.
You will need your own domain, and will need to add a CNAME or A record for the subdomain you wish to use with Amazon S3.
See: Example: Setting up a Static Website Using a Custom Domain
What is the value of 6 if 1=3, 2=3, 3=5, 4=4, 5=4?
Posted: ~2018 (7 years ago) Views: 4.9K views Source: https://www.quora.com/What-is-the-value-of-6-if-1-3-2-3-3-5-4-4-5-4/answer/Naomi-Amethyst-1
Answer
The value of 6 is -i.
Proof: We’ll prove this by contradiction. That is, we’ll show that if you assume that 6 \ne -i, you arrive at a contradiction:
!(0 = 1) Definition from math
2 - 1 = 1 ^ 1 - 1 = 0 Definition from math
(x = y) = (x - z = y - z) Definition from math
-------
| 1 = 3 ^ 2 = 3 ^ 3 = 5 ^ 4 = 4 ^ 5 = 4 ACP
|-------
| | !(6 = -i) AIP
| |-------
| | 1 = 3 Conj. Elim. 5
| | 2 = 3 Conj. Elim. 5
| | 3 -> 1 Bicond. Elim. 9
| | 1 -> 3 Bicond. Elim. 9
| | 3 -> 2 Bicond. Elim. 10
| | 2 -> 3 Bicond. Elim. 10
| | 1 -> 2 HS 12, 13
| | 2 -> 1 HS 14, 11
| | 1 = 2 Bicond. Intr. 15, 16
| | (1 = 2) = (1 - 1 = 2 - 1) UI 3
| | (1 = 2) -> (1 - 1 = 2 - 1) Bicond. Elim. 18
| | 1 - 1 = 2 - 1 MP 17, 19
| | 1 - 1 -> 2 - 1 Bicond. Elim. 20
| | | 0 ACP
| | |-------
| | | 1 - 1 = 0 Conj. Elim. 2
| | | 0 -> 1 - 1 Bicond. Elim. 24
| | | 1 - 1 MP 22, 25
| | | 2 - 1 MP 26, 21
| | | 2 - 1 = 1 Conj. Elim. 2
| | | 2 - 1 -> 1 Bicond. Elim. 28
| | | 1 MP 27, 29
| | 0 -> 1 CP 22-30
| | 2 - 1 -> 1 - 1 Bicond. Elim. 20
| | | 1 ACP
| | |-------
| | | 2 - 1 = 1 Conj. Elim. 2
| | | 1 -> 2 - 1 Bicond. Elim. 35
| | | 2 - 1 MP 33, 36
| | | 1 - 1 MP 32, 37
| | | 1 - 1 = 0 Conj. Elim. 2
| | | 1 - 1 -> 0 Bicond. Elim. 39
| | | 0 MP 38, 40
| | 1 -> 0 CP 33-41
| | 0 = 1 Bicond. Intr. 31, 42
| | 0 = 1 ^ !(0 = 1) Conj. Intr. 43, 1
| 6 = -i IP 7-44
(1 = 3 ^ 2 = 3 ^ 3 = 5 ^ 4 = 4 ^ 5 = 4)
-> (6 = -i) CP 5-45
Q.E.D.
If \sin(\theta) = \frac{1}{2}, then what will \frac{\theta^2}{15} be?
Posted: ~2018 (7 years ago) Views: 307 views Source: https://www.quora.com/If-sin-theta-frac-1-2-then-what-will-frac-theta-2-15-be/answer/Naomi-Amethyst-1
Answer
Well, if you apply basic algebra to it, you can solve for \theta:
\begin{align}\sin(\theta) &= \frac{1}{2}\\\theta &= \arcsin(\frac{1}{2})\end{align}
Simplifying, we get:
\theta = \frac{\pi}{6}
Now, if we inject that value into \frac{\theta^2}{15} and then simplify, we get:
\begin{align}\frac{(\frac{\pi}{6})^2}{15} &= \frac{\frac{\pi^2}{6^2}}{15}\\&= \frac{\pi^2}{36 \times 15}\\&= \frac{\pi^2}{540}\end{align}
(For those who like degrees, \frac{\pi^2}{540} = 60\text{ deg}^2)
Comments
Good answer but you missed the case when θ 𝜃 is 5 π 6 5 𝜋 6 (150 degrees). The second solution for the equation.
Well, sin ( x ) sin ( 𝑥 ) is periodic, and so θ ∈ { 2 k π
π 6 ∣ ∀ k ∈ Z } ∪ { 2 k π + 5 π 6 ∣ ∀ k ∈ Z } 𝜃 ∈ { 2 𝑘 𝜋 + 𝜋 6 ∣ ∀ 𝑘 ∈ 𝑍 } ∪ { 2 𝑘 𝜋 + 5 𝜋 6 ∣ ∀ 𝑘 ∈ 𝑍 } . We generally use the principal value for inverse trigonometric functions, however, because it allows for more concise values.
Google and Facebook are using our data to make money. Should they be stopped?
Posted: ~2017 (8 years ago) Views: 280 views Source: https://www.quora.com/Google-and-Facebook-are-using-our-data-to-make-money-Should-they-be-stopped/answer/Naomi-Amethyst-1
Answer
Google mostly, and to some extent Facebook, offer services. Services that are useful. Services that cost billions of dollars a month to run. And they offer these services for free.
Where do they fund these services? Ads mostly. And why are advertisers willing to pay Google (and Facebook) so much money? Because Google is phenomenal at placing targeted advertisements. When you can get a click-through-rate of 0.25% or 1%, or in some cases much higher, that’s crazy to think about. You certainly cannot get that kind of reaction from advertisements anywhere else.
So, why is Google phenomenal at placing advertisements? Because they know everything about you. They know more about you than you know about you, probably.
But is this actually a problem? Google is really good at protecting your data. They don’t sell the raw contents of that data to others. They don’t really even let their own employees look at that raw data. What looks at that data? Machines. Algorithms that profile you, categorize you for ads, and decide what you, Stanford, want to see in ads, or at least what will convince you to click.
Now, let’s look at this in a world where there aren’t ads, where Google isn’t allowed to collect information about you at all. You go to google.com, type in a search, and you get taken to a page to buy a pack of 100 searches for $10. And you can’t just use Bing, or other search engines, because they all make money off of ads right now. Or you sign up for gmail, and you pay $10/mo, just like companies do. YouTube? YouTube Red is the only option now. Facebook? $20/mo.
As a software engineer, I make a decent amount of money, but that would kill me. I’d much prefer algorithms deciding what I like and what I don’t like so I can see a few advertisements that pay Google the $10 per 100 searches I make.
What do programmers mean when they say something is “non-trivial?”
Credential: Software Engineer Posted: ~2019 (6 years ago) Views: 2.8K views Source: https://www.quora.com/What-do-programmers-mean-when-they-say-something-is-non-trivial/answer/Naomi-Amethyst-1
Answer
Whenever a programmer uses a term that you don’t know what it means, a good resource to find out is the Jargon File.
Trivial and Nontrivial are usually used as extremes. For example:
Can you have the program output “Hello, Earth!” instead of “Hello, World!”? Yeah, that’s a trivial change.
Great! Now can you have it do facial recognition and say “Hello, !”? That’s nontrivial. If you think that will add to the product significantly to justify potentially several more sprints, I can see what can be done. How do you want to handle people it’s never seen before?
Oh, just use one of those police facial recognition things they show on TV all the time. That’s … decidedly nontrivial. I don’t think we could get access to those databases just because we want to greet the user by name.
The Jargon File defines nontrivial as:
Requiring real thought or significant computing power. Often used as an understated way of saying that a problem is quite difficult or impractical, or even entirely unsolvable (“Proving P=NP is nontrivial”). The preferred emphatic form is decidedly nontrivial.
Whereas the same defines trivial as:
- Too simple to bother detailing.
- Not worth the speaker's time.
- Complex, but solvable by methods so well known that anyone not utterly cretinous would have thought of them already.
- Any problem one has already solved (some claim that hackish trivial usually evaluates to “I've seen it before”). Hackers' notions of triviality may be quite at variance with those of non-hackers.
The physicist Richard Feynman, who had the hacker nature to an amazing degree (see his essay “Los Alamos From Below” in Surely You're Joking, Mr. Feynman!), defined trivial theorem as “one that has already been proved”.
How do you write "26th of May, 2017" in 5 letters without using numbers?
Posted: ~2017 (8 years ago) Views: 1.3K views Source: https://www.quora.com/How-do-you-write-26th-of-May-2017-in-5-letters-without-using-numbers/answer/Naomi-Amethyst-1
Answer
FJVYQ
Julian date. Base 26 using the uppercase latin alphabet for digits.
What is a binary response?
Credential: Software Engineer9y Posted: ~2016 (9 years ago) Views: 65 views Source: https://www.quora.com/What-is-a-binary-response/answer/Naomi-Amethyst-1
Answer
Yes.
How does Google Maps implement its shortest path algorithm?
Posted: ~2017 (8 years ago) Views: 2.8K views Source: https://www.quora.com/How-does-Google-Maps-implement-its-shortest-path-algorithm/answer/Naomi-Amethyst-1
Answer
A* can be quite efficient. You could either do it with a caching layer against a database (BigTable?) or perhaps with something entirely in memory similar to a sharded Redis cluster.
So long as the heuristic used is reasonable, A* gives very efficient searching. And with Google, I’d imagine the heuristic could even include some machine learning.
How many people have the IP address 111.222.333.111.222?
Posted: ~2018 (7 years ago) Views: 144 views Source: https://www.quora.com/How-many-people-have-the-IP-address-111-222-333-111-222/answer/Naomi-Amethyst-1
Answer
That isn’t a valid IPv4 address.
You see, IPv4 addresses are 32-bit numbers. That means that it is a number between 0 and 4,294,967,295 (or 00000000 00000000 00000000 00000000 to 11111111 11111111 11111111 11111111 in binary, 0x00000000 to 0xffffffff in hexadecimal).
Now, because remembering many small numbers is easier than one large number, and it is visually easier to tell how related the numbers are, we most commonly write IPv4 addresses as four 8-bit numbers separated by periods.
Well, an 8-bit number is a number between 0 and 255, so that means that the whole address range is represented as 0.0.0.0 to 255.255.255.255. You can never have a fifth 8-bit number in an IPv4 address, and 333 is outside of the range of valid 8-bit numbers.
What does {"error": {"message": "Error validating application. Application has been deleted.", "type": "OAuthException", "code": 101, "fbtrace_id": "EVwyuILYSVs"}} mean?
Posted: ~2017 (8 years ago) Views: 1.9K views Source: https://www.quora.com/What-does-error-message-Error-validating-application-Application-has-been-deleted-type-OAuthException-code-101-fbtrace_id-EVwyuILYSVs-mean/answer/Naomi-Amethyst-1
Answer
This is an error message returned by the Facebook Graph API, best that I can tell.
It means that the Facebook application tied to the client_id of the requesting token is invalid because the Facebook application has been deleted.
What is the most efficient programming language for implementing data structures and algorithms?
Credential: Software Engineer Posted: ~2013 (12 years ago) Views: 1.7K views Source: https://www.quora.com/What-is-the-most-efficient-programming-language-for-implementing-data-structures-and-algorithms/answer/Naomi-Amethyst-1
Answer
Algorithms and data structures are orthogonal to programming languages. When actually building data structures, it is probably fastest on the machine in C or C++, and easiest on the programmer in Java. This is because data structures are inherently typed data.
When building algorithms, pseudo-code is incredibly useful. Once you have pseudo-code, actually building the algorithm, you should use any language you are familiar with. Python greatly resembles pseudo-code. For the basic pseudo-code building blocks, they usually also translate well into C/C++. The same algorithm will generally be faster on the machine in C/C++ rather than Python, but the choice of language should not affect its runtime complexity.
How much CPU does an EC2 micro instance have access to?
Posted: ~2013 (12 years ago) Views: 346 views Source: https://www.quora.com/How-much-CPU-does-an-EC2-micro-instance-have-access-to/answer/Naomi-Amethyst-1
Answer
I've heard 0.2 ECUs while I was at re:Invent 2013, but that was just overhearing a conversation between someone else and one of the speakers.
A computer with a 32-bit address uses a 2-level page table. The virtual addresses are split into a 9-bit top-level and an 11-bit 2nd-level page table fields, and an offset. How large are the pages, and how many are there in the address space?
Credential: Site Reliability Architect Posted: ~2019 (6 years ago) Views: 11.1K views Source: https://www.quora.com/A-computer-with-a-32-bit-address-uses-a-2-level-page-table-The-virtual-addresses-are-split-into-a-9-bit-top-level-and-an-11-bit-2nd-level-page-table-fields-and-an-offset-How-large-are-the-pages-and-how-many-are/answer/Naomi-Amethyst-1
Answer
2-level page tables are tiered, prefix-based lookup tables.
The top tier page table is a table that holds 2^k elements where the element in the $n$th position is a pointer to the page table that holds pages for addresses whose most-significant k bits is n.
For each position that is mapped, the second tier page table is a table that holds 2^l elements where the element in the $m$th position is a pointer to the memory page containing data for addresses starting with most-significant k+l bits are nm.
That is to say, suppose you have a 32-bit 2-tiered system with:
k = 8
l = 16
There will be a top-level page table:
+----+----------+
|addr| location |
+----+----------+
| 00 | 100000 |
| 01 | 100201 |
| 02 | 10010A |
| 03 | 10010F |
| 04 | 1001FA |
| .. | ...... |
| FE | 1003F0 |
| FF | 1000FF |
+----+----------+
And let's assume we're looking up address 0x04023A7F. We'd look into the top-level page table at 04 and find that we need to look at a second level page table starting at 0x1001FA00 in memory.
At memory address 0x1001FA00, there will be a second level page table:
+------+----------+
| addr | location |
+------+----------+
| 0000 | 100001 |
| 0001 | 100002 |
| 0002 | 10002A |
| .... | ...... |
| 023A | 12FF7C |
| .... | ...... |
| FFFE | 13745A |
| FFFF | 10002B |
+------+----------+
So, we look at the entry for 023A because that's the next part of our address. So our physical address is 0x12FF7C7F.
Now, using our fictional architecture with the parameters above, we can calculate the page-size and the number of pages:
First, our page-size is 256 bytes (2048 bits). This is because we have $32$-bit addresses and are using 8 bits for k and 16 bits for l, leaving us with only 8 bits for the offset in the page (32 - 8 - 16 = 8), and 2^8 = 256.
Now that we know our page-size, we can find how many pages are in the address space. There are 16777216 pages in our address space. This is because we have 2^{32} = 4294967296 bytes in our address space, our pages are 256 bytes, so we can divide the size of our address space by the size of our pages to get the number of pages that will fit in the address space: \frac{2^{32}}{2^8} = 2^{24} = 16777216.
Now, you can go and do your homework by filling in your own values.
Comments
great explanation! way better than my professor
But why even give this much help when the answer is out there already on the wider internet?
What is 2+2+2+2/2?
Credential: Site Reliability Architect (2013–present)8y Posted: ~2017 (8 years ago) Views: 202 views Source: https://www.quora.com/What-is-2+2+2+-frac-2-2/answer/Naomi-Amethyst-1
Answer
2 + 2 + 2 + \frac{2}{2} = 6 + \frac{1}{1} = 6 + 1 = 7
What is the second number if one of them is 60 and their LCM is 240 and GCD is 12?
Posted: ~2017 (8 years ago) Views: 1.1K views Source: https://www.quora.com/What-is-the-second-number-if-one-of-them-is-60-and-their-LCM-is-240-and-GCD-is-12/answer/Naomi-Amethyst-1
Answer
There are equations and formulas for this, but let’s do this from first principals, with primes.
\begin{align}y = ? &= ? \\ x = 60 &= 2 \times 2 \times 3 \times 5 \\ LCM(x, y) = 240 &= 2 \times 2 \times 2 \times 2 \times 3 \times 5 \\ GCD(x, y) = 12 &= 2 \times 2 \times 3\end{align}
Now, GCD(x, y) = 12 means that the prime factors of 12 are exactly the common prime factors of x and y. And LCM(x, y) = 240 means that the prime factors of 240 contains all of the prime factors of x and of y.
So, we get:
$240 = 2 \times 2 \times \underbrace{2 \times 2 \times 3}{\text{common}} \times \underbrace{5}{\text{exclusive to $x$}}$
Which just leaves 2 \times 2 that must be exclusive to y. So:
$y = \underbrace{2 \times 2}{\text{exclusive to $y$}} \times \underbrace{2 \times 2 \times 3}{\text{common}} = 2^4 \times 3 = 48$
What is 9 divided by 0?
Credential: Site Reliability Architect (2013–present)8y Posted: ~2017 (8 years ago) Views: 159 views Source: https://www.quora.com/What-is-9-divided-by-0/answer/Naomi-Amethyst-1
Answer
Division by 0 is not defined. You cannot divide anything by 0 and get any meaningful answer out.
What is behind AWS PIOPS?
Credential: Site Reliability Architect12y Posted: ~2013 (12 years ago) Views: 589 views Source: https://www.quora.com/What-is-behind-AWS-PIOPS/answer/Naomi-Amethyst-1
Answer
SSDs are behind EBS PIOPS.
(Source: AWS re:Invent 2013)
How do I prove that \frac 1a\cdot \frac 1b= \frac 1{ab} by justifying each step?
Posted: ~2017 (8 years ago) Views: 196 views Source: https://www.quora.com/How-do-I-prove-that-frac-1a-cdot-frac-1b-frac-1-ab-by-justifying-each-step/answer/Naomi-Amethyst-1
Answer
We can convert \frac{1}{a} \times \frac{1}{b} into a^{-1} \times b^{-1}. The reason this works is because x^{n} \times x^{m} = x^{n + m}, which implies via basic algebraic manipulation that x^{n} = \frac{x^{n + m}}{x^{m}}. If we let x = a, n = -1, and m = 1, we get a^{-1} = \frac{a^{-1 + 1}}{a^1}, or simplified, a^{-1} = \frac{1}{a}. We can apply this same process to \frac{1}{b}.
Now, we can convert a^{-1} \times b^{-1} into (a \times b)^{-1}. The reason that this works is because x^n \times y^n = (x \times y)^n. The reason that this identity holds is because x^n really means \underbrace{x \times x \times x \times \ldots}_{n\text{ times}}, and since you can reorder multiplication without changing the value (just like a rectangle of x by y is the same as a rectangle of y by x, just rotated by 90^{\circ}), you can group the equal number of x and y variables together, and then collapse it back into exponent form.
We’re almost there. We can finally convert (a \times b)^{-1} into \frac{1}{ab}. The reason this works is the same as the reason the first conversion worked: x^{n} = \frac{x^{n + m}}{x^{m}}. Setting x = a \times b, n = -1, and m = 1, we get (a \times b)^{-1} = \frac{(a \times b)^{-1 + 1}}{(a \times b)^{1}} = \frac{1}{a \times b} = \frac{1}{ab}.
What is a secure log-in?
Posted: ~2017 (8 years ago) Views: 81 views Source: https://www.quora.com/What-is-a-secure-log-in/answer/Naomi-Amethyst-1
Answer
It usually means that encryption was used to transfer the credentials from the user to the server.
How can search engines like Google get backend server (i.e. SQL, files) data, articles, posts, etc., from websites/accounts that require logging in?
Posted: ~2017 (8 years ago) Views: 153 views Source: https://www.quora.com/How-can-search-engines-like-Google-get-backend-server-i-e-SQL-files-data-articles-posts-etc-from-websites-accounts-that-require-logging-in/answer/Naomi-Amethyst-1
Answer
They don’t get backend data. They do get articles and posts and such because many websites want their content indexed and waive the login process for Googlebot and friends.
When 5 is subtracted from the length and breadth of the rectangle, the perimeter becomes 26, what is the mathematical form of the statement?
Posted: ~2018 (7 years ago) Views: 660 views Source: https://www.quora.com/When-5-is-subtracted-from-the-length-and-breadth-of-the-rectangle-the-perimeter-becomes-26-what-is-the-mathematical-form-of-the-statement/answer/Naomi-Amethyst-1
Answer
\text{Let }ABCD\text{ be a rectangle such that }AB = CD \land BC = AD\text{.}
\text{Let }l = AB \land w = AD\text{. }\therefore P_{ABCD} = 2l + 2w\text{.}
\text{Finally, we can state the original question: }2(l - 5) + 2(w - 5) = 26
\text{Simplifying, we get: }2l - 10 + 2w - 10 = 26 \implies l + w = 23
Since an interface in Java only contains some abstract methods, what is the need since I have to declare the method again in my class and give it the function I want it to perform?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 836 views Source: https://www.quora.com/Since-an-interface-in-Java-only-contains-some-abstract-methods-what-is-the-need-since-I-have-to-declare-the-method-again-in-my-class-and-give-it-the-function-I-want-it-to-perform/answer/Naomi-Amethyst-1
Answer
An interface is an abstraction. It defines what a class does.
Take List<T> for example. You can write your method to take a List<String> as a parameter. You can do things with it. You don’t need to know that what the method was actually passed was a ArrayList<String>. Or maybe it was passed a LinkedList<String>. Or maybe it was a special kind of List that was created just for my special use. But all you care is that it behaves like a List<String>.
This decoupling makes your code more reusable. It means that so long as a class that I give you behaves like a certain interface, your method will work on it.
Now, let’s give another example, this time from the implementer’s point of view: Let’s say that I am writing the cryptography subsystem of a complex application. I have a class that I want everyone else to use to talk to my cryptography subsystem. Let’s call it CryptographyManager. It has a few methods for doing the things you would want to do with a cryptography subsystem, but at the same time, it has a lot of other complexity that it hides, such as storing encrypted envelope keys in the database, talking to the HSM if one is available, and managing versioned keys, and so on and so forth. Now, let’s say that the day comes that I want to have a beta version called NewCryptographyManager running alongside CryptographyManager, and have the ability to turn it on or off based on the application’s config file. This is a whole lot easier if in the beginning CryptographyManager was an interface, and CryptographyManagerImpl and CryptographyManagerNewImpl are the two classes. That way everything still refers to CryptographyManager except the one place in the code where it is constructed when it reads the config file.
Two fathers and two sons walk into a candy store, they all buy 2 chocolate bars for $.50 and the total comes to $1.50. How is that possible?
Posted: Updated 8y Views: 11.9K views Source: https://www.quora.com/Two-fathers-and-two-sons-walk-into-a-candy-store-they-all-buy-2-chocolate-bars-for-50-and-the-total-comes-to-1-50-How-is-that-possible/answer/Naomi-Amethyst-1
Answer
Let’s break it down:
“Two fathers and two sons walk into a candy store”
This part is irrelevant.
“they all buy 2 chocolate bars for $.50”
There are four interpretations of this:
- Two chocolate bars are bought between all of the people listed and each chocolate bar costs $0.50
- Two chocolate bars are bought between all of the people listed and altogether the chocolate bars cost $0.50
- Two chocolate bars are bought by each of the people listed and each bar costs $0.50
- Two chocolate bars are bought by each of the people listed and altogether the bars cost $0.50
“and the total comes to $1.50”
These answers match up based on which interpretation we used above:
- If two chocolate bars are bought between all of the people listed and each chocolate bar costs $0.50, and the total came to $1.50, then other things besides chocolate bars must have been purchased.
- If two chocolate bars are bought between all of the people listed and altogether the chocolate bars cost $0.50, and the total came to $1.50, then other things besides chocolate bars must have been purchased, or tax.
- If two chocolate bars are bought by each of the people listed and each bar costs $0.50, and the total came to $1.50, each person must have purchased other things besides chocolate bars.
- If two chocolate bars are bought by each of the people listed and altogether the bars cost $0.50, and the total came to $1.50, each person must have purchased other things besides chocolate bars, or maybe there was tax involved.
Comments
You're ovethinking it.
There are 3 generations here.
The grandfather, father and son.
The grandfather is the father of the father.
The father is the father of the son and the son of the grandfather.
The son is the son.
Therefore 2 father's and 2 sons in 3 people. 3 × $0.50 = $1.50.
I hate complexity. The cashier, who had terrible math skills rang up $1.50 in error. They never said a word until they got outside and giggled.
Real world answer
I have slight problem with ur math in situation number 2 it assumes that there is more then one transaction
Which five words begin with "ph"?
Credential: Site Reliability Architect (2013–present)7y Posted: ~2018 (7 years ago) Views: 35 views Source: https://www.quora.com/Which-five-words-begin-with-ph/answer/Naomi-Amethyst-1
Answer
- phenomenon
- phenylalanine
- philharmonic
- philosophy
- philology
How many numbers from 1 to 20,000 are divisible by all numbers from 2 to 10?
Posted: ~2017 (8 years ago) Views: 424 views Source: https://www.quora.com/How-many-numbers-from-1-to-20-000-are-divisible-by-all-numbers-from-2-to-10/answer/Naomi-Amethyst-1
Answer
2.2.0 :001 > (1..20_000).select { |x| (2..10).all? { |y| x % y == 0 } }
=> [2520, 5040, 7560, 10080, 12600, 15120, 17640]
2.2.0 :002 > _.size
=> 7
An identification code is composed of three characters. The first character is the letters A or B, followed by a 2, 4, or 6, and ending with either the letters Y or Z. How many possible codes exist?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 624 views Source: https://www.quora.com/An-identification-code-is-composed-of-three-characters-The-first-character-is-the-letters-A-or-B-followed-by-a-2-4-or-6-and-ending-with-either-the-letters-Y-or-Z-How-many-possible-codes-exist/answer/Naomi-Amethyst-1
Answer
232 = 12:
- A2Y
- A2Z
- A4Y
- A4Z
- A6Y
- A6Z
- B2Y
- B2Z
- B4Y
- B4Z
- B6Y
- B6Z
Are any cloud storage companies better than Box, Dropbox, OneDrive (Microsoft), or Drive (Google)?
Posted: ~2017 (8 years ago) Views: 2.5K views Source: https://www.quora.com/Are-any-cloud-storage-companies-better-than-Box-Dropbox-OneDrive-Microsoft-or-Drive-Google/answer/Naomi-Amethyst-1
Answer
Amazon S3.
It’s cheap. It’s pay-for-what-you-use instead of pre-sized plans. You can’t “run out of space.”
It’s robust. It’s designed for 99.999999999% durability on objects over the period of a year. It’s designed for 99.99% availability over the period of a year.
You aren’t going to get hit with rate-limits or bandwidth limits, or other kinds of limits, except perhaps on certain administrative functions. There are companies that serve high-traffic websites and high-traffic file downloads out of S3.
Oh, and it has a robust API that you can use instead of relying on special-purpose clients, so you have your choice of how to interact with it.
Amazon Simple Storage Service (S3) — Cloud Storage — AWS
Can a node in a Cassandra database contain only the data it needs?
Credential: Software Engineer10y Posted: ~2015 (10 years ago) Views: 342 views Source: https://www.quora.com/Can-a-node-in-a-Cassandra-database-contain-only-the-data-it-needs/answer/Naomi-Amethyst-1
Answer
Each node in a Cassandra database stores the data for the partitions that it is a replica for. What this means is that each node in the cluster is given a range when it joins the cluster to be the "first replica" of that data. If the keyspace is set for a higher replication factor than 1, and it is highly recommended to do so, then nodes will also be assigned other ranges. (I won't get into exactly how these ranges are assigned right now)
A Cassandra node only stores data for other nodes temporarily when hinted handoff is on and a node is down, and once it replays that data to the proper node, it will delete that data. The other time that a Cassandra node will store data that is supposed to be on another node is when the cluster has just increased in size. You can run nodetool cleanup to force the node to delete data that now belongs to another node.
If you could make a list of very specific topics every Java developer needs to know, what would be on your list? Why?
Credential: Software Engineer Posted: ~2013 (12 years ago) Views: 1.1K views Source: https://www.quora.com/If-you-could-make-a-list-of-very-specific-topics-every-Java-developer-needs-to-know-what-would-be-on-your-list-Why/answer/Naomi-Amethyst-1
Answer
- Data structures (and Java's implementations of them in the Collections framework) -- when to use what. HashMap is not the only type of Map, and ArrayList is not the only type of List. And please don't use a List where you should be using some sort of tree -- like an RTree; or where you should be using some sort of graph.
- Runtime complexity of common algorithms; and the ability to analyze an algorithm to find the runtime complexity of the algorithm. There are many good algorithms for doing common and complex things. Use the right algorithm for the right task. And if one has stood the test of time, don't re-invent the wheel. Parsing, lexing, graph search and traversal, pathfinding, sorting, hashing, searching, and many, many more problems have good solutions publicly available. Use them.
- OO concepts -- How to model a system in Java's OO paradigm. This includes interfaces, classes, polymorphism, static vs dynamic binding.
- How to create a stable interface -- one that doesn't have to change, that doesn't provide too many details about the implementation while still providing a useful interface.
- How to effectively write tests for your code.
- What libraries and frameworks are available for your use -- Guava, Apache Commons, Spring, Netty, etc.
- How to effectively use your IDE -- there are many good IDEs for Java, and they can be tremendously useful to you if you understand how to wield their power.
- Thread-safety.
Comments
Thank you so much for the detailed answer. I'm a current CS student with a goal of getting a software engineering internship somewhere before I grad. This will be helpful!
How can I print 'hello world' in C without using printf and puts in the program?
Credential: Software Engineer Posted: ~2018 (7 years ago) Views: 17.9K views Source: https://www.quora.com/How-can-I-print-hello-world-in-C-without-using-printf-and-puts-in-the-program/answer/Naomi-Amethyst-1
Answer
On Linux, running on a modern x86_64 processor:
int main() {
char *s = "Hello, World!\n";
long l = 14;
long fd = 1;
long syscall = 1;
long ret = 0;
__asm__ ( "syscall"
: "=a" (ret)
: "a" (syscall),
"D" (fd),
"S" (s),
"d" (l)
);
return 0;
}
Compile it with gcc:
$ gcc -o test test.c
And execute it:
$ ./test
Hello, World!
Of course, it’s not particularly portable. That’s why we have stdio and all of the nice functions that it provides like printf.
Comments
I would have used fputs on stdout - but hey ho - lol .
can you explain each line of your code or can provide me some link where i can understand..
How can I write a file real time in Java without using a buffer?
Credential: Software Engineer Posted: ~2015 (10 years ago) Views: 782 views Source: https://www.quora.com/How-can-I-write-a-file-real-time-in-Java-without-using-a-buffer/answer/Naomi-Amethyst-1
Answer
What you are looking for is O_DIRECT, which is platform-dependent and has tons of weird quirks. Using System.setOut(fileName) is not sufficient because the OS will still buffer it. You'll need to use something like smacke/jaydio to use direct I/O. Also note that bypassing the OS buffer will, in general, make your I/O slower.
What is the difference between Raleigh and durham?
Posted: ~2016 (9 years ago) Views: 10.3K views Source: https://www.quora.com/What-is-the-difference-between-Raleigh-and-durham/answer/Naomi-Amethyst-1
Answer
[Answer content not available]
How do you integrate the function \displaystyle \int \ln \dfrac {(e^{x^2} +1) + 2 ((e^{x^2 }(2x^2 - 1) - 1) }{ (e^{x^2} + 1) ^2)} dx ?
Credential: Site Reliability Architect (2013–present)8y Posted: ~2017 (8 years ago) Views: 362 views Source: https://www.quora.com/How-do-you-integrate-the-function-displaystyle-int-ln-left-dfrac-e-x-2-1-2-e-x-2-2x-2-1-1-e-x-2-1-2-right-dx/answer/Naomi-Amethyst-1
Answer
As written, you don’t. You’ve got a syntax error with those mis-matched parentheses.
What is between 3/4 and 5/6?
Credential: Site Reliability Architect (2013–present)8y Posted: ~2017 (8 years ago) Views: 54 views Source: https://www.quora.com/What-is-between-3-4-and-5-6/answer/Naomi-Amethyst-1
Answer
\{ x \in \R\, \lvert\, \frac{3}{4} < x < \frac{5}{6} \}
What whole number(s) divide(s) 22 and leaves a remainder of 4?
Posted: ~2017 (8 years ago) Views: 3.5K views Source: https://www.quora.com/What-whole-number-s-divide-s-22-and-leaves-a-remainder-of-4/answer/Naomi-Amethyst-1
Answer
6, 9, and 18 all divide 22 with a remainder of 4:
irb(main):001:0> (1..22).select { |x| 22 % x == 4 }
=> [6, 9, 18]
How can I moniter the browsing history of people that use my home wifi network?
Posted: ~2018 (7 years ago) Views: 4.3K views Source: https://www.quora.com/How-can-I-moniter-the-browsing-history-of-people-that-use-my-home-wifi-network/answer/Naomi-Amethyst-1
Answer
With so many websites using HTTPS now, it cannot be done without their consent or control over the machine that they use. That’s what “secure” means in browsers.
You might be able to determine what domains they went to, but not the full URL, if you log DNS queries.
If n is divided with 2 the remainder will be 2, when on 3 it will be 1 and with four it is 2 with 5 it is 3 with 6 it is 3 with 7 it is 6 with 8 it is 2 with 8 it is 1 with 9 it is 9 and now, what is the value of N?
Posted: ~2018 (7 years ago) Views: 205 views Source: https://www.quora.com/If-n-is-divided-with-2-the-remainder-will-be-2-when-on-3-it-will-be-1-and-with-four-it-is-2-with-5-it-is-3-with-6-it-is-3-with-7-it-is-6-with-8-it-is-2-with-8-it-is-1-with-9-it-is-9-and-now-what-is-the-value-of-N/answer/Naomi-Amethyst-1
Answer
There is no number that satisfies all of those conditions. That is to say:
\{ n \in \mathbb{Z} \mid n\text{ mod }[2, 3, 4, 5, 6, 7, 8, 8, 9] = [2, 1, 2, 3, 3, 6, 2, 1, 9] \} = \emptyset
The modulo operator (division with remainder) with an integer output and an integer divisor only makes sense with an integer dividend.
The range of the modulo function n\text{ mod }m is [0, m). That is to say, that the output of the modulo function can never be larger than or equal to the divisor. You’ll note that in the question, you said that n\text{ mod }2 = 2 and then again n\text{ mod }9 = 9. Neither of these cases will ever be true for any value of n.
Secondly, the modulo function is deterministic. That is to say that given the same inputs, it will always return the same outputs. However, you’ll note in the question, you said that n\text{ mod }8 = 2 and n\text{ mod }8 = 1. These cannot ever be simultaneously true. (Trivial proof left as an exercise to the reader.)
What is the difference between (Stack stack = new Stack<>();) and (Stack stack = new Stack();)?
Credential: Software Engineer Posted: ~2018 (7 years ago) Views: 354 views Source: https://www.quora.com/What-is-the-difference-between-Stack-Character-stack-new-Stack-and-Stack-Character-stack-new-Stack-Character/answer/Naomi-Amethyst-1
Answer
There is no difference. In the first case, <> is short-hand in Java to indicate that the compiler should figure out the generic by looking at the generic on the left-hand-side of the assignment expression.
You have only 5 minutes to save all your files on your 2tb HDD on Windows 10 before a virus infects it. All your files are important. How will you save the files? You can't take the HDD out or turn off the PC, Antivirus is not an option.
Credential: Site Reliability Architect Posted: ~2019 (6 years ago) Views: 4.1K views Source: https://www.quora.com/You-have-only-5-minutes-to-save-all-your-files-on-your-2tb-HDD-on-Windows-10-before-a-virus-infects-it-All-your-files-are-important-How-will-you-save-the-files-You-cant-take-the-HDD-out-or-turn-off-the-PC-Antivirus/answer/Naomi-Amethyst-1
Answer
Some modern 2TB NVMe devices are capable of more than 7GB/s (Gigabytes per second, not gigabits per second) of sequential read. That is barely sufficient to read the whole disk in under 5 minutes.
Now you have to send it somewhere. This …
… is a dual 40 gbit/s network interface card. Bonded in a round-robin configuration, this can push 80 gbit/s (10 GB/s) to a network. So, assuming you have this kind of hardware in your computer, this seems reasonably doable.
Comments
No hard drive has a read speed fast enough to write to that nvme in time. Its not gonna work.
The plan isn’t to write to the NVMe drive; it’s to read from it as a source.
While that would be fun, the challenge question says that the data is on a 2tb HDD. So yeah you are gonna be stuck with that HDD no matter what
The network card is capable of the Data transfer but But you would still have bottle necks, The transfer speed of the actual switch itself, network overhead and other traffic, and the ability of the target to process the data at the same rate.
I got your back: Cisco Catalyst 9500 Series Switches Data Sheet the 9500–32QC can ‘ONLY’ handle 3.2 Tbps. You might want to warn the guys that are receiving your data to brace for impact, though.
Colloquially, hdd can refer to a system’s primary non-volatile memory, rather than specifically a magnetic-based non-volatile memory. Given the ridiculousness of the question, a little leeway in interpretation was used.
How can I code binary search to find a value of double data type when it's not in any array?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 1.6K views Source: https://www.quora.com/How-can-I-code-binary-search-to-find-a-value-of-double-data-type-when-its-not-in-any-array/answer/Naomi-Amethyst-1
Answer
#include <stdio.h>
double rhs() {
return 8.798569;
}
double lhs(double x) {
return x * x + 3.0 * x + 7.0;
}
double find(double low, double high, double (*l)(double), double r) {
double mid = (low + high) / 2.0;
if(mid == high || mid == low)
return low;
if((*l)(mid) > r)
return find(low, mid, l, r);
return find(mid, high, l, r);
}
void main() {
printf("Value: %lf\n", find(-100000000.0, 100000000.0, &lhs, rhs()));
}
Compiling this gives the following output:
$ gcc -o find_root find_root.c
$ ./find_root
Value: 0.512106
Be careful, as this method won’t find all roots. It works by adjusting low and high up or down based on whether the midpoint is higher or lower than the target:
low=-100000000 high=100000000 mid=0.0 l(mid)=7.0 r=8.798569 <=
low=0 high=100000000 mid=50000000.0 l(mid)=2500000150000007.0 r=8.798569 >
low=0 high=50000000 mid=25000000.0 l(mid)=625000075000007.0 r=8.798569 >
low=0 high=25000000 mid=12500000.0 l(mid)=156250037500007.0 r=8.798569 >
low=0 high=12500000 mid=6250000.0 l(mid)=39062518750007.0 r=8.798569 >
low=0 high=6250000 mid=3125000.0 l(mid)=9765634375007.0 r=8.798569 >
low=0 high=3125000 mid=1562500.0 l(mid)=2441410937507.0 r=8.798569 >
low=0 high=1562500 mid=781250.0 l(mid)=610353906257.0 r=8.798569 >
low=0 high=781250 mid=390625.0 l(mid)=152589062507.0 r=8.798569 >
low=0 high=390625 mid=195312.5 l(mid)=38147558600.75 r=8.798569 >
low=0 high=195312.5 mid=97656.25 l(mid)=9537036139.8125 r=8.798569 >
low=0 high=97656.25 mid=48828.125 l(mid)=2384332282.390625 r=8.798569 >
low=0 high=48828.125 mid=24414.0625 l(mid)=596119696.9414062 r=8.798569 >
low=0 high=24414.0625 mid=12207.03125 l(mid)=149048240.03222656 r=8.798569 >
low=0 high=12207.03125 mid=6103.515625 l(mid)=37271220.53149414 r=8.798569 >
low=0 high=6103.515625 mid=3051.7578125 l(mid)=9322388.019592285 r=8.798569 >
low=0 high=3051.7578125 mid=1525.87890625 l(mid)=2332891.0732574463 r=8.798569 >
low=0 high=1525.87890625 mid=762.939453125 l(mid)=584372.4274940491 r=8.798569 >
low=0 high=762.939453125 mid=381.4697265625 l(mid)=146670.56146335602 r=8.798569 >
low=0 high=381.4697265625 mid=190.73486328125 l(mid)=36958.99266076088 r=8.798569 >
low=0 high=190.73486328125 mid=95.367431640625 l(mid)=9388.049312651157 r=8.798569 >
low=0 high=95.367431640625 mid=47.6837158203125 l(mid)=2423.787901893258 r=8.798569 >
low=0 high=47.6837158203125 mid=23.84185791015625 l(mid)=646.9597623385489 r=8.798569 >
low=0 high=23.84185791015625 mid=11.920928955078125 l(mid)=184.8713340172544 r=8.798569 >
low=0 high=11.920928955078125 mid=5.9604644775390625 l(mid)=60.4085302206222 r=8.798569 >
low=0 high=5.9604644775390625 mid=2.9802322387695312 l(mid)=24.822480913309846 r=8.798569 >
low=0 high=2.9802322387695312 mid=1.4901161193847656 l(mid)=13.69079440740461 r=8.798569 >
low=0 high=1.4901161193847656 mid=0.7450580596923828 l(mid)=9.790285691389727 r=8.798569 >
low=0 high=0.74505805969238281 mid=0.3725290298461914 l(mid)=8.256364967616719 r=8.798569 <=
low=0.37252902984619141 high=0.74505805969238281 mid=0.5587935447692871 l(mid)=8.988630859983687 r=8.798569 >
low=0.37252902984619141 high=0.55879354476928711 mid=0.46566128730773926 l(mid)=8.613824296420319 r=8.798569 <=
low=0.46566128730773926 high=0.55879354476928711 mid=0.5122274160385132 l(mid)=8.799059173857032 r=8.798569 >
low=0.46566128730773926 high=0.51222741603851318 mid=0.4889443516731262 l(mid)=8.705899634052432 r=8.798569 <=
low=0.48894435167312622 high=0.51222741603851318 mid=0.5005858838558197 l(mid)=8.75234387868317 r=8.798569 <=
low=0.5005858838558197 high=0.51222741603851318 mid=0.5064066499471664 l(mid)=8.775667644952211 r=8.798569 <=
low=0.50640664994716644 high=0.51222741603851318 mid=0.5093170329928398 l(mid)=8.787354939075149 r=8.798569 <=
low=0.50931703299283981 high=0.51222741603851318 mid=0.5107722245156765 l(mid)=8.793204938883722 r=8.798569 <=
low=0.5107722245156765 high=0.51222741603851318 mid=0.5114998202770948 l(mid)=8.796131526974785 r=8.798569 <=
low=0.51149982027709484 high=0.51222741603851318 mid=0.511863618157804 l(mid)=8.797595218067011 r=8.798569 <=
low=0.51186361815780401 high=0.51222741603851318 mid=0.5120455170981586 l(mid)=8.798327162874797 r=8.798569 <=
low=0.5120455170981586 high=0.51222741603851318 mid=0.5121364665683359 l(mid)=8.798693160094107 r=8.798569 >
low=0.5120455170981586 high=0.51213646656833589 mid=0.5120909918332472 l(mid)=8.798510159416502 r=8.798569 <=
low=0.51209099183324724 high=0.51213646656833589 mid=0.5121137292007916 l(mid)=8.798601659238317 r=8.798569 >
low=0.51209099183324724 high=0.51211372920079157 mid=0.5121023605170194 l(mid)=8.79855590919816 r=8.798569 <=
low=0.51210236051701941 high=0.51211372920079157 mid=0.5121080448589055 l(mid)=8.798578784185928 r=8.798569 >
low=0.51210236051701941 high=0.51210804485890549 mid=0.5121052026879624 l(mid)=8.798567346683967 r=8.798569 <=
low=0.51210520268796245 high=0.51210804485890549 mid=0.512106623773434 l(mid)=8.798573065432928 r=8.798569 >
low=0.51210520268796245 high=0.51210662377343397 mid=0.5121059132306982 l(mid)=8.798570206057942 r=8.798569 >
low=0.51210520268796245 high=0.51210591323069821 mid=0.5121055579593303 l(mid)=8.798568776370828 r=8.798569 <=
low=0.51210555795933033 high=0.51210591323069821 mid=0.5121057355950143 l(mid)=8.798569491214353 r=8.798569 >
low=0.51210555795933033 high=0.51210573559501427 mid=0.5121056467771723 l(mid)=8.798569133792583 r=8.798569 >
low=0.51210555795933033 high=0.5121056467771723 mid=0.5121056023682513 l(mid)=8.798568955081704 r=8.798569 <=
low=0.51210560236825131 high=0.5121056467771723 mid=0.5121056245727118 l(mid)=8.798569044437142 r=8.798569 >
low=0.51210560236825131 high=0.5121056245727118 mid=0.5121056134704816 l(mid)=8.798568999759423 r=8.798569 <=
low=0.51210561347048156 high=0.5121056245727118 mid=0.5121056190215967 l(mid)=8.798569022098283 r=8.798569 >
low=0.51210561347048156 high=0.51210561902159668 mid=0.5121056162460391 l(mid)=8.798569010928853 r=8.798569 >
low=0.51210561347048156 high=0.51210561624603912 mid=0.5121056148582603 l(mid)=8.798569005344138 r=8.798569 >
low=0.51210561347048156 high=0.51210561485826034 mid=0.512105614164371 l(mid)=8.79856900255178 r=8.798569 >
low=0.51210561347048156 high=0.51210561416437095 mid=0.5121056138174263 l(mid)=8.798569001155602 r=8.798569 >
low=0.51210561347048156 high=0.51210561381742625 mid=0.5121056136439539 l(mid)=8.798569000457512 r=8.798569 >
low=0.51210561347048156 high=0.51210561364395391 mid=0.5121056135572177 l(mid)=8.798569000108468 r=8.798569 >
low=0.51210561347048156 high=0.51210561355721773 mid=0.5121056135138496 l(mid)=8.798568999933945 r=8.798569 <=
low=0.51210561351384964 high=0.51210561355721773 mid=0.5121056135355337 l(mid)=8.798569000021207 r=8.798569 >
low=0.51210561351384964 high=0.51210561353553374 mid=0.5121056135246917 l(mid)=8.798568999977576 r=8.798569 <=
low=0.51210561352469175 high=0.51210561353553374 mid=0.5121056135301127 l(mid)=8.798568999999391 r=8.798569 <=
low=0.51210561353011275 high=0.51210561353553374 mid=0.5121056135328232 l(mid)=8.7985690000103 r=8.798569 >
low=0.51210561353011275 high=0.51210561353282325 mid=0.512105613531468 l(mid)=8.798569000004845 r=8.798569 >
low=0.51210561353011275 high=0.512105613531468 mid=0.5121056135307904 l(mid)=8.798569000002118 r=8.798569 >
low=0.51210561353011275 high=0.51210561353079043 mid=0.5121056135304516 l(mid)=8.798569000000755 r=8.798569 >
low=0.51210561353011275 high=0.51210561353045159 mid=0.5121056135302822 l(mid)=8.798569000000073 r=8.798569 >
low=0.51210561353011275 high=0.51210561353028217 mid=0.5121056135301975 l(mid)=8.798568999999732 r=8.798569 <=
low=0.51210561353019746 high=0.51210561353028217 mid=0.5121056135302398 l(mid)=8.798568999999903 r=8.798569 <=
low=0.51210561353023976 high=0.51210561353028217 mid=0.512105613530261 l(mid)=8.798568999999988 r=8.798569 <=
low=0.51210561353026096 high=0.51210561353028217 mid=0.5121056135302715 l(mid)=8.79856900000003 r=8.798569 >
low=0.51210561353026096 high=0.51210561353027151 mid=0.5121056135302662 l(mid)=8.79856900000001 r=8.798569 >
low=0.51210561353026096 high=0.51210561353026618 mid=0.5121056135302635 l(mid)=8.798568999999999 r=8.798569 <=
low=0.51210561353026351 high=0.51210561353026618 mid=0.5121056135302648 l(mid)=8.798569000000004 r=8.798569 >
low=0.51210561353026351 high=0.51210561353026485 mid=0.5121056135302642 l(mid)=8.798569 r=8.798569 <=
low=0.51210561353026418 high=0.51210561353026485 mid=0.5121056135302645 l(mid)=8.798569000000002 r=8.798569 >
low=0.51210561353026418 high=0.51210561353026451 mid=0.5121056135302644 l(mid)=8.798569000000002 r=8.798569 >
low=0.51210561353026418 high=0.5121056135302644 mid=0.5121056135302643 l(mid)=8.798569 r=8.798569 <=
low=0.51210561353026429 high=0.5121056135302644 mid=0.5121056135302644 l(mid)=8.798569000000002 r=8.798569 >
What does (*a) [10] mean?
Posted: Updated 8y Views: 202 views Source: https://www.quora.com/What-does-*a-10-mean/answer/Naomi-Amethyst-1
Answer
It means the value stored at the memory address computed by summing the value at the memory address stored in the memory address of a and 10 times the size of the type of variable pointed to by a.
Or more symbolically, assuming m(x) gives the value of the memory at location x and s(x) gives the size of the type of the pointer at memory location x, it is equivalent to m(m(a) + 10 \times s(m(a))).
Or for you assembly-types, assuming a is in rax:
movq (rax), rax # rax now has value *a
addq 10, rax # rax now has value *a + 10
movq (rax), rax # rax now has value *(*a + 10) or (*a)[10].
How would you subtract 9½-19¾?
Posted: ~2017 (8 years ago) Views: 567 views Source: https://www.quora.com/How-would-you-subtract-9%C2%BD-19%C2%BE/answer/Naomi-Amethyst-1
Answer
First we need to convert 9\frac{1}{2} - 19\frac{3}{4} into a usable format. There are many usable formats, but I am going to go with the most ubiquitous, which is Single-precision floating-point numbers as specified by the IEEE 754 standard:
So, for 9\frac{1}{2} we get:
minuend = 0 10000010 00110000000000000000000
And for 19\frac{3}{4} we get:
subtrahend = 0 10000011 00111100000000000000000
Now, because we are subtracting, we need to take the minuend as an addend and we need to flip the sign bit of the subtrahend to turn it into an addend:
addend_1 = 0 10000010 00110000000000000000000
addend_2 = 1 10000011 00111100000000000000000
Now, we need to add these addends. To do that, we need to subtract the smaller exponent from the larger one:
d = 1000 0011 - 1000 0010
= 0000 0001
And we shift the fraction part of the number with the smaller exponent right by d places and add d to its exponent:
addend_1 = 0 10000011 00011000000000000000000
Now because the signs are different, we can subtract the smaller fraction part from the larger one:
addend_2 = 1 10000011 00111100000000000000000
addend_1 = 0 10000011 00011000000000000000000
-----------------------
sum = ? ???????? 00100100000000000000000
Now, we take the sign of the larger number:
sum = 1 ???????? 00100100000000000000000
Now, we need to left shift the fraction by d and subtract d from the larger exponent and use that:
sum = 1 10000010 01001000000000000000000
Which is, if we convert it back to the original representation:
-10\frac{1}{4}
P.S. I know I’ve simplified a few things and glossed over others. If you want to add more detail, suggest an edit! :)
In answer to the question ‘can you add three odd numbers together to get 30’ Why use all these mathematical formulas when a simple answer is 27+9/3=30?
Posted: ~2018 (7 years ago) Views: 436 views Source: https://www.quora.com/In-answer-to-the-question-can-you-add-three-odd-numbers-together-to-get-30-Why-use-all-these-mathematical-formulas-when-a-simple-answer-is-27-9-3-30/answer/Naomi-Amethyst-1
Answer
That's not adding 3 numbers, you're adding two numbers, 27 and \frac{9}{3} (which is just 3 by the way).
The question asks “can you add three odd numbers together to get 30”. Let’s break down that sentence:
Essentially the question is asking if it is possible to add (that is, sum together, use addition) three odd numbers (these would be the addends, and the fact that they are odd requires that they be integers, as odd is not defined for non-integers), and get 30 (meaning the sum is 30).
So, mathematically, the way you can write that is that the formula should be in the form of:
a + b + c = 30 where a, b, and c are all odd numbers. Note that there are 3 numbers separated by two + operators, that is what the question is asking. Your formula doesn’t fit because it only has one + operator.
How can we symbolically notate that a, b, and c are all odd numbers? Well the easiest way to do that is to denote an odd number as 2k + 1 where k \in \mathbb{Z} (that is, k is an integer). Since k is unbound, we can substitute any other variable we want into it, so let’s say that a = 2i + 1, b = 2j + 1, and c = 2k + 1 for i, j, k \in \mathbb{Z}.
Now, if you substitute those expressions into the original formula: a + b + c = 30 you get (2i + 1) + (2j + 1) + (2k + 1) = 30.
Simplifying, you get 2i + 2j + 2k + 3 = 30, 2i + 2j + 2k = 27, 2(i + j + k) = 27, and finally i + j + k = \frac{27}{2}.
Now, because integers are closed under addition (that is to say that when you add integers together, you always get integers), and because \frac{27}{2} = 13.5 is not an integer, then one of i, j, or k must not be an integer. This is a contradiction and shows that the original premise (that you could have three odd numbers sum to 30) is false.
P.S. This question was originally asked as a comment on Naomi Amethyst's answer to Can you add 3 odd numbers to get 30?
Comments
I still think It’s 3 numbers not 2.
Still not adding 3 numbers.
What is the square root of 3x times the square root of 16x in radical form?
Posted: ~2017 (8 years ago) Views: 230 views Source: https://www.quora.com/What-is-the-square-root-of-3x-times-the-square-root-of-16x-in-radical-form/answer/Naomi-Amethyst-1
Answer
\sqrt{3x} \times \sqrt{16x}
Oh, did you want that simplified?
\begin{align}\sqrt{3x} \times \sqrt{16x} &= \sqrt{3x \times 16x} \\ &= \sqrt{16} \times \sqrt{x^2} \times \sqrt{3} \\ &= 4x\sqrt{3}\end{align}
A balloon-seller has balloons of 3 different sizes (small, medium and large) and balloons are available in 4 different colors (violet, green, yellow, and blue). In how many possible ways can you choose a balloon?
Posted: ~2017 (8 years ago) Views: 222 views Source: https://www.quora.com/A-balloon-seller-has-balloons-of-3-different-sizes-small-medium-and-large-and-balloons-are-available-in-4-different-colors-violet-green-yellow-and-blue-In-how-many-possible-ways-can-you-choose-a-balloon/answer/Naomi-Amethyst-1
Answer
12:
2.2.0 :001 > %w[small medium large].product(%w[violet green yellow blue])
=> [["small", "violet"], ["small", "green"], ["small", "yellow"], ["small", "blue"], ["medium", "violet"], ["medium", "green"], ["medium", "yellow"], ["medium", "blue"], ["large", "violet"], ["large", "green"], ["large", "yellow"], ["large", "blue"]]
2.2.0 :002 > _.count
=> 12
How do you type a number squared with a 2 on a computer?
Posted: ~2017 (8 years ago) Views: 3.7K views Source: https://www.quora.com/How-do-you-type-a-number-squared-with-a-2-on-a-computer/answer/Naomi-Amethyst-1
Answer
Like this: number^2
What are the basic elements of assembly language?
Credential: Software Engineer Posted: ~2018 (7 years ago) Views: 3.5K views Source: https://www.quora.com/What-are-the-basic-elements-of-assembly-language/answer/Naomi-Amethyst-1
Answer
Assembly languages typically have labels, a syntax for specifying registers, a syntax for specifying immediate values, a syntax for specifying data segments, a syntax for specifying metadata, and a syntax for specifying instructions.
Labels allow you to mark a location in memory/instructions (on most architectures, these are the same) with a human readable name. Typically these look like a name followed by a colon and referenced by name:
mov a, 128
my_label:
dec a
jnz my_label
A syntax for specifying registers is how you provide registers to instructions. Typically these are named after letters, or other short mnemonics. Sometimes these are prefixed with % or $, or sometimes if registers are numeric, they might be prefixed with r:
xor a, a
xor %a, %a
xor $a, $a
xor r0, r0
A syntax for specifying immediate values is how you provide immediate values to instructions. Typically these are simple numeric values, but sometimes they are prefixed with $. Non-decimal numbers are typically denoted by either a prefix or suffix. For example:
mov a, 0
mov a, $0
mov a, 0x80
mov a, 80h
mov a, $80h
mov a, 644o
mov a, 0o644
mov a, 0644
mov a, 10b
mov a, 0b10
A syntax for specifying data segments is how you set up data segments of memory. Typically these are used for global variable storage, string constants, static variables, etc. These tend to be combined with labels:
hello: db 'Hello world!',10
A syntax for specifying metadata is how you set up things like main entrypoint, exported symbols for linking, delineate different segments, etc.
Finally the syntax for specifying instructions is how the instructions are written and how parameters are supplied. Typically this is the instruction mnemonic followed by the arguments separated by commas. There are two popular argument orders: Destination first, and destination last:
mov a, 0
mov 0, a
What possible numbers are next in this sequence, 5, 8, 12, 18?
Posted: ~2017 (8 years ago) Views: 306 views Source: https://www.quora.com/What-possible-numbers-are-next-in-this-sequence-5-8-12-18/answer/Naomi-Amethyst-1
Answer
Any number could be next in the sequence. Observe:
f(x) \stackrel{\text{def}}{=} \begin{cases} 5, & \text{for } x = 1\\ 8, & \text{for } x = 2\\12, & \text{for } x = 3\\18, & \text{for } x = 4\\ 42, & \text{otherwise} \end{cases}
So, clearly this sequence is the sequence of f(x) for x \in \mathbb{N}, which means the first bit of the sequence is:
5, 8, 12, 18, 42, 42, 42, 42, \dots
When should I use Lists vs Sets in Java?
Credential: Software Engineer Posted: ~2016 (9 years ago) Views: 7.1K views Source: https://www.quora.com/When-should-I-use-Lists-vs-Sets-in-Java/answer/Naomi-Amethyst-1
Answer
A List is used if you want a list of items in order. Think of a deck of cards. The cards are in an order. There is a card on the top of the deck.
A Set is used if you only care about whether something is contained in a larger group of things. Continuing the cards analogy, think of a poker hand. You have 5 cards, and it doesn’t matter which one is the first one. Another example is the set of prime numbers. The main question you want to be able to ask is “Is 6983 prime?” But you cannot have duplicate entries in a Set.
What is an ID-10T error?
Credential: Software Engineer Posted: ~2018 (7 years ago) Views: 3.8K views Source: https://www.quora.com/What-is-an-ID-10T-error/answer/Naomi-Amethyst-1
Answer
The ID-10T error code is a jocular, fictitious error code that gained popularity as a disguised way of calling someone an idiot. This comes from the fact that the 10, when written as digits, could be confused for I and O. Drop the dash and you’ve got the word idiot.
It is related to the PEBKAC class of errors — that is, Problem Exists Between Keyboard And Chair — another tongue-in-cheek acronym to describe user errors (errors caused by incorrect usage by the user).
These terms were used more widely back in the 1990s when it was more socially acceptable to use the terms behind users’ backs, but have fallen out of common usage today.
Comments
I still hear it used, but self applied :)
How can I customize the GO button on LaunchRock using the advanced code editor?
Posted: ~2014 (11 years ago) Views: 2K views Source: https://www.quora.com/How-can-I-customize-the-GO-button-on-LaunchRock-using-the-advanced-code-editor/answer/Naomi-Amethyst-1
Answer
The CSS for the GO button can be customized by adding a block, for example, like this:
.LR-sign-up-submit {
clear: both;
width: auto !important;
}
This moves the GO button to the next line down (clear: both), and makes the width auto-sizing (width: auto !important;). As far as why you need the !important flag on the width attribute, I do not know particularly. It worked correctly when I wrote it 2 years ago, but I haven't worked at LaunchRock for almost 2 years.
To change the actual text of the GO button, in the HTML editor window, find:
<input type="submit" name="submit" title="GO" value="GO" class="LR-sign-up-submit">
And change it as you see fit -- for example to change it to say SUBMIT instead of GO:
<input type="submit" name="submit" title="Submit" value="Submit" class="LR-sign-up-submit">
How do I write an algorithm that adds all numbers from 1 to 100 and displays only the final sum using the while condition?
Posted: ~2019 (6 years ago) Views: 147 views Source: https://www.quora.com/How-do-I-write-an-algorithm-that-adds-all-numbers-from-1-to-100-and-displays-only-the-final-sum-using-the-while-condition/answer/Naomi-Amethyst-1
Answer
#include <stdio.h>
int sum(int a, int b) {
int ret;
asm(
"mov %%esi, %%eax \n"
"sub %%edi, %%esi \n"
"add %%edi, %%eax \n"
"add $01, %%esi \n"
"imul %%eax, %%esi \n"
"mov %%esi, %%eax \n"
"shr $31, %%eax \n"
"add %%esi, %%eax \n"
"sar %%eax \n"
: "=a" (ret),
"+S" (b)
: "D" (a)
: "cc");
return ret;
}
int main() {
do {
printf("%d\n", sum(1, 100));
} while(0);
return 0;
}
Compile with:
$ gcc -o sum sum.c
And run to get:
$ ./sum
5050
List 3 numbers which are divisible by 3?
Posted: ~2017 (8 years ago) Views: 43 views Source: https://www.quora.com/List-3-numbers-which-are-divisible-by-3/answer/Naomi-Amethyst-1
Answer
\exists_{n_1,n_2,n_3} \text{ s.t. } \{n_1, n_2, n_3\} \subset \{ 3k : k \in \mathbb{Z} \}
What should be kept in mind before applying to a DevOps Engineer position?
Posted: ~2015 (10 years ago) Views: 1.4K views Source: https://www.quora.com/What-should-be-kept-in-mind-before-applying-to-a-DevOps-Engineer-position/answer/Naomi-Amethyst-1
Answer
So, first off, the term "DevOps Engineer" means a lot of different things to a lot of different people. For this question, I'm going to assume that your definition of DevOps Engineer, in this case, is the merging of the traditional role of Operations Engineer with that of a Software Engineer.
This means that you need to be strong on both fronts: Software Development, and Operations. If I were interviewing you, I would look for a few things:
- Foundational Linux Knowledge: Are you comfortable at the shell? Do you know the common utilities and tools to do basic tasks? Are you comfortable with piping, grep, awk, sed, curl/wget, tar?
- Foundational Programming Knowledge: Are you comfortable with the concepts of variables, control structures, data structures? Can you organize your programs well? OO (at least superficially)?
- Basic Problem Solving: Can you break a problem down into smaller problems that can be solved easier? Are you comfortable with formal logic (not necessarily the terminology used by philosophers, but the concepts used by computers)?
- Shell Scripting: Do you know how to write a shell script? Do you know any of the common scripting languages used when something outgrows shell scripting?
- Advanced Linux Knowledge: Do you understand how the operating system works? Do you understand system calls? Do you understand how the scheduler works? Virtual memory? The VFS? The FHS? Networking?
- Advanced Software Engineering: Do you understand OO (deeply, not superficially)? Do you understand how and when to modularize? When it is better to separate something out into a separate service? How to layer what you are writing in such a way that the foundational layers will not need to change much as the service evolves?
- Linux Ecosystem: Do you understand syslog? Its alternatives? What about bind and its alternatives? Monitoring tools? Apache? nginx? haproxy? MySQL? Cassandra? Redis? Memcache? Postfix or its alternatives? opensshd? Chef/puppet?
- Software Engineering Ecosystem: This starts to depend on the languages that the company uses, but good candidates are: your IDE of choice, your build toolchain, CI/CD, libraries, testing, version control.
- Cloud Ecosystem: Depending on which cloud provider the company uses, be prepared to be asked questions about AWS, GCE, Azure, or one of the others.
- Security: Do you know what security best practices are? When writing code or writing system automation, do you keep them in mind? Do you know what Shell Shock was? Heartbleed? Poodle? Do you know what SSL is? How it works?
Depending on how many of the above the interviewee nails, in my mind roughly determines what level they are. For example, I'd expect a Jr DevOps Engineer to get 1, 2, 3, and 10, with a desire to learn more of them. I'd expect a Sr. DevOps Engineer to get 1, 2, 3, 4, 5 or 6, 7 or 8, 9, and 10. I'd expect a higher level DevOps Engineer to nail all 10.
Which database is best?
Posted: ~2017 (8 years ago) Views: 554 views Source: https://www.quora.com/Which-database-is-best/answer/Naomi-Amethyst-1
Answer
For what? That’s like going into a workshop and asking “Which tool is best?” — they do different things, are designed for different purposes.
What is stdout_fileno in Linux?
Credential: Software Engineer Posted: ~2019 (6 years ago) Views: 110 views Source: https://www.quora.com/What-is-stdout_fileno-in-Linux/answer/Naomi-Amethyst-1
Answer
111 views · [
1 of 2 answers](https://www.quora.com/What-is-stdout_fileno-in-Linux)
What is a pointer to a function?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 906 views Source: https://www.quora.com/What-is-a-pointer-to-a-function/answer/Naomi-Amethyst-1
Answer
In C, functions are blocks of code that get compiled down into assembly. When you have a function, the assembly for the function gets loaded into system memory along with the rest of the program when you start it.
When you call a function, what you are doing is a jump to a specific memory address (we’ll not go into stack frames here, as they aren’t particularly relevant to understanding this). When the function returns, the code jumps back to where it was executing before it jumped for the function call.
Now, a pointer is a variable that holds a memory address. In many cases, this memory address is the address of a value in memory. Or it can be the base address of an array.
But it can be the address of the start of a function’s assembly in memory. And you can jump to that address to call the function. A function pointer is a pointer to a function, and is a variable that contains the address of the start of a function.
My mom asked me for the password to my phone, but I don't want to give it to her. What should I do?
Posted: ~2019 (6 years ago) Views: 985 views Source: https://www.quora.com/My-mom-asked-me-for-the-password-to-my-phone-but-I-dont-want-to-give-it-to-her-What-should-I-do/answer/Naomi-Amethyst-1
Answer
A good password is one that is sufficiently strong (not a dictionary word, or a manipulation of one, not any personal information, preferably more than 8 characters in length), used for a single purpose (not shared between, for example, your phone and your e-mail), and known only to you. Passwords that do not meet these criteria should be changed as soon as possible.
If you must, give the current password to her. It is now no longer a good password and is instead a compromised password, so change it. Repeat as necessary.
What do you mean by recursion in C and also explain its advantages and disadvantages?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 6K views Source: https://www.quora.com/What-do-you-mean-by-recursion-in-C-and-also-explain-its-advantages-and-disadvantages/answer/Naomi-Amethyst-1
Answer
Recursion is possible in any language that implements reentrant functions. That is, any language that allows a function to be called while it is already executing that function.
Recursion comes in a few varieties. The most common form is Direct Recursion, which is where a function calls itself within the function’s body. For example:
void print_to(int n) {
if (n == 0) {
return;
}
print_to(n - 1);
printf("%d\n", n);
}
Which, when you call it with print_to(10) you get:
1
2
3
4
5
6
7
8
9
10
Recursion can also be Tail Recursion, which is where a the recursion happens at the very end of the function. For example:
void print_down_from(int n) {
if (n == 0) {
return;
}
printf("%d\n", n);
print_down_from(n - 1);
}
Which, if you call it with print_down_from(10) you get:
10
9
8
7
6
5
4
3
2
1
The opposite of Direct Recursion is Mutual Recursion (sometimes Indirect Recursion). This is when two (or more) different functions call each other. For example:
void print_odd(int n);
void print_even(int n);
void print_odds_evens_to(int n) {
if (n % 2 == 0) {
print_even(n);
} else {
print_odd(n);
}
}
void print_odd(int n) {
print_even(n - 1);
printf("Odd: %d\n", n);
}
void print_even(int n) {
if (n == 0) {
return;
}
print_odd(n - 1);
printf("Even: %d\n", n);
}
Which, if you call it with print_odds_evens_to(10) you get:
Odd: 1
Even: 2
Odd: 3
Even: 4
Odd: 5
Even: 6
Odd: 7
Even: 8
Odd: 9
Even: 10
In recursion, you always need a Base Case. This is where the recursion stops. Otherwise it would go on calling itself forever (or until your program ran out of stack space). In the above, the base case was when n == 0, we return without doing anything.
Recursion can be useful for processing recursive data structures. Things like trees and graphs are inherently recursive, and in some cases it makes sense to write the processing code recursively.
Internally, most languages implement recursion with a stack data structure, which is also what most languages use to allow functions to be reentrant.
For some problems, often loops can be more straightforward, and don’t use the stack space that recursion uses. If the resources aren’t an issue, write it in whichever way makes it more readable for the problem at hand.
As the quote goes, “To understand recursion, you must first understand recursion. You must first understand recursion, to understand recursion.”
My mother wants me to give her my passwords, especially for Facebook. I don’t want to. I am a 24-year-old woman. What do I do?
Posted: ~2019 (6 years ago) Views: 243 views Source: https://www.quora.com/My-mother-wants-me-to-give-her-my-passwords-especially-for-Facebook-I-don%E2%80%99t-want-to-I-am-a-24-year-old-woman-What-do-I-do/answer/Naomi-Amethyst-1
Answer
Tell her it is a violation of Facebook’s Terms of Service that you are contractually obligated to abide:
- Not share your password, give access to your Facebook account to others, or transfer your account to anyone else (without our permission).
You will find similar language in just about any online service’s terms of service. If she wants to use Facebook or another service, she must create her own account.
Now, as to the more social issue here: This is totally inappropriate for her to ask. It’s inappropriate to ask a minor, let alone an adult. Tell her no, and tell her that it is inappropriate for her to even ask. Don’t let her drag you into “what have you got to hide” or anything like that. It’s a social taboo, it’s violation of a contract, it could very well get your account terminated.
If she brings it up again, just refuse to discuss or entertain the idea.
How can we sequence number generator in cassandra? It should be a number or long not UUID format
Credential: Site Reliability Architect Posted: Updated 8y Views: 6.9K views Source: https://www.quora.com/How-can-we-sequence-number-generator-in-cassandra-It-should-be-a-number-or-long-not-UUID-format/answer/Naomi-Amethyst-1
Answer
Why do you need a sequence number in this case? If it is a simple ID, then a random uuid should work. If it is for sorting, a timeuuid would work. If it really needs to be sequential without gaps, then perhaps it isn’t something you should be using Cassandra for because generating sequential numbers without gaps is not something a distributed system can easily do.
That being said, if you absolutely need something like this, you can create a table like such:
CREATE TABLE sequence (name text, num int, PRIMARY KEY (name));
INSERT INTO sequence (name, num) VALUES ('my_sequence', 0);
Then when you want a sequence number, try something like this:
int genSequenceNumber(String name) {
static PreparedStatement select = session.prepare("SELECT num FROM sequence WHERE name = ?;").setConsistencyLevel(ConsistencyLevel.LOCAL_ONE);
static PreparedStatement update = session.prepare("UPDATE sequence SET num = ? WHERE name = ? IF num = ?;").setConsistencyLevel(ConsistencyLevel.SERIAL);
do {
ResultSet selectResultSet = session.execute(select.bind(name));
int currentSequence = selectResultSet.getInt("num");
int newSequence = currentSequence + 1;
ResultSet updateResultSet = session.execute(update.bind(newSequence, name, currentSequence));
} while(updateResultSet == null || updateResultSet.getBool("[applied]") == false);
return newSequence;
}
Keep in mind that this is an antipattern in Cassandra and there is almost certainly a better way to do what you want to do avoiding sequence numbers. The above code has not been tested. It will cause a lot of compaction if used excessively. It will also cause hotspots in the cluster since the sequence number field will end up on a specific partition. It requires several round-trips in your Cassandra cluster, so it will not be fast, either.
Furthermore, keep in mind that while the above will generate sequential numbers without gaps, it is then up to the application to make sure that the numbers are then used. If the application encounters an error writing to Cassandra, or crashes, or the machine it is on dies before it can use the number, you will still have gaps in the sequence, since Cassandra will have “allocated” that number to the application, but the application never used it, and since it is not part of an ACID transaction, you cannot say that there will not be gaps.
Can any one write the code that displays all the numbers from 0 to 10 while skipping the multiple of 3 and 7 in descending order used for a loop?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 134 views Source: https://www.quora.com/Can-any-one-write-the-code-that-displays-all-the-numbers-from-0-to-10-while-skipping-the-multiple-of-3-and-7-in-descending-order-used-for-a-loop/answer/Naomi-Amethyst-1
Answer
for(k in a=[10,8,5,4,2,1,0])console.log(a[k])
Alternatively:
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]+(+(!+[]+!+[]+[+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+[+!+[]])+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+(![]+[])[+!+[]]+([]+[])[(![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(!![]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]()[+!+[]+[+!+[]]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+(!![]+[])[+[]]+(+(+!+[]+[+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+[+!+[]])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]+!+[]])()+[])[+[]]+[+!+[]]+[+[]]+[[]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]([[]])+[]+[!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]+!+[]]+[[]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]([[]])+[]+[!+[]+!+[]+!+[]+!+[]+!+[]]+[[]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]([[]])+[]+[!+[]+!+[]+!+[]+!+[]]+[[]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]([[]])+[]+[!+[]+!+[]]+[[]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]([[]])+[]+[+!+[]]+[[]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]([[]])+[]+[+[]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+([][[]]+[])[+[]]+([][[]]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(+(!+[]+!+[]+[+!+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+!+[]+[+!+[]])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]])()([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+(!![]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(+(!+[]+!+[]+[+!+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+!+[]+[+!+[]])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]])()(([]+[])[([![]]+[][[]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]]()[+[]])[+[]]+[!+[]+!+[]+!+[]+!+[]+!+[]]+([][[]]+[])[!+[]+!+[]])+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(+(+!+[]+[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+[!+[]+!+[]]+[+[]])+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]+(![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]+(![]+[])[+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+(!![]+[])[+[]]+(+(+!+[]+[+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+[+!+[]])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]+!+[]])()+[])[+[]]+(+(!+[]+!+[]+[+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+[+!+[]])+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+([][[]]+[])[+[]]+([][[]]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(+(!+[]+!+[]+[+!+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+!+[]+[+!+[]])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]])()([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+(!![]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(+(!+[]+!+[]+[+!+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+!+[]+[+!+[]])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]])()(([]+[])[([![]]+[][[]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]]()[+[]])[+[]]+[!+[]+!+[]+!+[]+!+[]+!+[]]+([][[]]+[])[!+[]+!+[]])+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]])()
What 3 parts make up the CPU?
Posted: ~2018 (7 years ago) Views: 5.3K views Source: https://www.quora.com/What-3-parts-make-up-the-CPU/answer/Naomi-Amethyst-1
Answer
There are a lot more than three parts of a modern CPU.
However, if you had to have exactly three, what most textbooks for introduction to computer architecture classes say is that a CPU has an ALU (arithmetic/logic unit) that is responsible for performing all arithmetic operations as well as all logical operations, a register file which is responsible for storing all of the named registers (which store the working set of data), and the control unit (sometimes called “controller” or “control plane”) which is responsible for decoding the instructions into control signals for the ALU and register file (usually by sending the addresses of the two read registers and the address of the write register, along with a write-enable control line to the register file, and a mode select control lines to the ALU).
However, this ignores the MMU/TLB, the fact that the distinction between the ALU and control unit can become a bit fuzzy when we talk about modern CPUs with large complex pipelines, the various caches, I/O (memory mapped or otherwise), the clock, pipeline registers, and a number of other things.
What are the pros and cons, except for individual software preferences, of running, on older hardware, a modern lite version of Linux vs. running an older Windows version if the 2 alternatives run with similar performance?
Credential: Site Reliability Architect Posted: ~2020 (5 years ago) Views: 289 views Source: https://www.quora.com/What-are-the-pros-and-cons-except-for-individual-software-preferences-of-running-on-older-hardware-a-modern-lite-version-of-Linux-vs-running-an-older-Windows-version-if-the-2-alternatives-run-with-similar/answer/Naomi-Amethyst-1
Answer
Well, first off, if it’s connected to the Internet, you want a modern operating system or you are opening yourself to security holes.
Windows 10 is the only version of Windows still supported (unless you have extended support via your enterprise licensing). That means that security flaws found in Windows 8 or 7 or older are no longer patched. And security flaws are found regularly.
By the same token, I would not recommend running an old version of Linux if it is connected to the Internet, either. Note, however, that “light” versions of Linux can still be up to date. The latest Linux kernel still runs on older systems (and a plethora of other machines of lesser capability).
If you do not connect the machine to the Internet, and you just want to use your own programs offline, pick whichever OS that supports the applications you want to run?
How successful is AWS in increasing its business in the enterprise side ?
Credential: Site Reliability Architect10y Posted: ~2015 (10 years ago) Views: 25 views Source: https://www.quora.com/How-successful-is-AWS-in-increasing-its-business-in-the-enterprise-side/answer/Naomi-Amethyst-1
Answer
Yes.
What is the sum of x^3 + y^3 if x+y=5 & xy=1?
Posted: ~2019 (6 years ago) Views: 335 views Source: https://www.quora.com/What-is-the-sum-of-x-3-y-3-if-x-y-5-xy-1/answer/Naomi-Amethyst-1
Answer
\begin{align}x+y&=5\\xy&=1\\y&=5-x\\x(5-x)&=1\\x^2-5x+1&=0\\x&=\frac{5\pm\sqrt{(-5)^2-4}}{2}\\x&=\frac{5\pm\sqrt{21}}{2}\\y&=5-x\\y&=5-\frac{5\pm\sqrt{21}}{2}\\x^3+y^3&=(\frac{5\pm\sqrt{21}}{2})^3+(5-\frac{5\pm\sqrt{21}}{2})^3\\&=\frac{(5\pm\sqrt{21})^3}{8}+(5-\frac{5\pm\sqrt{21}}{2})^3\end{align}
More simplification can be done, but I’ll leave that up to you. Ultimately, you should get something like:
Write a program that asks the user to type 10 integers. The program must compute how many even and odd numbers were entered by using loops?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 2.5K views Source: https://www.quora.com/Write-a-program-that-asks-the-user-to-type-10-integers-The-program-must-compute-how-many-even-and-odd-numbers-were-entered-by-using-loops-1/answer/Naomi-Amethyst-1
Answer
int main(){int a=0,b=0,c,d;printf("Enter 10 numbers:\n");for(;b
<10;b++){for(c=getchar();c>='0'&&c<='9';c=getchar())d=c;a+=d
%2;}printf("Odd: %d\nEven: %d\n",a,10-a);}
Is 3.333333 repeated a number?
Posted: ~2017 (8 years ago) Views: 248 views Source: https://www.quora.com/Is-3-333333-repeated-a-number/answer/Naomi-Amethyst-1
Answer
No. 3.333333 = \frac{3333333}{1000000}
However, 3.33\overline{3} = 3\frac{1}{3}, and is a repeated number.
Why are we using gzip and not other algorithms for compression in the server-client?
Posted: ~2018 (7 years ago) Views: 481 views Source: https://www.quora.com/Why-are-we-using-gzip-and-not-other-algorithms-for-compression-in-the-server-client/answer/Naomi-Amethyst-1
Answer
Because gzip is fast.
Not as fast as something lightweight like lzop, but not nearly as slow as bzip2 or xz (lzma) or other compression algorithms. When you have to compress every response, being fast is important.
Because gzip is free. (or more importantly, because gzip is widely-supported)
When you are picking an algorithm to use for a web standard such as HTTP compression, you want something that can be easily implemented by all browsers. Because gzip is free and widely-supported, it was an obvious choice.
Is a SELECT query that returns multiple fields from an AWS RDS instance equivalent to one I/O operation?
Posted: ~2015 (10 years ago) Views: 362 views Source: https://www.quora.com/Is-a-SELECT-query-that-returns-multiple-fields-from-an-AWS-RDS-instance-equivalent-to-one-I-O-operation/answer/Naomi-Amethyst-1
Answer
RDS I/O operations are at the disk level, not the query level. One query may make many I/O requests, or none at all if everything is in memory. But it is unlikely to just make one I/O request because it will need to look at the index, then fetch the block(s), and that is if you aren't joining or anything like that.
Best way is probably to just test it and look in CloudWatch to see how many I/O operations you are making under test conditions, and then add some buffer room. Or just overprovision and see what real production looks like and then change it up or down as needed.
What is the best way to test an even number to find out if it is prime?
Posted: ~2017 (8 years ago) Views: 381 views Source: https://www.quora.com/What-is-the-best-way-to-test-an-even-number-to-find-out-if-it-is-prime/answer/Naomi-Amethyst-1
Answer
def isEvenPrime?(number)
number == 2
end
Why are operating systems usually slow the first days after a large update?
Credential: Software Engineer Posted: ~2015 (10 years ago) Views: 110 views Source: https://www.quora.com/Why-are-operating-systems-usually-slow-the-first-days-after-a-large-update/answer/Naomi-Amethyst-1
Answer
I have never seen that with my primary operating systems: various distributions of Linux and Illumos. They are always either the same speed as before or sometimes faster.
Which professors at the University of Illinois at Urbana–Champaign would you recommend to take classes from, and why?
Posted: ~2019 (6 years ago) Views: 677 views Source: https://www.quora.com/Which-professors-at-the-University-of-Illinois-at-Urbana-Champaign-would-you-recommend-to-take-classes-from-and-why/answer/Naomi-Amethyst-1
Answer
This information is a bit dated, but this is what I remember from the CS department circa 2008–2012-ish.
- Michael Woodley - An excellent professor who has a lot of real world experience in the field in addition to the academic smarts. Could tell stories about how things actually worked in the industry. Probably prepared me more for the industry than anyone else.
- Cinda Heeren - Incredibly nice professor who loves teaching and always has an open door.
- Lawrence Angrave - Very smart and willing to work with students.
- Craig Zilles - I took CS125 (Intro for majors) from him. I wish I had had the opportunity to take a more advanced class from him, because while chatting with him after class, we dived deep into discussion around the JVM’s JIT optimization engine and strategies there, and that’s something I would have liked to discuss more in a more advanced class.
- Margaret Fleck - Did a very good job at explaining the mathematics underpinning a lot of CS.
- Jeff Erickson - Very good algorithms professor.
Is there a Linux OS for mobile phones? If not, will one ever be developed?
Credential: Site Reliability Architect Posted: ~2018 (7 years ago) Views: 134 views Source: https://www.quora.com/Is-there-a-Linux-OS-for-mobile-phones-If-not-will-one-ever-be-developed/answer/Naomi-Amethyst-1
Answer
Android is a distribution of Linux, though a bit specialized.
Which two consecutive positive odd numbers have a product of 99?
Posted: ~2019 (6 years ago) Views: 373 views Source: https://www.quora.com/Which-two-consecutive-positive-odd-numbers-have-a-product-of-99/answer/Naomi-Amethyst-1
Answer
Let 2k+1 and 2k+3 be the consecutive positive odd numbers.
So, we do some algebra:
\begin{align}(2k+1)(2k+3) &= 99\\4k^2 + 8k + 3 &= 99\\4k^2 + 8k - 96 &= 0\\k &= \frac{-8 \pm \sqrt{64 + 1536}}{8}\\k &= \frac{-8 \pm \sqrt{1600}}{8}\\k &= \frac{-8 \pm 40}{8}\\k &= -1 \pm 5\\k &= 4\text{ or }-6\end{align}
Because k=-6 is negative, we can disregard that. So, plugging k=4 into our two numbers: 2 \times 4 + 1 = 9 and 2 \times 4 + 3 = 11.
We can test that our solution is correct: 9 \times 11 = 99.
How do you convert ln to log?
Posted: ~2019 (6 years ago) Views: 14K views Source: https://www.quora.com/How-do-you-convert-ln-to-log/answer/Naomi-Amethyst-1
Answer
\frac{ln(x)}{ln(y)} = log_y(x)
The sum of two numbers is 7. If one number is subtracted from the other, the result is 5. What are the two numbers?
Posted: ~2019 (6 years ago) Views: 89 views Source: https://www.quora.com/The-sum-of-two-numbers-is-7-If-one-number-is-subtracted-from-the-other-the-result-is-5-What-are-the-two-numbers/answer/Naomi-Amethyst-1
Answer
So if we let a be the first number and b be the second number, we have a system of two equations:
\begin{align}a + b &= 7\\a - b &= 5\end{align}
This can then be solved algebraically:
\begin{align}a &= 7 - b\\(7 - b) - b &= 5\\7 - 2b &= 5\\2b + 5 &= 7\\2b &= 2\\b &= 1\\a + 1 &= 7\\a &= 6\end{align}
So the two numbers are 1 and 6. 6 + 1 = 7 and 6 - 1 = 5.
What is the constant in πuv+4u+6v?
Posted: ~2018 (7 years ago) Views: 147 views Source: https://www.quora.com/What-is-the-constant-in-%CF%80uv-4u-6v/answer/Naomi-Amethyst-1
Answer
4 and 6 are always constants. \pi usually refers to the circle constant, and is thus also usually a constant. More context is needed around u and v to determine if they are constants or variables.
Comments
A coefficient is a constant multiplier to a variable.
What are the necessities of a compiler?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 192 views Source: https://www.quora.com/What-are-the-necessities-of-a-compiler/answer/Naomi-Amethyst-1
Answer
A compiler usually has four or more components or phases of translation:
The lexer is responsible for turning text into meaningful tokens. This process is often called lexing or scanning. It turns something like:
if (foo + 1 >= 20) {
return;
}
into an array or stream of tokens like:
[
T_IF, T_OPAREN, T_LABEL("foo"), T_PLUS,
T_INTLITERAL(1), T_GTE, T_INTLITERAL(20),
T_CPAREN, T_OBRACE, T_RETURN, T_SEMICOLON,
T_CBRACE
]
The parser is responsible for taking the token stream and converting it into an abstract syntax tree or AST. This process is often called parsing or recognizing. It turns the above into something like:
(IfStatement){
condition: (GreaterThanOrEqualsExpression){
left: (AddExpression){
left: (LabelExpression){
label: "foo"
},
right: (IntegerLiteralExpression){
value: 1
}
},
right: (IntegerLiteralExpression){
value: 20
}
},
body: (Block){
statements: [
(ReturnStatement) {}
]
}
}
The optimizer is responsible for taking the AST and converting it into a more optimized AST. This process is called optimization or optimizing. It turns the above into something like:
(IfStatement){
condition: (GreaterThanOrEqualsExpression){
left: (LabelExpression){
label: "foo"
},
right: (IntegerLiteralExpression){
value: 19
}
},
body: (Block){
statements: [
(ReturnStatement) {}
]
}
}
The code generator is responsible for taking the AST and generating target-specific code. This is usually some form of assembly. This process is called code generation. It turns the above into something like:
ld r1, foo
ldi r2, 0x13
cmp r1, r2
jl ifend
ret
ifend:
Then there is usually a register mapping pass over the assembly, where real registers are allocated to the virtual registers, and virtual registers that cannot be mapped to a real register are replaced with register spills to memory, usually the stack. Labels are allocated space either on the stacks of functions or globally, depending on scope, unless they can be converted to immediate values by the optimizer.
Then the assembler is responsible for translating the assembly into machine code. This is called assembling.
Then the linker is responsible for linking all of the translation units together. This process is called linking.
Finally a valid executable is written out.
In more complex compilers, there may be more stages, especially of optimization, since that can happen at many different layers.
A 8*8 "magic square" is constructed in which each of the 64 squares contains one of the integers in the set S= {1,2,3,…, 64}. The numbers in each row and column have the same sum. What is the entire sum of the square?
Posted: Updated 8y Views: 1.5K views Source: https://www.quora.com/A-8-8-magic-square-is-constructed-in-which-each-of-the-64-squares-contains-one-of-the-integers-in-the-set-S-1-2-3-64-The-numbers-in-each-row-and-column-have-the-same-sum-What-is-the-entire-sum-of-the-square/answer/Naomi-Amethyst-1
Answer
The total sum over the set S is 2080. If you sum up every column all together, the sum will be 2080:
c_1 + c_2 + c_3 + c_4 + c_5 + c_6 + c_7 + c_8 = 2080
If you wanted to get the sum of each row or column, you can continue: Since there are 8 columns that each sum to the same value, we can say:
c_1 = c_2 = c_3 = c_4 = c_5 = c_6 = c_7 = c_8
Now, since they are all the same, we can substitute x for all of them:
\begin{align}x + x + x + x + x + x + x + x &= 2080 \\ 8x &= 2080 \\ x &= \frac{2080}{8} \\ x &= 260\end{align}
Why is 2 a prime number? It seems like there's something fundamentally wrong with the definition of prime, since 2 is the only even number included. Would the math work (better/not at all) if two wasn't on the list?
Posted: ~2017 (8 years ago) Views: 1.5K views Source: https://www.quora.com/Why-is-2-a-prime-number-It-seems-like-theres-something-fundamentally-wrong-with-the-definition-of-prime-since-2-is-the-only-even-number-included-Would-the-math-work-better-not-at-all-if-two-wasnt-on-the-list/answer/Naomi-Amethyst-1
Answer
Prime numbers are useful to Mathematics because they are the foundation — the multiplicative building blocks of other numbers.
Every positive whole number can be written as a unique product of primes.
—The Fundamental Theorem of Arithmetic.
In order for that to work, 2 must be included in primes, or none of the even numbers would be accessible. Let’s try a few numbers to see how this works:
71 = 71
68 = 2 \times 2 \times 17
98 = 2 \times 7 \times 7
1 = \displaystyle \prod_{k \in \emptyset} k
183 = 3 \times 61
This works for all positive whole numbers, and is why primes are useful in math.
Comments
This concept could be generalized to other sets such as polynomials.
So I'm looking at primes wrong, then. Fundamental indivisiblity is not really what they're about at all, then?
with all the prime numbers can you create 1? 1 is the first building block of all the numbers.
Why could statement III be used as implementation code in the question shown in the picture?
Credential: Software Engineer Posted: ~2013 (12 years ago) Views: 434 views Source: https://www.quora.com/Why-could-statement-III-be-used-as-implementation-code-in-the-question-shown-in-the-picture/answer/Naomi-Amethyst-1
Answer
Based on the available spec, write() really should take in a parameter java.io.OutputStream or some other object to write to, since the spec does not specify where to write the data.
In most real applications, you don't want your objects themselves writing directly to the System.out or System.err, because that's not flexible.
What if I wanted to write it to a network socket, a file, a buffer, or my own custom object that extends java.io.OutputStream?
Another thing is that in Java, the convention is for methods that simply return field to be named getFieldNameHere, so it really should be, by Java convention, getMonth(), getDay(), and getYear()
With that concern out of the way, answer I is technically correct, and about equal with answer II, but if you were to store the fields differently internally, you would have to update I but not II, so II has the advantage.
Answer III is technically correct, but toString()'s contract is typically far looser than most other methods. This is, in part, because Java defines the contract very loosely in Object: http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#toString(). Here, Java defines toString() as simply being a human readable textual representation of the object.
If you are OK with the contract of write() being as loose as toString()'s, then it's fine, but I would personally not rely on toString() for the implementation of write().
Comments
I don't think "flexibility" is always important. If you know that you will not be writing to a file, then it doesn't make sense for all your functions to have a provision to write to a file.
Granted that code re-use is important, but excessively "reuseable" code leads to the FactoryFactoryFactory nonsense that Java is infamous for.
What is recursion in c?
Credential: Software Engineer Posted: ~2017 (8 years ago) Views: 8.4K views Source: https://www.quora.com/What-is-recursion-in-c-1/answer/Naomi-Amethyst-1
Answer
Recursion is possible in any language that implements reentrant functions. That is, any language that allows a function to be called while it is already executing that function.
Recursion comes in a few varieties. The most common form is Direct Recursion, which is where a function calls itself within the function’s body. For example:
void print_to(int n) {
if (n == 0) {
return;
}
print_to(n - 1);
printf("%d\n", n);
}
Which, when you call it with print_to(10) you get:
1
2
3
4
5
6
7
8
9
10
Recursion can also be Tail Recursion, which is where a the recursion happens at the very end of the function. For example:
void print_down_from(int n) {
if (n == 0) {
return;
}
printf("%d\n", n);
print_down_from(n - 1);
}
Which, if you call it with print_down_from(10) you get:
10
9
8
7
6
5
4
3
2
1
The opposite of Direct Recursion is Mutual Recursion (sometimes Indirect Recursion). This is when two (or more) different functions call each other. For example:
void print_odd(int n);
void print_even(int n);
void print_odds_evens_to(int n) {
if (n % 2 == 0) {
print_even(n);
} else {
print_odd(n);
}
}
void print_odd(int n) {
print_even(n - 1);
printf("Odd: %d\n", n);
}
void print_even(int n) {
if (n == 0) {
return;
}
print_odd(n - 1);
printf("Even: %d\n", n);
}
Which, if you call it with print_odds_evens_to(10) you get:
Odd: 1
Even: 2
Odd: 3
Even: 4
Odd: 5
Even: 6
Odd: 7
Even: 8
Odd: 9
Even: 10
In recursion, you always need a Base Case. This is where the recursion stops. Otherwise it would go on calling itself forever (or until your program ran out of stack space). In the above, the base case was when n == 0, we return without doing anything.
Recursion can be useful for processing recursive data structures. Things like trees and graphs are inherently recursive, and in some cases it makes sense to write the processing code recursively.
Internally, most languages implement recursion with a stack data structure, which is also what most languages use to allow functions to be reentrant.
As the quote goes, “To understand recursion, you must first understand recursion. You must first understand recursion, to understand recursion.”
Comments
your method of making understand is fabulous
Can I, with reasonable security, use a computer and a VPN to pay bills and do banking while using wi-fi during a cruise?
Posted: ~2017 (8 years ago) Views: 119 views Source: https://www.quora.com/Can-I-with-reasonable-security-use-a-computer-and-a-VPN-to-pay-bills-and-do-banking-while-using-wi-fi-during-a-cruise/answer/Naomi-Amethyst-1
Answer
You probably don’t need a VPN at all. Modern browsers and websites use TLS to secure the connection so that no one between can modify, monitor, or hijack the connection.
You can tell that you have established a secure TLS link by verifying that the domain (part of the URL after https:// and before the next /) is what you expect it to be and that the first part of the URL is https:// and that there is a green lock near the URL.
In how many ways can 3 non-distinct prizes be distributed among n students. (A student can get atmost 1 prize)?
Posted: ~2017 (8 years ago) Views: 1.5K views Source: https://www.quora.com/In-how-many-ways-can-3-non-distinct-prizes-be-distributed-among-n-students-A-student-can-get-atmost-1-prize/answer/Naomi-Amethyst-1
Answer
Let’s start by asking a simpler question:
How many ways can 1 non-distinct prize be distributed among n students? I think we can both agree that there are n ways to do that: a way for each student.
Now, let’s see about 2 non-distinct prizes. Well, if we think about it, we can distribute one of those prizes n different ways. Now, we can’t distribute the second prize to the same student, so we have n - 1 students to give that prize to. So, n \times (n - 1) ways.
But we’re double counting here since you said non-distinct prizes, giving student A prize 1 and student B prize 2 is the same as giving student A prize 2 and student B prize 1. So we need to divide by 2.
This gives us:
\frac{n \times (n - 1)}{2}
So, let’s go about distributing that third prize. Using the logic from before, we can get n \times (n - 1) \times (n - 2).
But now, we’re counting six times as many as we should be:
Student A getting prize 1, B getting 2, and C getting 3
is the same as A getting 1, B getting 3, and C getting 2
is the same as A getting 2, B getting 1, and C getting 3
is the same as A getting 2, B getting 3, and C getting 1
is the same as A getting 3, B getting 1, and C getting 2
is the same as A getting 3, B getting 2, and C getting 1
So, our final formula is:
\frac{n \times (n - 1) \times (n - 2)}{6} = \frac{n^3 - 3n^2 + 2n}{6} = \frac{n^3}{6} - \frac{n^2}{2} + \frac{n}{3}
How can I find the maximum of two numbers without using if-else or any other comparison operator?
Posted: ~2017 (8 years ago) Views: 2.2K views Source: https://www.quora.com/How-can-I-find-the-maximum-of-two-numbers-without-using-if-else-or-any-other-comparison-operator/answer/Naomi-Amethyst-1
Answer
#include <stdio.h>
int max(int a, int b) {
int p[] = {a, b};
int d = a - b;
unsigned int u = d;
return *(p + (u >> (sizeof(unsigned int) * 8 - 1)));
}
int main(int argc, char **argv) {
int a = atoi(argv[1]), b = atoi(argv[2]);
printf("max(%d, %d) = %d\n", a, b, max(a, b));
return 0;
}
Compile and run it:
$ gcc -o max max.c
$ ./max 5 10
max(5, 10) = 10
$ ./max 10 5
max(10, 5) = 10
$ ./max 10 50000
max(10, 50000) = 50000
$ ./max 10002 50000
max(10002, 50000) = 50000
$ ./max 100022 50000
max(100022, 50000) = 100022
Can you rank the top 10 language pairs by interpretation (not translation) demand globally (for example, English - Chinese)?
Posted: ~2017 (8 years ago) Views: 100 views Source: https://www.quora.com/Can-you-rank-the-top-10-language-pairs-by-interpretation-not-translation-demand-globally-for-example-English-Chinese/answer/Naomi-Amethyst-1
Answer
- Javascript -> x86_64
- Java Byte Code -> x86_64
- Python -> x86_64
- Ruby -> x86_64
- PHP -> x86_64
- Perl -> x86_64
- Lua -> x86_64
- TeX -> PNG
- SQL -> Query Plan
- Bash -> Linux System Calls
What are the tasks in the boot process when a computer starts up?
Posted: ~2018 (7 years ago) Views: 5.4K views Source: https://www.quora.com/What-are-the-tasks-in-the-boot-process-when-a-computer-starts-up/answer/Naomi-Amethyst-1
Answer
The computer first performs a Power-On Self Test (POST) that is controlled by the BIOS, which is built into a chip on your motherboard.
The BIOS then needs to find a disk drive that it can load the operating system (OS) from and transfer control to the OS. The problem is that the BIOS is generic and doesn’t know any specifics of what OS or how the OS is laid out on the disk.
So, it assumes that there will be a Master Boot Record (MBR) at the beginning of at least one of the disks. The MBR has 446 bytes of space for the operating system to install what is known as a “bootloader,” which is a small executable that knows how the OS uses the disks and what the OS expects to be already set up. So, when the BIOS finds the MBR, it will load those 446 bytes off of the disk into memory and transfer control to the bootloader.
The bootloader will then need to read the disk to find out where the kernel image is stored. To do this, it might first need to read more bootloader code off the disk if the bootloader is bigger than 446 bytes. This is what is called a staged bootloader. Once the bootloader has found the kernel image, and potentially also an initial ramdisk for early OS initialization, it will load the kernel image (and initial ramdisk, if applicable) into system memory, and will transfer control over to the kernel.
The kernel will then do a scan of hardware to figure out what the computer has attached to it, load any modules or drivers necessary, initialize all of the various hardware components, set up memory management, and transition the CPU to protected mode, which will protect the OS from normal programs.
The kernel will then locate and execute the initialization program for the userland (programs that run inside the operating system). On Linux and other Unixes, this program is called init, and is responsible for starting all of the rest of the programs that are necessary or desired for the system to operate, including the graphical login prompt or the text-based login prompt. I am less familiar with Windows, but I’d bet that the Windows equivalent is responsible for starting all of the system services, and the graphical login prompt.
The initialization program usually will be responsible for configuring networking, mapping any non-boot disk drives, and starting any services configured to start with the system.
A,B, and C together can do a piece of work in 15 days, B alone can do it in 30 days and C alone can do it in 30 days in how many days will A alone do the work?
Posted: ~2017 (8 years ago) Views: 210 views Source: https://www.quora.com/A-B-and-C-together-can-do-a-piece-of-work-in-15-days-B-alone-can-do-it-in-30-days-and-C-alone-can-do-it-in-30-days-in-how-many-days-will-A-alone-do-the-work/answer/Naomi-Amethyst-1
Answer
Your mathematics instructor most likely wants you to lay it out like:
15(A + B + C) = 30B = 30C
A + B + C = 1
and assume that the piece of work scales linearly.
Solving these equations simultaneously, you get:
A = 0, B = \frac{1}{2}, C = \frac{1}{2} indicating that A did 0% of the work, and B and C each did half of the work. So, it will never get done if A alone worked on it.
—
Now, in the real world, it doesn’t work like that. Work does not always scale linearly. In fact, in many cases, the collaboration overhead can actually make work take longer when you add more people rather than take shorter.
What file storage system does AWS block storage use?
Posted: ~2013 (12 years ago) Views: 8.2K views Source: https://www.quora.com/What-file-storage-system-does-AWS-block-storage-use/answer/Naomi-Amethyst-1
Answer
Block storage is a lower-level concept than file storage. Block storage is like a disk -- it provides blocks, not files. Most traditional file systems will work on top of any block storage device.
AWS provides two relevant products:
- EBS -- Elastic Block Store -- which provides persistent block storage to EC2 instances. You can put whatever filesystem you want on these devices. They look just like hard drives (block devices).
- S3 -- Simple Storage Service -- which provides persistent object (file) storage via an API accessible to both EC2 instances and non-EC2 instances. You can store files and retrieve files, but you cannot format it with a filesystem.
If you are asking about how EBS works behind the scenes, that's not really well-known, nor is it necessary to know. In programming terms, EBS provides an interface. The implementation, so long as what they present to you is the same, is free to change.
What I have been able to gather, though, about how EBS works behind the scenes is this:
- EBS is provided to EC2 host machines by one or more dedicated links on a dedicated storage network. On the newer hosts, these links are 10G links.
- EBS is a replicated block device, meaning that your data is replicated to multiple physical hosts, so there is redundancy. In the event that your EBS host goes down, the EBS system will promote one of the replicas, and find another host to replicate your data to.
- EBS works in blocks of 16K. If you use a larger block size, then they will be split at the EBS layer, and if you use a smaller block size, then they will be merged at the EBS layer. For optimum performance, use a block size of 16K.
- Snapshotting is copy-on-write. This means that as soon as the API tells you the snapshot has started, any later changes will not be in the snapshot. This is useful to give you a consistent view.
- Snapshotting has to copy data off the disk. This will have an effect on the performance of the block device during that period.
(These are just some of the things I've learned throughout my time using EBS. Some of these came from time I spent at re:Invent, and some of them came from reading EBS outage reports)
If you are asking about how S3 works behind the scenes, again, not fully disclosed. It is a highly distributed, highly reliable service that stores objects (files).
At what speed does a computer calculate?
Posted: ~2018 (7 years ago) Views: 9.5K views Source: https://www.quora.com/At-what-speed-does-a-computer-calculate/answer/Naomi-Amethyst-1
Answer
It really depends on the computer. It also depends on which kinds of calculations you are performing.
The two main types of calculations that computers perform are integer arithmetic (integer operations) and floating-point arithmetic (floating-point operations).
In the terms of modern (x86_64) processors, integer arithmetic refers to any basic operation on whole numbers between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807 (or 0 to 18,446,744,073,709,551,615 if doing unsigned math). Floating-point arithmetic refers to any basic operation on real numbers between bounds of what can be represented in 64 bits (and isn’t quite as straight-forward to explain as integer arithmetic ranges).
As an example of a modern consumer-grade processor, the Intel Core i7 8700K can perform 217,980,000,000 integer operations per second, or 32,110,000,000 floating-point operations per second.
Do Americans generally believe being 5 minutes late is acceptable?
Posted: ~2017 (8 years ago) Views: 229 views Source: https://www.quora.com/Do-Americans-generally-believe-being-5-minutes-late-is-acceptable/answer/Naomi-Amethyst-1
Answer
Being late is not a good thing, obviously, but in corporate America, people tend to have meetings back-to-back. And very frequently the prior meeting runs over.
Generally, 5–7 minutes is the mark when someone might enter the room by saying “sorry, the last meeting ran over.”
Now, if you had already left, that shows great disrespect, and would likely annoy the person who was late, and who would have apologized had you been there when he got there.
Furthermore, you compounded the issue by asking/demanding an apology. That’s simply not done in American culture. There really is only one time when asking someone to apologize is acceptable, and that is when a child has committed a faux pas and the child’s own parent asks or tells the child to apologize to the person against whom the faux pas was committed.
If you feel you must let him know that you were offended or hurt, or felt disrespected by his tardiness, that’s fine to tell him: “I feel that you have shown a lack of respect for my time with your tardiness. In my culture, we value promptness.” At which point, the expectation is that he will apologize. But don’t directly ask for an apology.
Generally at the 10 minute mark is when I would attempt to contact the person for whom I am waiting. 5–10 minutes after the attempt to contact the person with no reply, and I’d leave.
How many factors does 100^{100} have? Answer: 201*201= 40401 (including 1) But how? I've not found it on Google.
Posted: ~2017 (8 years ago) Views: 101 views Source: https://www.quora.com/How-many-factors-does-100-100-have-Answer-201*201-40401-including-1-But-how-Ive-not-found-it-on-Google/answer/Naomi-Amethyst-1
Answer
Let’s get the prime factors for 100^{100}:
100^{100} = 2^{200} \times 5^{200}
Now, because all of the factors must be some combination of these, we can calculate the number of different factors:
Now, there are 201 different ways you could pick exponents for 2^{200}, since 0 is also a valid option. And there are 201 different ways you could pick exponents for 5^{200}, again since 0 is also a valid option.
So, we can multiply those together to get the total number of factors.
Finally, the factors of 100^{100} are:
\{ 2^x \times 5^y \mid \forall_{x \in \mathbb{Z}} \forall_{y \in \mathbb{Z}} 0 \le x \le 200 \land 0 \le y \le 200 \}
In the C programming language, can I move the file cursor while reading a file?
Posted: ~2017 (8 years ago) Views: 4.2K views Source: https://www.quora.com/In-the-C-programming-language-can-I-move-the-file-cursor-while-reading-a-file/answer/Naomi-Amethyst-1
Answer
The (off_t) lseek(int fd, off_t offset, int whence) system call allows you to reposition the file cursor. fd is the file descriptor, offset is the new offset relative to whence. whence is either SEEK_SET to be relative to the start of the file, SEEK_CUR to seek relative to the current cursor position, or SEEK_END to seek relative to the end of the file. lseek returns the new offset relative to the beginning of the file.
If you prefer to use FILE *s instead of file descriptors, fseek and fseeko are the buffered I/O equivalents.
Furthermore, you can use the (void *) mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) system call to map a file into memory. This doesn’t read the whole file into memory, but the OS makes it seem that way to your application. Then you can randomly access anywhere in the file without having to explicitly seek.
What is the full form of I.N.T.E.R.N.E.T?
Posted: ~2017 (8 years ago) Views: 44.7K views Source: https://www.quora.com/What-is-the-full-form-of-I-N-T-E-R-N-E-T/answer/Naomi-Amethyst-1
Answer
Internet is not an acronym. It is short for internetwork -- a network between networks. The internet is made up of links between many smaller networks.
Just like an interstate highway is a highway between states.
If a quarter of 60 is 15, what is a quarter of 64?
Credential: Site Reliability Architect (2013–present)8y Posted: ~2017 (8 years ago) Views: 555 views Source: https://www.quora.com/If-a-quarter-of-60-is-15-what-is-a-quarter-of-64/answer/Naomi-Amethyst-1
Answer
A quarter of 64 is 16 regardless of the value of a quarter of 60 is.
A quarter means to divide by 4 or multiply by \frac{1}{4} = 0.25.
