解題小工具 - 輕鬆解答數學比賽最新題目 / A simple tool to tackle the latest math competition

in #cn7 years ago (edited)

每一次我也相當期待 @kenchung 的數學比賽,因為我喜歡用不同的方法解答問題。可是我的程式語言並不好,寫短短的語言可能要花大半天時間,有一些人也可能因此沒有參加這比賽。這是非常可惜的。這一次的題目是要從十多個的方程式去把未知數尋找出來。?簡單的方法是把所有的方程式寫出來,然後把他們加加減減,把逐一個未知數找出來。第二個方法是用程式暴力解題。我看了題目便認為有可能用 Excel 的 Add-in (Solver),直接把所有條件輸入,把所有回答一次過找出來。 也順便分享此方法給大家,以後也有可能用同樣的方法參加比賽。

I always have high expectation to @kenchung maths competition because I always like to use different ways to solve the question. However, my programming skill is not very good and a short code can cost me plenty of time. That may be also the reason why not more people join the competition and this is a real pity. For this competition, we are required to solve the unknown variables by using 10+ conditions. There are few ways to solve that: 1) write down all the formula and use simple algorithm to find out the variables one by one. 2) Use brute force to calculate the answer programmatically. I also thought there are the third way and a way everyone can do it easily: By using the built in tool within excel (solver) to calculate all the variable at once. I will share the method to everyone such that I hope it will encourage more people to participate the competition in the future.

第一步是在 Excel在特訂的範圍內輸入 1-16 ,這範圍是會讓 Excel 進行計算的。

The first step is to input 1-16 into a range within Excel, the range will be used to calculate the answer later.

P_20170828_123049.jpg

第二步是在 Excel 內把所有的條件列出來(藍色),紅色部分是使用來有核對答案的。

The second step is to list all the conditions (blue), the red part is to validate the answer later on.

P_20170828_123113.jpg

第三步是打開 Solver 的功能,再把藍色的條件輸入到"設定限制式裡面", 其中還會要求結果是不能重複和必須是整數。

The third step is to open the solver function and input the conditions (blue) into the excel, in particular I will add two more conditions (to ensure the result do not duplicate and must be integer).

P_20170828_123134.jpg

P_20170828_123141.jpg

可是用這些條件,Excel 並未能把回答算出,原因是首四個條件 "A, B, J, K 只可由 2, 4, 6, 8 四個數字填上" 對於 Solver 來說太複雜,所以我會在 Solver 把這四個條件移除,然後再執行一次。

Unfortunately Excel could not give me the answer in the first go because the condition of "A, B, J, K can only be filled with the numbers 2, 4, 6 or 8" is too complex for Excel and therefore I will remove these conditions and re-run the program.

P_20170828_123148.jpg

最後Excel把回答算出來了,只有一個條件沒有達成,我們可以很簡單把 J 和 H 的位置互換,便是這次比賽的答案。

Finally, after the changes, Excel is able to calculate the answer for me but with one condition not being fulfilled. We can simply switch the output for J and H and we have our answer for this competition.

P_20170828_123156.jpg

希望下次你們也可以一起參加~

Hope you enjoy it and hope to see you in the next competition.

Sort:  

我記得以前念書的時候,讀這個好崩潰啊!!!

現在我也很崩潰啊 :(

我現在就比較不崩潰了, 因為我都沒在用,哈哈哈~

programming 渣先要咁做 :(

用Excel做到嘅就唔一定要寫program

This post received a 29.44% upvote from @animus thanks to @animus! For more information, click here!

Good post
I like to have a stemit friend like you who are a fan. I want to be like you to spark my aspirations to be liked by other stemit friends. I want to be the best poet that many fans like you. @Sinta

This drive me crazy............... master wig!

no master :( I think my drawing is better XD.

Excel还可以这么用,长见识拉

That's a smart way to do it ;)

I wish i am smarter :(

之前参加过Macro 的短期培训,弄得两眼发呆,晕了。不知道什么时候会掌握。

我也有一段時間沒有用,都忘光光了 :(

Amazing, I don't know this ! It is very helpful for me thank you!

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.028
BTC 60157.20
ETH 2416.98
USDT 1.00
SBD 2.43