Bulls and cows/Player: Difference between revisions

→‎{{header|Go}}: language change
No edit summary
(→‎{{header|Go}}: language change)
Line 633:
=={{header|Go}}==
Notes: Strategy per the suggestion in the problem description. Check algorithm lifted from Bulls and cows program. It was nice to have done that one first. Code here uses Go's built in map type as the container for the list of still-possible numbers; only the map key is used, the value is assigned a dummy of 0.
<lang go>package main
package main
 
import (
Line 673 ⟶ 672:
var guess string
for guess = range m {
delete(m[guess] = 0, false // remove itguess)
break
}
Line 717 ⟶ 716:
}
if cows != c || bulls != b {
delete(m[pat] = 0, falsepat)
}
}
Line 727 ⟶ 726:
}
}
}</lang>
}
</lang>
 
=={{header|Haskell}}==
1,707

edits