Talk:Stair-climbing puzzle: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
Line 2: Line 2:
The problem is ambiguous as stated. It says to climb one step up, not climb up one step up from the starting position. Thus the original C# code that was there solved the 'climb one step up'. <span style="font-size: smaller;" class="autosigned">—Preceding unsigned comment added by [[Special:Contributions/71.59.209.100|71.59.209.100]]</span>
The problem is ambiguous as stated. It says to climb one step up, not climb up one step up from the starting position. Thus the original C# code that was there solved the 'climb one step up'. <span style="font-size: smaller;" class="autosigned">—Preceding unsigned comment added by [[Special:Contributions/71.59.209.100|71.59.209.100]]</span>
:Okay, I've made it more explicit. —[[User:Underscore|Underscore]] 00:30, 7 November 2009 (UTC)
:Okay, I've made it more explicit. —[[User:Underscore|Underscore]] 00:30, 7 November 2009 (UTC)
Am I wrong or recursion can be simply avoided since the "action" is done indeed into step? So the following C code
<lang c>
void step_up()
{
while ( !step() ) ;
}
</lang>
would work? Why is used recursion if indeed <tt>step_up</tt> does nothing more? ... --[[User:ShinTakezou|ShinTakezou]] 10:30, 7 November 2009 (UTC)

Revision as of 10:30, 7 November 2009

Problem statement

The problem is ambiguous as stated. It says to climb one step up, not climb up one step up from the starting position. Thus the original C# code that was there solved the 'climb one step up'. —Preceding unsigned comment added by 71.59.209.100

Okay, I've made it more explicit. —Underscore 00:30, 7 November 2009 (UTC)

Am I wrong or recursion can be simply avoided since the "action" is done indeed into step? So the following C code <lang c> void step_up() {

 while ( !step() ) ;

} </lang> would work? Why is used recursion if indeed step_up does nothing more? ... --ShinTakezou 10:30, 7 November 2009 (UTC)