The inverted pyramid puzzle

The other day, I was talking to a friend of mine about the Z3 theorem solver and he mentioned the inverted Pyramid puzzle. I told him: “I think this can be solved with Z3” and hence this blog post.

So what’s the inverted pyramid puzzle?

Imagine the following pyramid with 4 rows:

 10   9   8   7
    6   5   4
      3   2
        1

The numbers in that triangle are just placeholders for the sake of explanation.
The goal of the puzzle is to find the right order for those numbers in the triangle in such a way that:

For the 4th row, we must have whatever is at the position denoted with [number] subtracted from its neighbor equals the value of the next row’s value beneath the top 2 numbers (note: we take the absolute value of the subtraction). So:

|[10] - [9]| == [6]
|[9] - [8] | == [5]
|[8] - [7] | == [4]

And for the 3rd row, we must have:

|[6] - [5]| == [3]
|[5] - [4]| == [2]

And for the 2nd row, we must have:

|[3] - [2]| == [1]

Of course, we stop at the first row.

For now, here’s a solution for the inverted pyramid with 4 rows:

 8 10  3  9
  2  7  6
   5  1
    4

The numbers configuration from above satisfies the conditions explained above.

Please note that the only numbers accepted in the pyramid are [1..Sigma(rows)]. Sigma denotes the sum of the arithmetic series going from 1 to rows. Continue reading “The inverted pyramid puzzle”

21 formulas for wholesome living

Chain emails sometimes bring more than entertainment, sometimes they bring wisdom. Enjoy:

  1. Live beneath your means
  2. Return everything you borrow
  3. Stop blaming other people
  4. Admit it when you make mistakes
  5. Give clothes not worn to charity
  6. Do something nice and try not to get caught
  7. Listen more, talk less
  8. Every day, take a 30 minutes walk
  9. Strive for excellence, not perfection
  10. Be on time. Don’t make excuses
  11. Don’t argue. Get organized.
  12. Be kind to unkind people
  13. Take time to be alone
  14. Cultivate good manners
  15. Be humble
  16. Realize and accept that life is not fair
  17. Know when to keep your mouth shut
  18. Go an entire day without criticizing anyone
  19. Learn from the past. Plan for the future
  20. Live in the preset
  21. Don’t sweat the small stuff…it’s all small stuff



You might also like:

Can you solve this puzzle?

I got this silly puzzle via chain mail:

Can you solve it?

Maybe you will be able to, but don’t beat yourself up if you don’t get it right.

You might also like:

Statistics about Lebanon

I found this information on the internet, if you find inaccuracies, let me know please.

Statistical facts

  1. Lebanon has 18 religious communities
  2. It has 40 daily newspapers
  3. It has 42 universities
  4. It has over 100 banks (that is banks and not branches of a bank)
  5. 70% of the students are in private schools
  6. Many of the Lebanese people are Christians (The highest percent in all the Arab countries)
  7. There’s 1 doctor per 10 people in Lebanon (In Europe & America , there’s 1 doctor per 100 people)
  8. The name LEBANON appears 75 times in the Old Testament
  9. The name CEDAR ( Lebanon ‘s tree) appears 75 times too in the Old Testament!!
  10. Beirut was destroyed and rebuilt 9 times (this is why it’s compared to The Phoenix).
  11. There’s 3.5 Million Lebanese in Lebanon
  12. There’s around 15 Million Lebanese outside Lebanon !!!
Other interesting facts:
  1. Lebanon , the country, was occupied by over 16 countries:
    (Egyptians-Hittites-Assyrians- Babylonians- Persians- Alexander the greats Army- the Roman Empire Byzantine- the Arabian Peninsula-The Crusaders- the Ottoman Empire- Britain-France- Israel- Syria)
  2. Byblos (city in Lebanon ) is the oldest, continuously living city in the world.
  3. Lebanon ‘s name has been around for 4,000 yrs non- stop (it’s the oldest country/ nation’s name in the world!)
  4. Lebanon is the only Asian/African country that doesn’t have a desert.
  5. There are 15 rivers in Lebanon (all of them coming from its own mountains)
  6. Lebanon is one of the most populated countries in its archeological sites, in the world!!!
  7. The first alphabet was created in Byblos (city in Lebanon )
  8. The only remaining temple of Jupiter (the main Roman god) is in Baalbeck ,Lebanon (The City of the Sun)
  9. The name of BYBLOS comes from the BIBLE!!!
  10. Lebanon is the country that has the most books written about it.
  11. Lebanon is the only non-dictatorial country in the Arab world (Yes, we do have a President!)
  12. Jesus Christ made his 1st miracle in Lebanon , in Qana (The miracle of Turning water into wine).
  13. The Phoenicians (Original People of Lebanon) built the 1st boat, and they were the first to sail ever!
  14. Phoenicians also reached America long before Christopher Columbus did.
  15. The 1st law school in the world was built in Lebanon , in Downtown Beirut.
  16. People say that the cedars were planted by God’s own hands (This is why they’re called ‘The Cedars of God’, and this is why Lebanon is called ‘God’s Country on Earth.’

I love Lebanon ….. may God bless my homeland forever….

First trip to Lebanon
First time To Lebanon? The Untold tips and tricks

You might also like:

If your plan is for 100 years, educate children

If your plan is for 1 year, plant rice.
If your plan is for 10 years, plant trees.
If your plan is for 100 years, educate children.

You might also like:

Excerpts from the “Blizzard Cosplay: Tips, Tricks and Hints” book

A hardcover copy of the “Blizzard Cosplay: Tips, Tricks and Hints” book was released on October 15, 2018. It has stunning CosPlay images.

Here’s a small taste of it:

You might also like:

 

 

All must fulfill their three debts

I was watching the Mahabharata and they spoke about the 3 kinds of debts that one has to fulfill in his/her lifetime: God’s debt, Sage’s debt, Ancestral debt.

All must fulfill their debts three,
God’s, Sage’s, Ancestral surely,
Before death and leaving body,
Else life itself is insulted sadly.
These debts not ordinary do be,
God’s debt – Lord Vishnu’s be,
Sage’s debt – Lord Shiv’s be,
Ancestral debt – Brahma’s be.
God’s debt by charity fulfilled be,
Sage’s by acquiring, giving be,
But of the knowledge definitely,
Ancestral debt by having progeny.

God’s debt can be fulfilled by doing charity work. I am not surprised by that. It is known in many esoteric circles that charity is a very important deed. The Bible and Masonic literature talk a lot about charity.

Sage’s debt can be fulfilled by learning, acquiring wisdom and imparting knowledge to others.

And it goes without saying that ancestral debt can be fulfilled by procreating and continuing our ancestral lineage. That is not to say that one should procreate mindlessly but instead procreate with high morality and spiritual standards. One has to bring children to the world so they help improve the world and not “pollute” the world and be like parasites.


You might also like:

Different foods and their digestion times

It is a curious and helpful thing to know how much time the food we eat takes to digest. Digestion time is different than the time the food remains in our body before it gets expelled.

You might also like:

Two things

Two things do not remain for ever in humans: youth and strength
Two things beneficial for every human: good manners and generosity
Two things that hurt every man: darkness and corruption
Two things every man hates: envy and bitterness
Two things pursued by every man: fame and money
Two things that never change in a human: looks and character
Two things you spend your life between: evening and day, tiredness and restfulness
Two things that conflict your soul: the lust of the body and the lust of the soul
Two things are enemies of health: deep sorrow and deep love
Two things are enemies of peace: greed and envy
Two things are enemies of the society: the traitor and the lazy
Two small things: the heart and the tongue
Two stones: gold and silver
Two alternates: day and night
Two whites: water and yogurt
Two courts: the world and the afterlife



You might also like:

Riddle: How many brothers and sisters are there in this family? Z3 Theorem prover

The other day, I ran into a riddle:

A brother said to his sister: “I have as many sisters as brothers”
His sister replied: “I have twice as many brothers as I have sisters”

How many brothers and sisters exist in this family?

I figured that it’s a nice exercise for the Z3 theorem prover. All I had to do is express the riddle in a series of constraints and ask Z3 to try to find a solution.

The following is a Z3Py program that expresses the riddle:

import z3

# Create a solver instance
s = z3.Solver()

# Create two variables representing the total number of males and females (m and f)
m, f = z3.Ints('m f')

# The brother said: I have as many brothers as sisters
s.add(m - 1 == f)

# The sister said: I have twice as much brothers as I have sisters
s.add(2 * (f - 1) == m)

# Check for the solution
if s.check() == z3.sat:
  sol = s.model()
  print "Brothers: %d, Sisters: %d" % (sol[m].as_long(), sol[f].as_long())

When we run the solver, we get the following solution: 4 males, 3 females.

If you prefer the good old systems of equations, we can solve it like this:

The brother said:
m - 1 = f          (1)

The sister said:
2 * (f - 1) = m    (2)


So we have 2 equations, let's do some substitution:

-> f = m - 1        (1)
-> 2f - 2 = m       (2)

--> m = 2f - 2      (2)
--> f = 2f - 2 - 1  (1)
--> f = 2f - 3
--> f - 2f = -3
--> -f = -3
--> f = 3

--> m = 2f - 2
--> m = 2*3 - 2
--> m = 6 - 2
--> m = 4

 

You might also like:

Unhealthy food cravings and their healthy counterparts

Often times a modern man craves unhealthy and junk food that did not exist before (artificial sweeteners, transfats, fast food etc.). What to do in this case?

Cave in and eat unhealthy foods? or try to find a more healthy alternative to satisfy those cravings?


You might also like:

A warrior has two friends and two enemies

A while back, I was watching the Mahabharat series by B.R Chopra. It contains lots of nice moral stories and wisdom. One thing I am sharing with you is the following:

The warrior has two enemies: Sleep and Tiredness.

He has two friends: Hard work and caution.

The warrior who can vanquish these enemies and befriend these two friends will be undefeatable.
A person should not be jealous.
Jealousy neutralizes a person’s good points.


You might also like: