square root on the 4 4's challenge

Gravili (360 points)
1 4 8
asked Oct 2, 2021 in Programming in Python by Gravili (360 points)
in the instructions for the 4 4's challenge given to us by professor Spognardi the math import is mentioned and how we can evaluate factorials and square roots with it, are we allowed to use said operations on the challenge? as in 4!=24 and sqrt4=2

5 Answers

gianluca5539 (9820 points)
3 6 44
answered Oct 2, 2021 by gianluca5539 (9,820 points)
I think we are allowed to, but I'm not fully sure.

We must use 4 4s, I didn't hear him say anything about operations not permitted. I think I also heard him talking with one of our colleagues and he said that we could also use the logarithm if we found it helpful. So I think it's a yes, we can use the operations available by importing math.

Having said that, I managed to find all numbers apart from 14 without using the square root. I had to use the factorial for many numbers though.
Annafabia (2050 points)
0 0 3
commented Oct 3, 2021 by Annafabia (2,050 points)
why we can use the square root but we can't elevate 4 to the power, for example of 5.. it is the same thing ... square root of 4 is equal to 4^1/2 ..... so I don't understand if we ca use the power or not
Bianchi (320 points)
2 3 5
commented Oct 3, 2021 by Bianchi (320 points)
I think it's because when we write "sqrt()" in a python code we don't explicitly put 2.
Annafabia (2050 points)
0 0 3
answered Oct 3, 2021 by Annafabia (2,050 points)
in order to write the all 20 numbers you don't need 4! or any square root ... for 12 you can use 4! but you can also find 12 by doing :( 4- (4/4)) * 4
francescofavale (420 points)
0 0 2
answered Oct 3, 2021 by francescofavale (420 points)
For every operation the only numbers you can write are four 4s. I think you can arrange them and do whatever operations you want on them.
From the math library I used sqrt(4) and factorial(4).
I think the allowed operations are sums, subtractions, multiplications, divisions, raising 4 to the 4th power (4^4), sqrt(4), factorial(4) and log(4). I managed to complete the challenge without usinng all of those though.
Tsion biruk (570 points)
0 0 2
answered Oct 3, 2021 by Tsion biruk (570 points)
The thing is, we can technically use them but its best if we didn't because the whole point of the four fours challenge is to use four operations to combine four 4s in four different ways and get the numbers one through 20.
Luigi Pizza (6120 points)
11 20 65
answered Oct 5, 2021 by Luigi Pizza (6,120 points)

Hi guys, I know I'm a bit late to answer to this post, but we haven't still turned in the homework, so I'm still in time .

What I'd like to discuss, is that, if we are able to use the square root and the logarithmic function then we are able to express every single power of 2, For example:

But it is not all that useful. For example, I have implemented it only on 6, 10, 12, 16, 20. 

In reality, I didn't quite like using the square root on a 4 by itself: it seemed like cheating, so I had to get inventive. For example 10 =

Or, 12 =

And so on. 

gabrimat (5630 points)
2 2 25
commented Oct 7, 2021 by gabrimat (5,630 points)
That is really clever, I also agree with you, using the square root feels like cheating. I mean if you use it why not just use 4 to the power of 2. The square root is still using a number that is not 4 because of its index.
Luigi Pizza (6120 points)
11 20 65
commented Oct 14, 2021 by Luigi Pizza (6,120 points)
Yes, this was my same reasoning. By using all the square roots you want the game kind of loses its beauty. Though, considering that to use my method are necessary 3 4's, i don't feel like it's cheating.