Show HN: FeatureMap - Story Mapping meets Agile Management
featuremap.co2 pointsby jpatte0 comments
mov p0 acc # place input value into internal register
mul 2 # multiply register by 2
mov acc p1 # place register value into output
slp 1 # sleep 1 cycle, wait for next input
The only way (I can think of) to optimize this is by cheating, i.e. by writing an algorithm specifically fitted for the kind of input we have to deal with. Looking at the input, we see that for example there are only 3 input values (0, 25 and 50) and there seems to be more zeros than other values. Based on this info we can try to predict what value is likely to show up as input and follow a dedicated path to handle it, in order to be as efficient as possible. def printPlayerLineup(playerPositionByNames)
batOrder = 1
playerPositionByNames.each do |name, position|
puts "#[name} bats #{batOrder} and plays #{position}"
batOrder += 1
end
end
There are also a few tips to give about how to pick good names. For example if you expect an array of player names the argument should be called `playerNames`, not `players`. Another example is function names should always start with a verb.
Thanks Bob! :-)