👼Polyglot implementations of "safadeza" calculus.
Polyglot implementations of "safadeza" calculus.
Sometimes, you want to know how safad(o/a) - a Brazilian Portuguese word for naughty - someone is. A very popular Brazilian musician desbribes himself as being
99%an angelical and perfect person; but the other
1%is naughty - as you can see in the lyrics.
A very clever professor from a state university in Brazil proposed a way o calculing how safado some is based on his/her date of birth.
The magical formula needs:
sumfunction which takes an
inta returns the sum of it with all its previous positive integers, e.g.
sum(5) = 5 + 4 + 3 + 2 + 1.
safadezafunction which is given by:
safadeza = sum(month) + (year / 100) * (50 - day)
angelfunction which is given by:
angel = 100 - safadeza
The last two functions MUST return a float
So this repo is for writing code that shows others how safado they are.
I look forward to seeing what you come up with c:
The programming question which quotes Wesley Safadão and turned to be a hit on the web.
It all started when a professor from the Quixadá campus of the Federal University of Ceará - Universidade Federal do Ceará (UFC) - Jefferson de Carvalho called everyone's attention by using a hit of the sertanejo and forró music to teach imperative programming logic to his students.
He was inspired by the song Aquele 1%, which is a success from the duo Marcos & Belutti featuring a very popular Brazilian musician, Wesley Safadão, to write his logical challenge.
version-*in the folder!
- [x]in GitHub Flavored Markdown - in which you've implemented here.
git push origin master.
git push origin master.
You can check a list of languages in which the problem's been implemented - or should've been - here.
This project may seem useless, but, amazingly, it is not.
In about two days it achieved something interesting: a deterministic algorithm said to be simple which when implemented in 40+ languages, tells us a lot! E.g.
It shows us a different programming logic from the imperative one we are probably used to think, such as declarative.
It allows us to think in different paradigms from the ones we are probably used to think, e.g. functional and logical ones.
It allows us to study and analyze new implementations in new langs, for example: a taste of Smalltalk's pure Object Orientation - hooray for Allan Kay, Adele Goldberg et al! - or a bit of functional programming in Haskell - and its beautiful type system, monads etc. - or the different logic that a language based on Horn Clauses such as Prolog reveals.
Or, amazingly, the underground languages that we don't know - after all, getting to know a DSL written in JS, which has a different approach to prototype-based OO or a declarative DSL written in TypeScript and LiveScript which has a type system inspired by Idris and aims printers is not something you do every day.
So the lesson is: that kind of initiative shows us that in modern times not only with FizzBuzz-alike implementations you can learn programming logic/languages/ paradigms.
safadômetro is distributed under the MIT License, available in this repository. All contributions are assumed to be also licensed under the MIT License.
Wesley Oliveira da Silva, also known as Wesley Safadão, is a Brazilian singer, songwriter, producer, and businessman. The safadômetro project does not have any rights over anything related to the him; images, logos, and everything related to the him have All Rights Reserved to Wesley Safadão & Banda Garota Safada.