จาวาสคริปต์, 153
(function(g){o=[],f=g[0];for(;i<g[1];i++)for(n=0;n<=i;n++)for(_=n;_<f;_+=n+1)o[_]=!o[_];for(;f--;)o[f]&&(l=f+1+s+l);alert(l)})(prompt().split(i=l=s=' '))
เอาต์พุตสำหรับ N = 23, K = 21:
1 2 4 8 9 16 18 23  
ผ่านการทดสอบใน Chrome แต่ไม่ได้ใช้ฟีเจอร์ ECMAScript ที่แปลกใหม่ดังนั้นควรทำงานกับเบราว์เซอร์ใด ๆ !
ฉันรู้ว่าฉันจะไม่ชนะรายการอื่น ๆ และ @tryingToGetProgrammingStrainght ได้ส่งรายการใน JavaScript แล้ว แต่ฉันไม่ได้รับผลลัพธ์เดียวกันสำหรับ N = 23, K = 21 เนื่องจากทุกคนเข้าร่วมด้วยดังนั้นฉันคิดว่าฉัน ต้องไปที่รุ่นของฉันเอง
แก้ไข : แหล่งที่มาหมายเหตุประกอบ (ในการดูสิ่งนี้อีกครั้งฉันเห็นสถานที่เพื่อบันทึกอีก 3 ตัวอักษรดังนั้นมันอาจจะยังคงได้รับการปรับปรุง ... )
(function(g) {
    // initialise variables, set f to N
    o = [], f = g[0];
    // round counter
    // since ++' ' == 1 we can use the same variable set in args
    for (; i < g[1]; i++)
        // monkey counter, needs to be reset each round
        for (n = 0 ; n <= i; n++)
            // iterate to N and flip each Kth door
            for (_ = n; _ < f; _ += n + 1)
                // flip the bits (as undef is falsy, we don't need to initialise)
                // o[_] = !~~o[_]|0; // flips undef to 1
                o[_] = !o[_]; // but booleans are fine
    // decrement f to 0, so we don't need an additional counter
    for (;f--;)
        // build string in reverse order
        o[f] && (l = f + 1 + s + l); // l = (f + 1) + ' ' + l
    alert(l)
    // return l // use with test
// get input from user and store ' ' in variable for use later
})(prompt().split(i = l = s = ' '))
// })('23 21'.split(i = l = s = ' ')) // lazy...
// == '1 2 4 8 9 16 18 23  '; // test