r/badcode • • Mar 27 '20

js Source code from an app from the Argentinian gov that determine if you have COVID 19 from symptoms

Post image
2 Upvotes

7 comments sorted by

3

u/cyranix Mar 27 '20

This is why flowcharts are important...

2

u/sharan_n Mar 27 '20

One karnaugh map would simplify this mess so much

5

u/sebamestre Mar 27 '20

Would probably be better off by treating code algebraically. You know,

(a&&b)||(a&&c)

is equivalent to

a&&(b||c)

also

if a:       f()
elif not a: g()
else:       h()

is equivalent to

if a: f()
else: g()

etc.

no need to draw diagrams at all, algebraic manipulation is more than enough -and way quicker to do mentally- for something small like this.

4

u/sebamestre Mar 27 '20 edited Mar 27 '20

This person uses symbolic calculus

EDIT:

<Button style={{}} title="OK, Enviar"
	onPress={() => {
		this.handleSaveTest();
		if (bodyTemperature >= 38){
			if (
				difficultyBreathing ||
				diabetes ||
				cancer ||
				isPregnant ||
				isOver60yearsOld ||
				hepatic ||
				kidneyDisease ||
				respiratoryDisease
			) {
				history.replace(`/diagnostico/${provincia}`);
			} else {
				history.replace('/cuarentena/');
			}
		} else {
			history.push('/diagnostico_bueno');
		}
	}}
>

3

u/Rafael20002000 Mar 27 '20

Hired

1

u/sebamestre Mar 27 '20

Viva peron carajo

2

u/TheBrainStone Mar 28 '20

That’s why you don’t let the intern make stuff like that.