Skip to content

Instantly share code, notes, and snippets.

@sherif-gamal
sherif-gamal / lamma-bada.rb
Created October 4, 2018 12:14
Lamma bada yatathanna remix - Sonic Pi
_ = 4
s = 1.0 * _
m = s/2
c = s/4
dc = c * 1.5
q = s/8
sq = s/16
dsq = s/32
hdsq = s/64
qhdsq = s/128

Keybase proof

I hereby claim:

  • I am sherif-gamal on github.
  • I am sgamal (https://keybase.io/sgamal) on keybase.
  • I have a public key ASDdFct09uwYb_sohDvDZdLima62O27Atu5QaLAMMnaR1go

To claim this, I am signing this object:

write a program that, given an unsorted array that contains all the numbers from 1 to n except one unknown number, returns the missing number.

Do it in ruby in two different ways.

A palindrome string is a string that reads the same forwards and backwards, e.g. deleveled, deified and Hannah etc. are all palindromic strings. Also "A man, a plan, a canal: Panama.", "Al lets Della call Ed Stella." and "Anne, I vote more cars race Rome to Vienna."

Write a ruby program that, removes all punctuations from a string checks whether it is palindrome or not, in three different ways.

For some test cases see: http://www.palindromelist.net/

The Collatz conjecture is a conjecture in mathematics named after Lothar Collatz, who first proposed it in 1937. It's also known as the 3n + 1 conjecture, the Ulam conjecture, the Kakutani's problem, the Thwaites conjecture, Hasse's problem or the Syracuse problem, the sequence of numbers that results is referred to as the hailstone numbers or the wondrous numbers.

The problem is defined as follows:

Starting with any number n, if the number is even, halve it, if it's odd triple it and add one. And keep repeating until you reach 1

Happy Numbers

A happy number is defined by the following process:

Starting with any positive integer, 
replace the number by the sum of the squares of its digits,
repeat the process until the number equals 1 (where it will stay),
or it loops endlessly in a *repeating* cycle which does not include 1.   
Write a program that can calculate the sum of the first n elements of the following sequences:
s1 = 1 - 1 + 1 - 1 + 1 - 1 + ....
s2 = 1 + 2 + 3 + 4 + 5 + 6 + ....
For example:
s1(4) = 0
s2(4) = 10

The Fibonacci sequence is one of the coolest sequences in mathematics. The sequence is: 1,1,2,3,5,8,13,....

You can calculate the nth fibonacci number from the following formula: F(n) = F(n - 1) + F(n - 2)

The sequence is named after the Italian mathematician Leonardo of Pisa (Leonardo Fibonacci). The ratio between two consecutive Fibonacci numbers tends to 1.61538... which is called the golden ratio, golden number, divine ratio, etc. If you draw the numbers in rectangles of the same area you will end up drawing a golden spiral. This magic ratio and magic spiral appear surprisingly often in nature, sunflower, starfish, human body (ratios between bones), sea waves follow this spiral even

There are 10 types of people in the world: Those who understand binary, and those who don't.

You and your fellow cohort of those in the "know" when it comes to binary decide to come up with a secret "handshake".

1 = wink
10 = double blink
100 = close your eyes
1000 = jump