17
\$\begingroup\$

I'm attempting to solve a programming golf style programming puzzle. I need to write an 18 character phrase in Chef in less than 32 "lines" of code. In this case, a line counts as an ingredient or an instruction.

The most straightforward way of doing this is to declare an ingredient for each character and put each ingredient into a baking dish. Unfortunately for what I'm trying to do, that takes too many "lines" of code. (I'm limited to 32 and I want to print a 18 character phrase. 18*2 + title + serves command + headers = 40).

Here are things I tried:

So I had the idea of just using large numbers that would span multiple unicode chars. But when I print it out, I get garbage. So then I had the idea to just stream my characters by reading off each byte of a large number at a time and popping them into a baking dish in a loop. Unfortunately, there doesn't seem to be a way to do with the operators I have (the basic four arithmetic operators). I tried taking a number, dividing by 256, multiplying by 256, and subtracting that from my original number to get the least significant byte, but then discovered that Chef uses floating point (that is the number doesn't change).

There are no logical operators. There's no comparison operators. Any idea on what I can try next to print out an 18 character phrase in less than 32 "lines" of code? (Putting commands on the same line doesn't help. It still counts the same).

\$\endgroup\$
11
  • 1
    \$\begingroup\$ Outside the box: What interpreter are you using? I don't see anything in the spec that requires Chef to use floating point. If you write your own interpreter using integers... \$\endgroup\$
    – Geobits
    Oct 13, 2014 at 18:00
  • 2
    \$\begingroup\$ I'm unsure why help solving a programming golf problem is considered off topic here. I would consider it off topic on StackOverflow. I'll edit it to make it clear I'm solving a programming puzzle. \$\endgroup\$ Oct 13, 2014 at 18:16
  • \$\begingroup\$ The questions seems little legit. If you can modify it and turn it into a programming challenge with shortest code as scoring criteria and other rules, then it can be reopened. As of right now, it simply looks like you need help in doing some stuff, even though the question is nice. \$\endgroup\$
    – Optimizer
    Oct 13, 2014 at 18:21
  • 5
    \$\begingroup\$ @Optimizer Not all questions need to be challenges. @ Jason It might help if you post the code you're currently trying to golf. What works for one string may not work for another (due to patterns or whatever). It also changes it from general advice to "I have this code that works correctly and I'm trying to golf it to X lines/characters", which may be received better. \$\endgroup\$
    – Geobits
    Oct 13, 2014 at 18:27
  • 1
    \$\begingroup\$ There would have to be some kind of exploitable sequence in the characters. Within the "Chef" rules, I don't see it's feasible to encode an arbitrary string with more than one character per ingredient. \$\endgroup\$
    – COTO
    Oct 15, 2014 at 8:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.