Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

square root on the 4 4's challenge

G
Gravili (360 points)
2 6 8
in Programming in Python by (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
552 views

5 Answers

gianluca5539 (9820 points)
4 6 44
by (9.8k 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.
A
Annafabia (2130 points)
0 0 3
by (2.1k 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
B
Bianchi (320 points)
2 3 5
by (320 points)
I think it's because when we write "sqrt()" in a python code we don't explicitly put 2.
A
Annafabia (2130 points)
0 0 3
by (2.1k 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
f
francescofavale (420 points)
0 0 2
by (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.
T
Tsion biruk (570 points)
0 0 2
by (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)
14 20 65
by (6.1k 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 4 25
by (5.6k 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)
14 20 65
by (6.1k 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.