Dynamic Programming

>Lol just use recursion brah
Basically they're saying I can solve any fucking programming problem by calling the function over and over again like magic

>implying you can't

>Dynamic Programming
aka Sequential Optimization

dumb frogposter

>like magic
this is not the right board for you. try ?

ITT: People who aren't able to implement fizzbuzz

>with no iterations, only recursion
>without any arithmetics besides +/- 1
>without any use of the literals 3, 5 or 15

I'll post a super fucking dumb solution that fits these requirements, it's gonna be so fucking dumb you'll feel dumb for suggesting this challenge.

Computer science only know recursion as proof method, hey everything is recursive.

I will genuinely enjoy that.

Hard mode: no variables except functions and function arguments.

#include

using namespace std;

void fizzbuzz(int i) {
if (i > 100)
return;
else {
cout

Pretty good.

Here's my non hard-mode:
### Functions ###
range = $(if $(filter $1,$(lastword $3)),$3,$(call range,$1,$2,$3 $(words $3)))
make_range = $(foreach i,$(call range,$1),$(call range,$2))
equal = $(if $(filter-out $1,$2),,$1)


### Variables ###
limit := 101
numbers := $(wordlist 2,$(limit),$(call range,$(limit)))

threes := $(wordlist 2,$(limit),$(call make_range,$(limit),2))
fives := $(wordlist 2,$(limit),$(call make_range,$(limit),4))

fizzbuzz := $(foreach v,$(numbers),\
$(if $(and $(call equal,0,$(word $(v),$(threes))),$(call equal,0,$(word $(v),$(fives)))),FizzBuzz,\
$(if $(call equal,0,$(word $(v),$(threes))),Fizz,\
$(if $(call equal,0,$(word $(v),$(fives))),Buzz,$(v)))))


### Target ###
.PHONY: all
all: ; $(info $(fizzbuzz))


And here's my hardmode one:
select = (a, b, c) => a + b || c

cycler = (v) => () => {
v.push(v.shift());
return v[v.length + -1];
};

fizz = cycler(['','','Fizz'])
buzz = cycler(['','','','','Buzz'])

Array.from({length: 100}, (_, i) => console.log(select(fizz(), buzz(), i + 1)))

I cheated a bit but tried to make it convoluted:

var three = 1+1+1;
var five = three + 1 + 1;
var fifteen = five + five + five;

function fizz(i) { if(i==1) return "fizz"; };
function buzz(i) { if(i==1) return "buzz"; }
function fizzbuzz(i) { if(i==1) return "fizzbuzz"; }

function koding(i, j, k, l) {
if(i>=100) return;
console.log(fizzbuzz(l) || buzz(k) || fizz(j) || i);
if(j == 0) j = three;
if(k == 0) k = five;
if(l == 0) l = fifteen;
koding(i+1, j-1, k-1, l-1);
}

koding(1, three, five, fifteen);

Pretty good.

I'm realizing it now and I'm sick of it

>it just werks bro

What language is the first one?

its not just recursion you fucking mental midget
you need to cache or memoize something as well

kys

GNU Make.

#include
#include

typedef struct piece {
char *str;
struct piece *next;
} Piece;

static Piece * fizz_buzz_list = NULL;

static void
initialize_fizz_buzz()
{
Piece *p;
static int _initialized = 0;
if(_initialized) return;
p = malloc(sizeof(Piece));
p->str = "%d";
fizz_buzz_list = p;
p->next = malloc(sizeof(Piece));
p = p->next;
p->str = "%d";
p->next = malloc(sizeof(Piece));
p = p->next;
p->str = "Fizz";
p->next = malloc(sizeof(Piece));
p = p->next;
p->str = "%d";
p->next = malloc(sizeof(Piece));
p = p->next;
p->str = "Buzz";
p->next = malloc(sizeof(Piece));
p = p->next;
p->str = "Fizz";
p->next = malloc(sizeof(Piece));
p = p->next;
p->str = "%d";
p->next = malloc(sizeof(Piece));
p = p->next;
p->str = "%d";
p->next = malloc(sizeof(Piece));
p = p->next;
p->str = "Fizz";
p->next = malloc(sizeof(Piece));
p = p->next;
p->str = "Buzz";
p->next = malloc(sizeof(Piece));
p = p->next;
p->str = "%d";
p->next = malloc(sizeof(Piece));
p = p->next;
p->str = "Fizz";
p->next = malloc(sizeof(Piece));
p = p->next;
p->str = "%d";
p->next = malloc(sizeof(Piece));
p = p->next;
p->str = "%d";
p->next = malloc(sizeof(Piece));
p = p->next;
p->str = "Fizz Buzz";
p->next = fizz_buzz_list;
_initialized = 1;
}

static char *
list_element(Piece *p, int el)
{
if (el > 1)
return list_element(p->next, --el);
else
return p->str;
}

void
fizz_buzz(int n)
{
initialize_fizz_buzz();
if (n-1 != 0) {
fizz_buzz(n-1);
fputs(", ", stdout);
}
printf(list_element(fizz_buzz_list, n), n);
}

What the actual fuck is this monstrosity?

linked list

Doesn't even work lol, if you call fizzbuzz(2) the numbers will all be wrong

then dont call fizzbuzz(2) retard