DEV Community

Abubakar Sadiq Ismail
Abubakar Sadiq Ismail

Posted on

Day 4 I4G Code Challenge

Day 4!!!! Yay
Today's problem is interesting and challenging as well Javascript is not included in the programming language I can solve the problem with.
So I had to choose another programming language, python is always the next tool to use if Js will not solve my problem
.
The problem statement seems bizarre and a big problem but it's pretty simple and straight forward when you understand the problem.
Problem. Print In order
Tag: Easy
Given three method in a class
class foo():

firt(self):
print("first line")

second(self):
print("second line")
third(self):
print("third line")

The task is to modify the above methods such that calling
foo = foo()

foo.first()
foo.second()
foo.third()
//or
foo.first()
foo.third()
foo.second()

//or
foo.third()
foo.first()
foo.second()

Or any permutation of this calls can result in
//first line
//second line
// third line
irrespective of how they are called;

What first come to my mind is to delay third method for some time,delay second method for less time and first method will fire immediately.
So that third will wait for first and second, second will wait for first.
first fires immediately.
I use python in built time module for that.

Print Order problem

Code Implementation

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay