# Puzzle: Century From Year \[reference\]

**URL:** <https://forum.codeselfstudy.com/t/puzzle-century-from-year-reference/2483>\
**Category:** Puzzles and Logic\
**Created:** [November 5, 2020, 7:40pm UTC](https://forum.codeselfstudy.com/t/puzzle-century-from-year-reference/2483 "2020-11-05T19:40:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![content\_bot](https://forum.codeselfstudy.com/letter_avatar_proxy/v4/letter/c/9d8465/32.png) [@content\_bot](https://forum.codeselfstudy.com/u/content_bot)\
**Post date:** [November 5, 2020, 7:40pm UTC](https://forum.codeselfstudy.com/t/puzzle-century-from-year-reference/2483/1 "2020-11-05T19:40:01Z")

</div>

“ **Century From Year** ” is a coding puzzle that people can be attempted in the following languages: cpp, python, javascript, haskell, go, csharp, c, ruby, crystal, php, typescript, powershell, scala, groovy, coffeescript, java, julia, lua, r, kotlin, nim, nasm, clojure, rust, dart, elixir, fsharp, racket, reason, shell, factor, sql, purescript, forth, elm, swift, ocaml, vb, erlang, fortran, objc, solidity, prolog, and cfml.

- **Difficulty:** 8 kyu
- **Stars:** 442
- **Votes:** 4135
- **Category:** reference
- **Tags:** Fundamentals, Numbers, Data Types, Mathematics, Algorithms, Logic, Basic Language Features, Dates/Time
- **Source:** [codewars](https://www.codewars.com/kata/5a3fe3dde1ce0e8ed6000097)

# Description

# Introduction

The first century spans from the **year 1** _up to_ and **including the year 100** , **The second** - _from the year 101 up to and including the year 200_, etc.

# Task :

Given a year, return the century it is in.

## Input , Output Examples ::

```auto
cpp
centuryFromYear(1705) returns (18)
centuryFromYear(1900) returns (19)
centuryFromYear(1601) returns (17)
centuryFromYear(2000) returns (20)

```

```auto
racket
(century 1705) returns 18
(century 1900) returns 19
(century 1601) returns 17
(century 2000) returns 20

```

```auto
if:sql
In SQL, you will be given a table `years` with a column `yr` for the year. Return a table with a column `century`.

```

Hope you enjoy it .. Awaiting for Best Practice Codes

Enjoy Learning !!!

# Solve It Here

Click the link below to solve it on Codewars:

> **[Century From Year](https://www.codewars.com/kata/5a3fe3dde1ce0e8ed6000097)**
>
> Introduction 
> The first century spans from the year 1 up to and including the year 100, the second century - from the year 101 up to and including the year 200, etc. 
> Task 
> Given a year, return ...

# Notes

This puzzle was posted by a Slackbot via a slash command. If you want to help work on the app, send a message to @Josh.

If you don’t want to see the coding puzzles when you visit the forum, you can go into [your settings](https://forum.codeselfstudy.com/my/preferences/categories) and mute the puzzles category.

---

<div class="post-metadata">

**Author:** ![Josh](https://forum.codeselfstudy.com/user_avatar/forum.codeselfstudy.com/josh/32/4_2.png) [@Josh](https://forum.codeselfstudy.com/u/Josh)\
**Post date:** [November 5, 2020, 7:53pm UTC](https://forum.codeselfstudy.com/t/puzzle-century-from-year-reference/2483/2 "2020-11-05T19:53:22Z")

</div>

Try solving it without any conditional logic.
