Well, this is a fun little puzzle from Google Blogoscoped
I’ve translated them to Ruby-esque code fragments (with some Rails-isms sprinkled in.)
// idiom 1
cop[0].goodInPercent = 100;
cop[1].goodInPercent = 0;
GoodCop=cop[0]
BadCop=cop[1]
return GoodCop + BadCop
// idiom 2
isCrowd = personCounter >= 3;
assert (3 == isCrowd)
// idiom 3
injury += insult;
return (insult + injury)
// idiom 4
1: board.draw();
goto 1;
def Board.back
Board.type = ‘drawing’
end
// idiom 5
if (bird[1].feather == bird[2].feather) {
bird[1].flock(bird[2]);
}
flock.collect {|bird| feathers.each {|feather| bird.find_by_feather(feather)}}
// idiom 6
a = getThickness('blood');
b = getThickness('water');
assert(a > b);
Blood.SpecificGravity = 1.0506 # reference: http://www.clinchem.org/cgi/content/abstract/20/5/615
Water.SpecificGravity = 1.0000
assert (Blood.SpecificGravity > Water.SpecificGravity)
// idiom 7
aspadea_spade();
class Spade
def Spade.call(value)
Spade.name = value
end
end
Spade.call (‘Spade’)
// idiom 8
die(1000);
function die(max) {
for (i = 1; i <= max; i++) {
cut();
}
}
Death.find_by_cut(‘1000’)
// idiom 9
prey = 'worm';
time = getCurrentTime();
if (time >= 4 && time <= 8) {
bird.catch(prey);
}
bird = Creature.new(:shift => ‘early’)
worm = Creature.new
if bird.shift == ‘early’ {
bird.catch(worm)
}
// idiom 10
while ( rome.fire() ) {
doFiddle();
}
Nero(:instrument => ‘fiddle’) while Rome.is_burning?
// idiom 11
function getValue(garbage) {
return garbage;
}
Value.In(:Garbage)
print Value.Out
==>Garbage
// idiom 12
take(salt * .01);
Salt.take(:mass => 0.06479891, :unit => ‘gram’)
// idiom 13
var here = false;
var there = false;
assert (!(here or there) == true)
// idiom 14
if (i == 2) {
tango();
}
def self.takes(value)
if value == 2 then self.tango();
end
// idiom 15
days = 365;
for (day = 1; day <= days; day++) {
if ( random(0,100) <= 50 ) apple++;
}
if (apple <= days) doctor();
year.collect {|day| if day.applecount > 0 then doctor.keepaway()}
// idiom 16
if ( !dogs.sleep() ) {
disturb(dogs);
}
if dog.is_asleep? then dog.lay()
// idiom 17
function tunnel() {
var dark;
for (i = 0; i < 10; i++) {
dark = true;
}
dark = !dark;
return dark;
}
Class Tunnel
def self.istherelight?
return (self.position == END)
end
end
// idiom 18
if ( ape.inLineOfSight(it.x, it.y) ) ape.do(it);
if monkey.doessee?(:actor) then monkey.do(Monkey.actionseen(:actor))
// idiom 19
return way.my || way.high;
return way(:my) || way(:high)
// idiom 20
hay[ random(0, hay.length - 1) ] = 'needle';
hay = Stack.new
hay.find(‘needle’)
hand[‘left’].wash(hand[‘right’])
// idiom 21
a = 0;
b = 1;
hand[a].wash(hand[b]);
hand[b].wash(hand[a]);
hand[‘right’].wash(hand[‘left’])
if (pain.level == 0) then gain.level = 0
// idiom 22
function getGain(pain) {
return pain >= 1;
}
// idiom 23
if (cooks >= 3) {
broth = null;
}
if cook.count >= 3 then broth.is_spoiled? = true
// idiom 24
if (a != 'cake') a.eat();
Class Cake
def Cake.have()
Cake.ishad? = Cake.iseaten? ? false : true
end
def Cake.eat()
Cake.iseaten? = Cake.ishad? ? false : true
end
end
// idiom 25
doesStand = you == me;
if We.is_united? then We.stand()
if We.is_divided? then We.fall()
if person.locale == ‘Rome’ then person.behavior(:Roman)
// idiom 26
var location = getLocation();
if (location == 'rome') {
do( location.getCitizen() );
}

Sorry, comments are closed for this article.