Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#201 2006-01-06 06:25:14

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Cow Bull 1

(according to my calculations)


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#202 2006-01-06 06:39:52

mathsyperson
Moderator
Registered: 2005-06-22
Posts: 4,900

Re: Cow Bull 1

No, siva.eas's guess doesn't match the result from guess 6.

My calculations show that either ganesh is right, with 1204, or the answer is Guess 9 (because siva actually had guess 8): 1206.


Why did the vector cross the road?
It wanted to be normal.

Offline

#203 2006-01-06 07:25:09

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Cow Bull 1

I think her result match, but we'll see soon.


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#204 2006-01-06 07:31:24

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Cow Bull 1

I'm starting writing cowbull program in Mathematica.
I think I'll be ready soon.


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#205 2006-01-06 07:33:53

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Cow Bull 1

Here's some code:

len[n_] := Length[IntegerDigits[n]]
(*This gives the number of digits of n*)

diff[n_] :=
  (
    a := 0;
    Do[
      If[IntegerDigits[n][[i]] == IntegerDigits[n][[j]] && i != j, a = 1]
      , {i, 1, len[n]}, {j, 1, len[n]}];
    a
    )
(*this gives 1 if there is repeating digit*)

cowbull[a_, b_] :=
  (
    c := 0;
    d := 0;
    If[len[a] == len[b] && diff[a] == 0 && diff[b] == 0,
      Do[
        If[
          IntegerDigits[a][[i]] == IntegerDigits[b][[j]],
          If[i != j,
            c += 1,
            d += 1]],
        {i, 1, len[a]},
        {j, 1, len[b]}];
      {c, d},
      Print["Please input correct numbers"]]
    )
(*this is the main function. It 
    gives the number of cows and bulls between 2 numbers a and b*)

IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#206 2006-01-06 07:55:15

mathsyperson
Moderator
Registered: 2005-06-22
Posts: 4,900

Re: Cow Bull 1

If the answer was 4219, then a guess of 1289 would have returned bbc.


Why did the vector cross the road?
It wanted to be normal.

Offline

#207 2006-01-06 08:15:09

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Cow Bull 1

Oh yes, you're right


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#208 2006-01-06 10:19:04

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Cow Bull 1

Now I'm ready with my program and I'm checking it...


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#209 2006-01-06 10:21:14

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Cow Bull 1

Yes, Mathsy, you are right.
According to the home-made program the answers are 1204 or 1206.

It works!!!


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#210 2006-01-06 10:32:15

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Cow Bull 1

Here is it:
(you won't understand it easy)

(* Cow Bull *)
(* by krassi_holmz *)
(* January, 2006 *)
(*BEGINING*)
(*--------------------------------------------------------------*)

len[n_]:=Length[IntegerDigits[n]]
(* This gives the number of digits of n *)
(*--------------------------------------------------------------*)

diff[n_]:=
  (
    a:=0;
    Do[
      If[IntegerDigits[n][[i]] == IntegerDigits[n][[j]] && i!=j,a=1]
      ,{i,1,len[n]},{j,1,len[n]}];
    a
    )
(* this gives 1 if there is a repeating digit *)
(*--------------------------------------------------------------*)

cowbull[a_,b_]:=
  (
    c:=0;
    d:=0;
    If[len[a]\[Equal]len[b]&&diff[a]\[Equal]0&&diff[b]\[Equal]0,
      Do[
        If[
          IntegerDigits[a][[i]]\[Equal]IntegerDigits[b][[j]],
          If[i!=j,
            c+=1,
            d+=1]],
        {i,1,len[a]},
        {j,1,len[b]}];
      {c,d},
      "Please insert correct numbers"]
    )
(* this is the main function. It gives the number
     of cows and bulls between 2 numbers a and b *)
(*---------------------------------------------------------------*)

iscb[a_,b_,c_]:=If[Head[cowbull[a,b]]!= String && cowbull[a,b]\[Equal]c,1,0]
(* this gives 1 if the n\
umber of cows and bulls 
    of a and b is from the table c*)
(*---------------------------------------------------------------*)

gen[a_,data_,cb_]:=
  (
    p:=1;
    Do[
      If[
        iscb[a,data[[i]],cb[[i]]]\[Equal]0,
        p=0]
      ,{i,1,Length[data]}];
    p
    )
(* this is generalized iscb function. It gives 1 if all the numbers 
    from data list have cowbull[a,n] equal to cb[n]*)
(*----------------------------------------------------------------*)

ppt[l_]:=
  (
    k:=1;
    Do[If[l[[i]]\[Equal]1,out[k]=i;k=k+1],{i,1,Length[l]}];
    Table[1022+out[j],{j,1,k-1}]
    )
(* this function is used to visualise the results. It transforms 
    a binary solution table to the final solution table *)
(*----------------------------------------------------------------*)

TheSolutions[data_,cb_]:=ppt[Table[gen[i,data,cb],{i,1023,9876}]]
(* this is the final function *)
(*----------------------------------------------------------------*)
(*END*)

Last edited by krassi_holmz (2006-01-06 10:35:13)


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#211 2006-01-06 10:42:39

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Cow Bull 1

Here's the input and calling the function TheSolutions (for the last cowbull):

Last edited by krassi_holmz (2006-01-06 10:44:09)


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#212 2006-01-06 10:46:35

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Cow Bull 1

So Mathsy || Ganesh wins!

Congratulations Mathsy || Ganesh !

(|| means logic OR)


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#213 2006-01-06 12:33:29

justlookingforthemoment
Moderator
Registered: 2005-05-26
Posts: 2,161

Re: Cow Bull 1

Guess &: 1204          bbb
Guess 9: 4219           bc

Right, didn't see next page.

Guess 8: 1206          bbbb

Mathsy wins. Again. Kudos to you. big_smile

Last edited by justlookingforthemoment (2006-01-06 12:34:55)

Offline

#214 2006-01-06 16:34:06

Jai Ganesh
Administrator
Registered: 2005-06-28
Posts: 48,418

Re: Cow Bull 1

Cow Bull # 12
(1) Who's going to host?
(2) If the members agree, we can upgrade the game to hexadecimal. All conditions remain the same. Four digit numbers, no repititions,  the number shouldn't start with zero. The only difference, we'd have to guess from 15 numbers : 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E. The number of permutations : 30,576!
Advantages :- Games of longer duration, more players get an opportunity to win.
Disadvantage :- If the host makes a mistake, the game would go on meaninglessly until someone (maybe the host) discovers there has been a mistake.

Vote for or against Hexa cool


It appears to me that if one wants to make progress in mathematics, one should study the masters and not the pupils. - Niels Henrik Abel.

Nothing is better than reading and gaining more and more knowledge - Stephen William Hawking.

Offline

#215 2006-01-06 23:28:11

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Cow Bull 1

No, I'll have to rewrite my program!

Last edited by krassi_holmz (2006-01-06 23:28:37)


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#216 2006-01-07 01:59:43

mathsyperson
Moderator
Registered: 2005-06-22
Posts: 4,900

Re: Cow Bull 1

Yes, because krazzi will have to rewrite his program! tongue

But seriously, I think it will be much more fun this way. Using a computer program could be considered cheating, anyway.

I'll host this game. I've got 2 possible numbers, depending on whether the rule change gets accepted or not.


Why did the vector cross the road?
It wanted to be normal.

Offline

#217 2006-01-07 02:53:11

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Cow Bull 1

OK. I agree. I've written my program for demical numbers, but my style is "function programing" so it won't be hard to generalize my program. Actually I have to rewrite only some functions becouse the i can you many of old functions. But I won't cheat. I promise.

I suggest to have two games at once:
hexademic cb1:
guess 1: def3

demical cb12:
guess 1:1234


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#218 2006-01-07 03:04:43

mathsyperson
Moderator
Registered: 2005-06-22
Posts: 4,900

Re: Cow Bull 1

2 games at once? That will be... interesting. Well, it never hurts to try something once, so let's see how this turns out.

Hex Guess 1: DEF3 (bc)
Dec Guess 1: 1234 (cc)


Why did the vector cross the road?
It wanted to be normal.

Offline

#219 2006-01-07 06:10:21

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Cow Bull 1

Hex Guess 2:ABFD
Dec Guess 2:5678


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#220 2006-01-07 10:38:36

mathsyperson
Moderator
Registered: 2005-06-22
Posts: 4,900

Re: Cow Bull 1

Hex 2: ABFD (bcc)
Dec 2: 5678 (cc)


Why did the vector cross the road?
It wanted to be normal.

Offline

#221 2006-01-07 19:05:34

Jai Ganesh
Administrator
Registered: 2005-06-28
Posts: 48,418

Re: Cow Bull 1

Thats very interesting! Two games simulataneously, one in Decimal and the other in Hexa!
Guess 3 : Hex : DBFA
Guess 3 : Dec : 3904


It appears to me that if one wants to make progress in mathematics, one should study the masters and not the pupils. - Niels Henrik Abel.

Nothing is better than reading and gaining more and more knowledge - Stephen William Hawking.

Offline

#222 2006-01-07 22:47:11

mathsyperson
Moderator
Registered: 2005-06-22
Posts: 4,900

Re: Cow Bull 1

Hex 3: DBFA (ccc)
Dec 3: 3904 (-)


Why did the vector cross the road?
It wanted to be normal.

Offline

#223 2006-01-07 23:29:51

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Cow Bull 1

Hex 4:a3bf
Dec 4:7812


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

#224 2006-01-07 23:53:01

mathsyperson
Moderator
Registered: 2005-06-22
Posts: 4,900

Re: Cow Bull 1

Hex 4: A3BF (cc)
Dec 4: 7812 (cccc)


Why did the vector cross the road?
It wanted to be normal.

Offline

#225 2006-01-08 08:44:18

krassi_holmz
Real Member
Registered: 2005-12-02
Posts: 1,905

Re: Cow Bull 1

Hex 5:badf
Dec 5:8127


IPBLE:  Increasing Performance By Lowering Expectations.

Offline

Board footer

Powered by FluxBB