Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
38 views

Algorithm Coding Challenges: Challenge 1 What's The Time Mr. Wolf

The document describes 11 coding challenges involving tasks like calculating time differences, determining the day of the week for a given date, identifying the century for a given year, calculating how long a spider takes to climb a distance, checking if numbers are positive/odd/even, comparing remainders from division, checking the last digit of a number, comparing properties of multiple numbers, ordering numbers, and determining the color of a square on a chess board based on row and column numbers. The challenges involve taking basic integer inputs and providing short string outputs based on logical evaluations and calculations performed on the inputs.

Uploaded by

Ahmed Shahin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

Algorithm Coding Challenges: Challenge 1 What's The Time Mr. Wolf

The document describes 11 coding challenges involving tasks like calculating time differences, determining the day of the week for a given date, identifying the century for a given year, calculating how long a spider takes to climb a distance, checking if numbers are positive/odd/even, comparing remainders from division, checking the last digit of a number, comparing properties of multiple numbers, ordering numbers, and determining the color of a square on a chess board based on row and column numbers. The challenges involve taking basic integer inputs and providing short string outputs based on logical evaluations and calculations performed on the inputs.

Uploaded by

Ahmed Shahin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Algorithm

Coding Challenges

Challenge 1
What’s the time Mr. Wolf.

Calculate and display the number of seconds which have
elapsed between the two time stamps.


Inputs are hourStart, minuteStart and secondStart. hourEnd,
minuteEnd and secondEnd.


Example
1
1
1
2
2
2
Total Seconds: 3661

Challenge 2
What day is it!?


Take an input integer number from 1 to 365, output the day of the
week that this day would be. Assume that January 1st this year was a
Friday (This can be day 0, with Sunday represented by 2 etc)

Input:
Day: 1
This was a Friday (1)

Day: 3
This was a Sunday (3)

Day: 10
This was a Sunday (3)

Challenge 3
What century is it!?

Given an input as a positive integer, output the century a particular year
falls in.
Keep in mind, the 20th Century began on 1901 and ended on 2000.

Input:
Year: 1899
19 TH Century

Year: 1901
20 TH Century


Challenge 4
Itsy Bitsy Spider

A spider climbs up h centimeters per night, slipping back down f
centimeters when sleeping.

How long does a spider take to climb X centimetres (h must be > f)


The program should output the number of days

Input:
h: 3
f: 2
X: 10
8 days required

h: 7
f: 3
X: 20
5 days required


Challenge 5
Are you positive!?

Given an input integer, print ‘YES’ if it is positive, ‘NO’ otherwise

Input: 12
YES

Input: -6
NO

Challenge 6
That’s odd!

Given an input integer, print ‘ODD’ if the number is odd, display ‘EVEN’
otherwise (any special numbers which should print neither?)

Input: 12
EVEN

Input: -7
ODD









Challenge 7
Remainder Remainder!

Given an input integer A and an input integer B, if A is larger than B,
output “yes” if A perfectly divides by B and “no” otherwise

Input A: 12
Input B: 6
Remainder: 0
yes

Input A: 14
Input B: 5
Remainder: 4
no


Challenge 8
Lucky 8’s

Given an input integer, print ‘YES’ if
the last digit in the number is 8, ‘NO’
otherwise

Input: 1228
YES

Input: 107
NO










Challenge 9
Oddly Peculiar

Given two integer inputs, output ‘ODD’
if both numbers are odd, ‘EVEN’ if both
numbers are even and ‘NEITHER’ in any
other scenario.

Input: 12
Input: 13
NEITHER

Input: 14
Input: 16
EVEN

Challenge 10
Ascending and Descending

Given three input integers, output ‘ASCENDING’ if they are in
ascending order, ‘DESCENDING’ if in descending order, otherwise
display ‘MIXED’

Input: 12
Input: 13
Input: 14
DESCENDING

Input: 8
Input: 13
Input: 124
ASCENDING

Input: 13
Input: 10
Input: 14
MIXED

Challenge 11
Check Mate

Given two input integers (both in range 1 to 8). Output if the square is
‘BLACK’ or ‘WHITE’

Input: 1
Input: 1
Output: BLACK

Input: 4
Input: 7

Output: WHITE

You might also like