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

Top comments (0)