13

I'm trying to figure out what the sentence below means.

Write code that creates a list of all integers from 50 to the power of 300.

I'm struggling with the "from 50 to the power of 300" part.

I've been googling for an hour now, but I've never heard "to the power of 300" without a base.

What does that mean? From 50 to what number? Is it possible that the teacher made a mistake?

So we came up with another way on how to interpret that, and given our previous exercises, this probably makes the most sense:

Write code that creates a list of all integer digits from 50 to the power of 300.

This would be still a little ambiguous, however we could interpret that as first calculating 50^300 and then creating a list of integers that includes each digit of 50^300 individually.

ColleenV
  • 11,879
  • 11
  • 46
  • 85
nozmat aram
  • 149
  • 1
  • 7
  • 11
    Most likely they mean "all the digits of" rather than "all integers from", ie write 50^300 in decimal. The sentence doesn't make sense from an English/Maths point-of-view and I suspect there are a number of charitable interpretations of it, but this would be mine if you don't have the opportunity for clarification. – Dannie Feb 25 '21 at 14:10
  • @Dannie is almost certainly right. "From" is not in the sense of "from X to Y" but rather in the sense of "comes from" or "found within". This would be better expressed as "all the digits in the integer representation of". – CCTO Feb 25 '21 at 14:23
  • 2
    ***50 to the power of 300*** is just a very large number (probably way more than the number of atoms in the entire universe). But substituting a *slightly* smaller "large number", we'd have *[Please] list all integer digits from a million*, which obviously makes no real sense. We could *contrive* an interpretation based on the meaning ***starting from** a million*, but since there are infinitely many integers beyond 1,000,000, that doesn't make much sense. – FumbleFingers Feb 25 '21 at 14:32
  • 5
    I’m voting to close this question because it's asking us to analyse garbage text – FumbleFingers Feb 25 '21 at 14:33
  • 1
    As chasly points out, the problem currently asks you to generate an infinite list of integers. My first thought was that the question was missing a few words e.g. "up to 2" before "to the power of 300" but even this is asking for a list of around 2*10^90 elements which seems implausible. Something has definitely got very garbled somewhere along the line. You need to ask for clarification from teacher because rn there is no way to work out what they mean – Tristan Feb 25 '21 at 15:40
  • 2
    @nozmat aram - I think we should ask what level programmer you are. If you are a beginner or intermediate, this is not a week's homework. (1) Simply calculating the starting point needs you to write software that will handle such large integers. (2) To create a *list* (rather than simply counting) requires you to address arbitrarily large amounts of memory. This would involve modifying the operating system. All of this would make an excellent exercise for an advanced programmer although much of it would be pointless (I could give reasons). So, what level are you? – chasly - supports Monica Feb 25 '21 at 18:24
  • A possible interpretation would be "list all the different digits in the number 50^300". (If the accepted answer is correct, the list would be 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.) – alephzero Feb 25 '21 at 20:30
  • 3
    Is there some reason why you can't ask the person who wrote that sentence to clarify what they meant? – ColleenV Feb 25 '21 at 21:28
  • 1
    Broadly, that's meaningless in and of itself. Can you describe the context? Better still, can you quote or at least cite the source? – Robbie Goodwin Feb 25 '21 at 21:41
  • @Tristan It's not an infinite list; it's bounded by the number of bits allocated to the integer in memory. Its simply extremely large. See my answer for details. – nick012000 Feb 25 '21 at 21:59
  • @FumbleFingers In a computing context, there aren't an infinite number of integers since the maximum value is constrained by the number of bits allocated to them by memory. See my answer for details of how this applies to this question. – nick012000 Feb 25 '21 at 22:04
  • I might mean that you're supposed to generate all of the substrings in the decimal expansion of 50^300. – MackTuesday Feb 25 '21 at 22:15
  • Is the teacher French? @Dannie's interpretation would make more sense then since "from" and "of" are the same word in French, "de" (with some exceptions). – wjandrea Feb 25 '21 at 22:21
  • Can't this mean "a list of every integer from 50 to infinity, each raised to the power of 300"? E.g. something like this in Haskell: `map (^300) [50..]`. Many other languages also have support for arbitrary precision integers and infinite iterables in their standard libraries. Sure you can't compute the whole thing, but you can compute arbitrary far into the infinite list as long as you have enough time and memory. – Kolmar Feb 26 '21 at 00:41
  • Are you sure "power" wasn't capitalized as "Power"? If so, it would make sense. Otherwise, it's hard to see how the "from" and "to" match. – David Schwartz Feb 26 '21 at 02:15
  • 26
    Speaking as a university prof: *please, please, just ask for clarification if your homework assignment seems unclear* (rather than speculating wildly what the intent of a task with a minor typo is). Typos happen, and they are fixed extremely quickly. It's much more annoying to deal with the fallout of a bunch of students going on a hog chase of how to generate all integers larger than a certain value ... – xLeitix Feb 26 '21 at 06:55
  • 1
    My interpretation would be that you are being asked to calculate 50^300, then identify the unique integers in the form of a list. From @chasly-supportsMonica 's answer, the first 10 digits would give you: 4,9,0,3,6,5 with 9, 0 and 4 being repeated and thus ignored. 50^300 is an arbitrarily large number that has no further significance to the question – nzaman Feb 26 '21 at 08:27
  • 1
    @xLeitix - I already suggested this by implication in my answer which the OP has accepted. Following your comment, I have made your suggestion explicit in that answer. Wrt to the obvious typing error, the accidentally produced 'problem' is quite an interesting one and quite educational in terms of computer science. I may at some point formalise the fake problem and present it as a genuine problem on one of the computer SEs. With luck this will remove the discussion from here. – chasly - supports Monica Feb 26 '21 at 11:16
  • @nick012000: It's a bit irrelevant that any *actual* computer will be limited in terms of some maximum integer value that it can calculate / display / store. I already said 50 to the power of 300 is way more than the number of atoms in the (visible, not necessarily *entire*) universe. So even if we convert all the material in the universe into a computer whose only function is to identify the largest possible integer it can do anything with, that would still have to be a finite value. (But in my ***mind***, I can certainly conceive of adding 1 to whatever that value might be! :) – FumbleFingers Feb 26 '21 at 17:17
  • 1
    It's annoying to admit but dealing with the mistakes my professors made like this was a wonderful introduction to requirements gathering. You think this is bad. Try the real world where the scary powerful people don't even know what they want and still expect you to make it. Asking for clarification is part of "speaking truth to power". – candied_orange Feb 26 '21 at 18:24
  • @xLeitix, I wish you had written that as an answer, so it could have been upvoted :D – ilkkachu Feb 26 '21 at 21:43
  • I’m voting to close this question because the only person who can say for certain what this text means is the person that wrote it. – ColleenV Feb 27 '21 at 16:06
  • @nick012000 the code would still be code to provide an infinite list, it's just the practical implementations that would have a finite output – Tristan Mar 01 '21 at 09:57

8 Answers8

27

The way you have presented it, the statement makes no sense in terms of finite computation*. If you have copied the words correctly then the teacher has made a mistake.

Are you 100% certain that you have transcribed every word perfectly? Please double check and, if the text is exactly as presented, ask your teacher to clarify.


*The reason is that, as it stands, it is asking for an infinite list. It is possible to compute the integer 50^300. The answer has 510 digits in decimal notation - it is huge! However you are then asked to calculate "all integers from" that number. There is an infinite number of integers that are greater than 50^300 so it would take an infinite amount of time to calculate them. Not only that but you also have to store them in a list!

Your teacher would not get the whole list even after the end of the universe.


As a matter of interest, 50^300 is

4909093465297726553095771954986275642975215512499449565111549117187105
2547217158564600978840373319522771835715651318785131679186104247189028
0751482410896345225310546445986192853894181098439730703830718994140625
0000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000

But of course you now have to count from that number until infinity and store the results!

  • Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/120230/discussion-on-answer-by-chasly-supports-monica-what-does-write-code-that-crea). – Eddie Kal Feb 27 '21 at 15:39
6

From a mathematical angle and a logical angle, the question does not make sense as it stands, and unfortunately it does not make sense in more than one way, so we can't easily assume what it was meant to convey, either.

The question is asking for a contiguous list of integer numbers ("all"). When asking for this, you have to specify a range, i.e. a start value and an end value. It is possible that the start value is supposed to be 50, as in "from 50 to {some other value}", or it is possible that it is missing. If the start value was omitted, it would make sense to assume that "50 to the power of 300" is a correctly specified end value.

It is equally possible that 50 is the start value of the range and that the specifiction of the end value is incomplete, as in "from 50 to {something to} the power of 300". In this case, the "something" is cricially missing, because you need to know "something" before you can calculate it's power of 300.

Either way, the specification of the range is incomplete, we don't know what the original intent was, and as the problem statement stands, it makes no sense and cannot be solved.

A equally incomplete problem statement would be:

How many people can you fit in between the wall and the red?

The "red" what!? is the obvious response.

cdonner
  • 160
  • 5
5

It seems likely from the sentence structure that something is missing, as you have suggested. However the task as written can be interpreted in a way that makes sense. If you write a program that lists the integers beginning with 50 ^ 300 you would have accomplished the task, in that every required number will eventually be in the list. It might only be a short task to write the program even though it would need to run for ever.

Peter
  • 5,112
  • 2
  • 7
  • 15
  • 1
    I challenge you to try this. The largest integer that can be represented in 64-bits is 2^64-1 - How are you going to do arithmetic with numbers that are 50^300 and bigger? You would have to implement variable-precision arithmetic first. – chasly - supports Monica Feb 25 '21 at 18:01
  • 7
    @chasly-supportsMonica: `import itertools; result=itertools.count(start=50**300); next(result)`. Done – Eric Duminil Feb 25 '21 at 20:54
  • 2
    @chasly-supportsMonica No, it's easy and can be done with 4-bit arithmetic. Start with the string representation of 50^300 shown in another answer. The low digits are 0 anyway, so you just need an algorithm to start producing numbers from 0. Add one, if 10 is reached, handle carry. Print string, repeat. Could be a one-liner in C. – Jens Feb 25 '21 at 20:54
  • Okay, so now you have implemented the arithmetic. Still doesn't work - now you have to implement variable length memory addressing ***for variable-length list elements***. I'm not talking about the physical amount of memory or even the number of atoms in the universe. Assume you have infinite memory. I'm talking about the limits imposed by your 64-bit operating system. No current OS will be able to address potentially infinite memory, let alone arbitrary length records within that memory. So now you are writing a new OS. Good luck if that is this week's homework. – chasly - supports Monica Feb 25 '21 at 21:12
  • P.S. I am not saying that the task is impossible. I'm saying that, even given infinite memory and infinite time, and everlasting hardware; writing the software is not a week's homework on any normal programming course. It requires some fancy programming at OS level. Maybe that is what the teacher wants - in that case, it's a great exercise! If it wasn't completely pointless I'd be tempted to do it myself. – chasly - supports Monica Feb 25 '21 at 21:22
  • 3
    @chasly-supportsMonica There are a lot of programming languages in which it's easy to write a program which—theoretically, and if the program is executed according to the specification of the programming language—will output every integer greater than or equal to 50^300. I'll grant that today's operating systems are incapable of allowing programs to access an infinite amount of memory even if the computer _has_ an infinite amount of memory, but that fact has no bearing on the theoretical correct behavior of a computer program. – Tanner Swett Feb 25 '21 at 21:39
  • @Tanner Swett - No. "Write code to" means "implement". If you merely write an expression in a computer language but don't execute it, then you haven't solved the problem, you've merely rewritten it in a different notation. To actually solve it, you need an implementation that would not crash, given infinite memory, and infinite time. Either that or the question should specify an upper limit. – chasly - supports Monica Feb 25 '21 at 22:50
  • 1
    @chasly-supportsMonica I think we disagree on what counts as an "implementation." To me, any computer program written in an acceptable programming language (which would include, say, C, Lua, Haskell, or the untyped lambda calculus) counts as an "implementation." To you, an "implementation" must be a computer program that would actually run on the type of computer system that you have in mind. I don't know exactly what type of computer system you have in mind, but I can infer that it's one that's attached to an infinite memory device which today's operating systems cannot use. – Tanner Swett Feb 25 '21 at 23:10
  • @Tanner Swett - The computer system I have in mind is a bog-standard Turing Machine. https://en.wikipedia.org/wiki/Turing_machine. No actual physical computer can do this task, obviously. However I interpret the question to mean "Write an algorithm that will count upwards from 50^300 and store the results in a list to any required endpoint without ever crashing." This algorithm is to be implemented on any Turing-equivalent system. I say that this task is possible but it is not half-an-hour's worth of homework on an average programming course. It requires really tricky memory management. – chasly - supports Monica Feb 25 '21 at 23:30
  • 1
    @chasly-supportsMonica I'm pretty sure most programming assignments allow the student to assume that an implementation of the relevant programming language, targeting the relevant computer, already exists. If you tell me to write a program in the ordinary programming language of my choice, and that my program will run on a Turing machine, then I will assume (unless you say otherwise) that I may use Haskell and that the Haskell implementation is one that doesn't have any unnecessary restrictions on memory usage. – Tanner Swett Feb 26 '21 at 00:01
  • @Tanner Swett - This is getting silly now. The name of the language is irrelevant. I could write the program in Visual Basic. However no existing operating system can address arbitrary amounts of memory. You would have to write an ad hoc OS. This is also possible. I could do that as well given time. I'm saying that it is not just a matter of writing a Haskell expression and letting it run. It will crash at some point. Anyway I'm tired of arguing. If I have time I may formalise this problem and post it on Computing SE or similar. It's ridiculous to discuss CS in ELL. – chasly - supports Monica Feb 26 '21 at 00:16
  • This. This is why nothing has replaced COBOL. COBOL is like "variable-precision arithmetic? Of course, *but what do you mean, ‘other languages don't support that’. **How do they do money?***” – Harper - Reinstate Monica Feb 26 '21 at 20:44
4

As Peter pointed out, it may be a request to write a program that never ends, a program that computes every integer starting from 50^300 onward. But such request gets special meaning in the context of programming languages that allow for lazy evaluation, like Haskell.

Infinite lists in those languages does not mean that the code will compute forever, but that a list is a recipe that will be computed on demand, depending on how other parts of the program uses it (hence, "lazy" evaluation, because values are only computed when needed).

In this context (for instance, if this is an assignment from a class that teaches Haskell), the sentence gains a new light and does not feel as incomplete, because code that potentially never ends are commonplace and objectively useful.

lvella
  • 141
  • 3
  • Does Haskell have built-in variable-precision arithmetic? If not, you can't even get started. – chasly - supports Monica Feb 25 '21 at 18:02
  • Built-in [Integer](https://hackage.haskell.org/package/integer-gmp-0.5.1.0/docs/GHC-Integer.html#t:Integer) type is arbitrary precision, which is deducted when you write 50^300. – lvella Feb 25 '21 at 18:29
  • That's interesting. I've never used or studied Haskell - I'm retired now and don't need to but it could be interesting. I suggest you ask the OP what language(s) they are expected to use. The problem for me though is, even if Haskell does this, why set such an apparently arbitrary starting point? Also, how do you specify when to stop? You would have to write a user program to drive this procedure. In that case we're back to an infinite loop requiring infinite memory to store the list. The teacher still needs to specify a stopping point. If it's abstract, why specify a start point? – chasly - supports Monica Feb 25 '21 at 18:47
  • 1
    In a Haskell terminal (which is much like a Python terminal), if you write `a = [50^300..]` and press enter, by any Haskell standards, you have effectively defined an infinite list starting from 50^300. If you want to actually display the list (type `a` and press enter, for instance), it will obviously never stop printing until you cancel it, but expression `a` has a type List of Integers (Haskell is strongly typed), and can be passed to any function that takes a List of Integers. – lvella Feb 25 '21 at 18:50
  • That sounds good. I think I'll have a look at this language. So the homework goes from advanced to trivial !! I think you need to ask the OP if Haskell is allowed. If it isn't and they put this as the answer, the teacher won't be pleased! If it is allowed, then you have solved the English and you have done the homework! – chasly - supports Monica Feb 25 '21 at 18:55
  • 2
    My intention with this answer is just to point that the sentence does have an specific and very natural meaning in the context of [lazy evaluation](https://en.wikipedia.org/wiki/Lazy_evaluation) programming languages. – lvella Feb 25 '21 at 18:59
  • I've just been reading a little about it. I think my objection now is you haven't actually written "code that creates a list of all integers from 50 to the power of 300", instead you have simply rewritten the *problem* but in Haskell format. All you have created is a template that is strictly limited by the operating system you are working within. The code will crash as soon as you exceed the limit of memory that the OS will let you address. Okay, this is large by human standards but it is zero when compared to an infinite list ... – chasly - supports Monica Feb 25 '21 at 19:37
  • ... IMHO, to truly answer your version of the problem you would have to allow the addressing of arbitrarily large amounts of memory. In other words you would need to redesign the OS. – chasly - supports Monica Feb 25 '21 at 19:37
  • @chasly-supportsMonica The list of all integers isn't infinite in a computing context, because integers are constrained by the number of bits of memory allocated to them. – nick012000 Feb 25 '21 at 22:07
  • @nick012000 - I'm way ahead of that. Trying searching online for ***Variable Precision Integer Arithmetic*** I've also pointed out that variable-precision memory addressing would be needed in addition. – chasly - supports Monica Feb 25 '21 at 22:39
  • @chaslt-supportsMonica Yes? I'm aware. I mention the Java BigInteger class in my answer. You'd just need to use a class that lets you allocate enough memory to store the value of 50^300. – nick012000 Feb 25 '21 at 22:48
  • @chasly-supportsMonica The convention in this context is that a list does not need to be fully evaluated to be a list, so the fact that its full evaluation does not fit into memory is irrelevant. Such convention comes straight from math: if the answer for your math assignment is an infinite convergent series, no one will expect you to calculate every digit of the answer, it is sufficient to formally define the series, which is effectively the number that answers the question. – lvella Feb 26 '21 at 13:49
2

There's another unlikely but possible interpretation that also barely makes sense: the infinite list
[50**300, 51**300, 52**300, ...]

It wouldn't be a good way to give an assignment to students: assignments should clearly and unambiguously describe exactly what problem you're supposed to solve, or what the code is supposed to do. Therefore it's highly unlikely this is what was intended. It's also only possible in a programming language that allows creation of infinite lists (e.g. Haskell I think, where they can be lazily evaluated.)

Parsing the sentence this way would fit even better if there was a comma where I placed one, but I think it's possible to interpret this way even without.

creates a list of all integers from 50, to the power of 300.

So your list is of all the integers "from 50" (another way to say "50 and up"), and every element of that list is raised to the power 300.

This list is IMO slightly more interesting than contiguous integers starting with 50**300, 50**300 + 1, but both interpretations are at least somewhat valid. The +1, +2, ... version is a somewhat better fit for the phrasing, but this is the interpretation that occurred to me first, when mentally searching for a way it could possibly make any sense.


Write code that creates a list of all integer digits of 50^300

Yes, that's possibly what your teacher meant to say, especially if English isn't their native language or they simply made a typo. But it's not possible as an exact literal interpretation of that the assignment did say.

"all integers from x" definitely doesn't mean "the base-10 digits of x". It has no standard meaning.

Peter Cordes
  • 968
  • 9
  • 12
1

It means that whoever posed that question isn't very good at writing questions, not very good at English, or both.

"The power of 300" is meaningless. There is no mathematical property named "power" that numbers could have. Numbers have powers; the "first power" is the number itself, the "second power" is the number squared, and so on. "x to the power of 300" or "x raised to the 300th power" or "the 300th power of x" all make sense, they are all the result of starting with 1 and multiplying by x, repeated 300 times.

gnasher729
  • 3,698
  • 13
  • 12
-2

The way to parse this in mathematical English is:

 Write code that creates
 a list of
 all integers
 from
 50 to the power of 300

where each line is parsed distinctly.

 Write code that creates
 a list of
 X
 from
 Y

means treat Y as a description of a set or collection of elements, and they want you to create a list of elements that qualify as X from that set or collection, and make a list of them.

The problem is that "50 to the power of 300" is itself an integer. And an integer is not a collection of integers.

You can attempt to read "50 to the power of 300" as a collection of integers; if it was "A to B" where both A and B where numbers, that would have a clear meaning (well, somewhat clear; if it includes the endpoints would be ambiguous). But while "50" describes a number, "the power of 300" does not.

You could invent a base (like 10), but that is stretching it.

So we treat "50 to the power of 300" as a single number.

So now we have:

 Write code that creates
 a list of
 all integers
 from
 some number

the teacher probably means digits. If the teacher was being a silly set theoretical mathematician, one construction of the natural numbers is that each natural number is the set of all of its predecessors; so zero is the empty set, 1 is the set containing 0, 2 is the set containing 1 and 0, etc. But I'd bet a fair amount of money that your teacher does not mean this, unless you are taking an introductory course in formal mathematics foundations of some kind.

So make a list of the digits.

Note that in some dialects of non-mathematical English, "all of the X from Y" can mean "starting at Y and going on, all of the X". This is not something you would ever mean in the mathematical sub-dialect of English.

Yakk
  • 166
  • 8
-3

This might theoretically make sense, with a sufficiently large integer type.

Like the other answers, I'm going to say that based on what you've written, your teacher wants a list of all integers, starting with 50^300. However, this is neither impossible, nor an unending infinite task, because this is being asked about in the context of computers.

In computers, integers cover a finite span based on the amount of memory allocated to them. For instance, in Java, the primitive int type uses 32 bits of memory with the first bit being allocated to determining whether the int is positive or negative, resulting in a maximum positive value of 2^31-1 (2,147,483,647) and a maximum negative value of 2^31. This is obviously far smaller than the value of 50^300, since both the base and the exponent are far larger than than the value allowed by the primitive int type.

However, there are additional Java classes that allow you to increase this size, such as the Java BigInteger class, which allows you to set its length in bits, up to the normal integer size limit (approximately 2 gigabytes of memory for each such number). Such a massive size would be overkill, and it would likely take an obscene amount of time to run to completion; it would likely be much more efficient to use a far smaller number of bits.

50^300, expressed in base 2, is just under 1,700 digits long, so fastest (but still extremely slow) way to do it would be to store 50^300 in a binary number exactly long enough to store it, 1,694 bits long. It would still be take an obscene amount of time, however - running it on the CPU of an XBox Series X (as an example of a generic modern computer), with a clock speed of 3.6 GHz, it would still take about 10^482 times the current age of the universe to finish counting up to its maximum value.

nick012000
  • 2,208
  • 10
  • 12
  • 3
    This is both ridiculous and utterly unrelated to the English language. – TypeIA Feb 25 '21 at 13:24
  • @TypeIA The other answers were talking about a counting process that would take literally forever. This way would at least theoretically have a stopping point. – nick012000 Feb 25 '21 at 20:46
  • 1
    That might be an interesting topic for a programming site! – TypeIA Feb 25 '21 at 21:52