Jump to content
BrainDen.com - Brain Teasers
  • 0

Find smallest function for 24 permutations


Guest
 Share

Question

You have few calculator functions:

+ : add

- : subtract

* : mutiply

/ : divide

% : get remainders from divide

** : power

Notation:

1.f(x) = {1,2,3,4} means f(1)=1, f(2)=2, f(3)=3, f(4)=4.

2.cost = 1 means the function uses one operator.

So, please find all 24 functions of 4! with minimum of operations. That is,

f1(x)={1,2,3,4} f1(x)=x (cost = 0)

f2(x)={1,2,4,3} f2(x)=?

f3(x)={1,3,2,4} f3(x)=?

f4(x)={1,3,4,2} f4(x)=?

f5(x)={1,4,2,3} f5(x)=?

f6(x)={1,4,3,2} f6(x)=?

f7(x)={2,1,3,4} f7(x)=?

f8(x)={2,1,4,3} f8(x)=?

f9(x)={2,3,1,4} f9(x)=?

f10(x)={2,3,4,1} f10(x)=?

f11(x)={2,4,1,3} f11(x)=?

f12(x)={2,4,3,1} f12(x)=?

f13(x)={3,1,2,4} f13(x)=?

f14(x)={3,1,4,2} f14(x)=?

f15(x)={3,2,1,4} f15(x)=?

f16(x)={3,2,4,1} f16(x)=?

f17(x)={3,4,1,2} f17(x)=?

f18(x)={3,4,2,1} f18(x)=?

f19(x)={4,1,2,3} f19(x)=?

f20(x)={4,1,3,2} f20(x)=?

f21(x)={4,2,1,3} f21(x)=?

f22(x)={4,2,3,1} f22(x)=?

f23(x)={4,3,1,2} f23(x)=?

f24(x)={4,3,2,1} f24(x)=5-x (cost = 1)

Note:

1.it does not allow recursive function calls.

2.power operator costs 2 and others cost 1.

*3.divide operator gets the floor of the divide result. that is, 3/2 => 1

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Cute puzzle. I think I have the idea.

Here's a start, more to come after I get some zzzzzzzzzzz's.

----------------------------------------------------------

f1(x)={1,2,3,4} f1(x)= x cost = 0

f2(x)={1,2,4,3} f2(x)=?

f3(x)={1,3,2,4} f3(x)=?

f4(x)={1,3,4,2} f4(x)=?

f5(x)={1,4,2,3} f5(x)=?

f6(x)={1,4,3,2} f6(x)=? 4-(x+2)%4 cost=3

----------------------------------------------------------

f7(x)={2,1,3,4} f7(x)=?

f8(x)={2,1,4,3} f8(x)=? 4-(x+1)%4 cost=3

f9(x)={2,3,1,4} f9(x)=?

f10(x)={2,3,4,1} f10(x)=? 1+x%4 cost=2

f11(x)={2,4,1,3} f11(x)=?

f12(x)={2,4,3,1} f12(x)=?

----------------------------------------------------------

f13(x)={3,1,2,4} f13(x)=?

f14(x)={3,1,4,2} f14(x)=?

f15(x)={3,2,1,4} f15(x)=? 4-x%4 cost=2

f16(x)={3,2,4,1} f16(x)=?

f17(x)={3,4,1,2} f17(x)=? 1+(x+2)%4 cost=3

f18(x)={3,4,2,1} f18(x)=?

----------------------------------------------------------

f19(x)={4,1,2,3} f19(x)=? 1+(x+2)%4 cost=3

f20(x)={4,1,3,2} f20(x)=?

f21(x)={4,2,1,3} f21(x)=?

f22(x)={4,2,3,1} f22(x)=?

f23(x)={4,3,1,2} f23(x)=?

f24(x)={4,3,2,1} f24(x)= 5-x cost = 1

----------------------------------------------------------

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...