Code Challenge

Here’s a challenge for you, Jow Forums.

Write a solver for Hanoi towers, knowing there will be exactly 5 disks on it.

PLOT TWIST (dun, dun, dun): Recursivity is not allowed.

Go.

Attached: 9AAF1A8D-4CF6-4840-93EC-813C800AA551.gif (404x125, 3K)

Other urls found in this thread:

hanoitower.mkolar.org/algo.html
web.archive.org/web/20040605074124/http://yupana.autonoma.edu.co/publicaciones/yupana/003/hanoi/hanoi_eng.html
twitter.com/SFWRedditImages

Do your own homework

require 'hanoi_solver'

HanoiSolver.solve(ARGV)

Do your own homework, jamal

just make the AI do it lmao

>use tail recursion in c++
>clang optimizes it away
>submit assembly
wow that was hard

while not solved:
move random disk to random peg

Go back to Vietnam and solve your own goddamn towers you commie

>iOS filename
fuck off

The trick is to use a stack

ezpz
#!/usr/bin/python
from PIL import Image
hanoi = Image.open('1549334993918.gif')
solution = hanoi.transpose(Image.FLIP_LEFT_RIGHT)
solution.save('solved.gif')

Attached: solved.gif (404x125, 12K)

>there will be exactly 5 disks on it
so close

My solver is generalized and works for any number of disks

top kek

> 2^n - 1 steps
> paltry 5 disks

nigger just hardcode that shit

int main(void)
{
int n, x;

printf( "How many disks? " );
scanf( "%d", &n );
puts( "\n\n" );

for (x=1; x < (1

Attached: CPM_CLUB12.png (1066x554, 36K)

Hanoi with tail rec. Wanna see that.

>recursivity is not allowed
you cant use the easiest, most efficient, and most maintainable solution because... uhhhhh... i said so
no thanks, ill just get a job somewhere that isnt run by retards

here is

Use stack, negro

Interesting, gonna test that.

hanoitower.mkolar.org/algo.html
web.archive.org/web/20040605074124/http://yupana.autonoma.edu.co/publicaciones/yupana/003/hanoi/hanoi_eng.html

Note that the generalized one doesn't use recursion.