हाँ एक स्टैक-आधारित भाषा है जिसमें कुछ अलग-अलग निर्देश हैं:
yes: Push 1 to the stack
no: Push 0 to the stack
what: Push the input to the stack (input is taken at the start of program execution and is the same for the whole execution)
sure: Increment the last item in the stack
nah: Decrement the last item in the stack
really: If the last stack item is a number, replace it with its Unicode character. If it is a letter, replace it with its Unicode char code.
oh: convert the stack to strings and concatenate it, and push that to the stack.
nope: remove the first stack item
yep: remove the last stack item
कार्यक्रम के अंत में स्टैक का अंतिम तत्व हमेशा आउटपुट होता है। सभी गैर-अल्फ़ान्यूमेरिक और गैर-अंतरिक्ष वर्णों को अनदेखा किया जाता है। सभी कोड लोअरकेस है। उदाहरण कार्यक्रम:
yes sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure really
yes sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure really
yes sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure really
yes sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure really
yes sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure really
yes sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure really
yes sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure really
yes sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure really
yes sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure really
yes sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure really
yes sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure really
yes sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure really
yes sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure really
oh
प्रिंट करता है Hello, World!
।
what
इनपुट ( cat
प्रोग्राम) प्रिंट करता है
no nah
प्रिंट करता है -1
।
no really
NUL
वर्ण प्रिंट करता है ( U+0000
)
what
yes sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure sure really
oh
इनपुट और अंडरस्कोर प्रिंट करता है।
yes no nope
प्रिंट 0
yes no yep
प्रिंट करता है 1
।
आपको संभव के रूप में कुछ बाइट्स में एक दुभाषिया लिखना होगा। यहाँ एक जेएस कार्यान्वयन (अच्छी तरह से गोल्फ नहीं है!):
function yes(code, input){
var stack = [];
var functions = {
"yes": "stack.push(1)",
"no": "stack.push(0)",
"what": "stack.push(input)",
"sure": "stack[stack.length - 1] ++",
"nah": "stack[stack.length - 1] --",
"really": "stack[stack.length - 1] = (typeof lastItem === 'number' ? String.fromCharCode(lastItem) : lastItem.charCodeAt())",
"oh": "stack.push(stack.reduce((x, y)=>''+x+y))",
"nope": "stack.shift()",
"yep": "stack.pop()"
};
code.replace(/[^a-z ]/g, "").split(" ").map(x=>(lastItem = stack[stack.length - 1],eval(functions[x])));
return stack[stack.length - 1];
}
textarea{
display: block;
}
Code: <textarea id = "code"></textarea>
Input: <textarea id = "input"></textarea>
<button onclick = "output.value = yes(code.value, input.value)">Run</button>
<textarea id = "output"></textarea>
नीचे मेरा जेएस उत्तर भी देखें ।
आप मान सकते हैं कि इसमें शामिल सभी पूर्णांक 126 से कम या बराबर really
होंगे , जो कभी भी स्टैक के शीर्ष पर बहु-चार स्ट्रिंग के साथ नहीं चलाया जाएगा, और यह कि स्टैक 100 तत्वों से अधिक लंबा नहीं होगा।
किनारे के मामले
yes yes oh
प्रिंट करता है11
।- इंटूप एक स्ट्रिंग या संख्या हो सकती है।
- कोड में कोई भी वर्ण हो सकता है। मेल खाते हुए लोगों की
[a-z ]
अनदेखी नहीं की जानी चाहिए।
really
यदि स्टैक के ऊपर मल्टी-कैरेक्टर स्ट्रिंग है तो क्या करें?
yes yes oh
प्रिंट नहीं होना चाहिए 11
?
[a-zA-Z ]
?