डीसी, 104 बाइट्स
इनपुट टर्मिनल से लिया जाता है, आउटपुट प्रिंट होता है और स्टैक पर भी।
क्योंकि यह उपयोग करता है? ऑपरेटर, आपको उपयोग करने की आवश्यकता है dc -e "<solution>"या dc <file with solution in it>।
कोई भी कभी भी मेरे उत्तर नहीं देखता है, अकेले उन पर वोट दें, लेकिन मुझे वास्तव में डीसी में समस्याओं को हल करने में मजा आता है। यह इस धागे में अब तक का सबसे कम कुशल समाधान है, लेकिन मैंने सोचा कि मैं इसे वैसे भी पोस्ट करूंगा।
1sb?sn[lesi]ss[lble1+dse^dln=sln>c]sc[liSflq1+sq]sm[Lfplq1-dsq0<p]dsp[lb1+sb0si0selcxli0!=mlbln!=h]dshxx
स्टार्टर सामान
1sb Store 1 in register b
?sn Store user input in register n
[lesi]ss A macro to copy the e to the i register, stored in the s register
मैक्रो सभी शक्तियों के लिए एक आधार जुटाने के लिए जब तक कि परिणाम लक्ष्य से बड़ा या लक्ष्य के बराबर न हो
[lble1+dse^dln=sln>c]sc
[lb ] load our base num (register b)
[ le ] load our exponent (register e)
[ 1+dse ] add 1 to the exponent, copy and store in the e register
[ ^d ] raise the base to the exponent and copy it
[ ln=s ] load the user input, if that is equal to the power result run the macro in register s
[ ln>c] load the user input, if it's greater than the power result run the macro in register c (this one)
[ ]sc save this macro in register c
मैक्रो एक वैध घातांक मान को बचाने के लिए जैसा कि उपरोक्त घातांक मैक्रो से दूसरे स्टैक में पाया जाता है
[liSflq1+sq]sm
[liSf ] copy the i register to the top of the stack in register f
[ lq1+sq] add 1 to the q register
[ ]sm save this macro in the m register
मैक्रो 2 से हमारे लक्ष्य संख्या तक सभी ठिकानों के माध्यम से मैक्रो (मैक्रो सी) के ऊपर 2x को चलाने के लिए
[lb1+sb0si0selcxli0!=mlbln!=h]dsh
[lb1+sb ] add 1 to the base number
[ 0si0se ] reset the i and e registers (previously found value and exponent
[ lcx ] load and run the c macro
[ li0!=m ] load the result of the c macro and if it's not 0, run m to save it to the f stack
[ lbln!=h] if our base number is not equal to our target number, run macro h (this macro)
[ ]dsh duplicate this macro and save one copy, so that one is left on the stack to run later
मैक्रो को एफ स्टैक से मान प्रिंट करने के लिए
[Lfplq1-dsq0<p]dsp
[Lfp ] load the top value from the f register and print it
[ lq1-dsq ] load the q register and subtract one from it and save it
[ 0<p] if the q register is greater than 0, run macro p (this macro) again
[ ]dsp duplicate this macro and save one copy, so that one is left on the stack to run later
xx finally run the two macros on the stack (h and then p)
[1 2 3 6]आखिरी टेस्ट केस के लिए प्रिंट करता है। यह भी मुद्रित कर सकते हैं[6 3 2 1],[1.0 2.0 3.0 6.0]या[6.0 3.0 2.0 1.0]?