EaglePB2's Competitive Programming Writeups
  • Home Page
  • Why Python?
  • Why 10^9 + 7?
  • General Formatting Title
  • 🇲🇾CodeNection
    • 2021
      • Closed Cateogry
        • Attend Talks
        • Distant Relatives
        • Concert
        • Mamak
        • Fair Contest
      • Open Preliminary Round
        • f(Aibohphobia)^-1
        • Did they cheat?
        • Semester Breaks
      • Open Final Round
        • Ways 1
        • Circular Campus
        • A joke
        • 🥰Last year when life was better
        • Thank You Pizza
    • 2023
      • Test Round
        • Codey and Alphabetical Scoring
        • Codey and Binary Guesser
      • Preliminary Round
        • Codey and CodeNection
        • Codey and Hide-and-Seek
        • Codey and Math
        • Codey and Textbooks
        • Codey and Money
        • Codey and Team Selection
        • Codey and Painted Tree
        • Codey and Number Grid
        • Codey and Crimes
      • Final Round
        • Codey and CodeNection 2
        • Codey and Connection
        • Codey and Schedule
        • Codey and School Supplies
        • Codey and Zombies
        • Codey and Sightseeing
        • Codey and Apples
        • Codey and Facto
        • Codey and Zoey
    • 2024
      • Test Round
        • Codey and Sunday
        • Codey and Takoyaki
      • Preliminary Round
        • Codey and CodeNection
        • Codey and Pebbles
        • Codey and Spam
        • Codey and Coins
        • Codey and Rectangles
        • Codey and Manuscript
        • Codey and Recipes
        • Codey and Toy Kingdom
        • Codey and Peaks
      • Final Round
        • Codey and Exit
        • Codey and Gardening
        • Codey and Symbol
        • Codey and Rectangles 2
        • Codey and Jutsu
        • Codey and Toy Kingdom 2
        • Codey and Speeches
  • ABaKoDa
    • 2023
      • Round 1
        • Problem Letters
        • Problem Statistics
        • Rankings Order
        • Rankings Search
      • Round 2
        • Abakoda Letters
        • Borrowed Words
        • Kensorship
        • Duel Languages
  • Meta Coding Competitions
    • 2011
      • Qualification Round
        • Double Squares
        • Peg Game
        • Studious Student
      • Round 1A
        • Diversity Number
        • Turn on the Lights
        • Wine Tasting
      • Round 1B
        • Chess 2
        • Diminishing Circle
        • Slot Machine Hacker
      • Round 1C
        • N-Factorful
        • Polynomial Factoring
        • Risky Slide
      • Round 2
        • Bonus Assignments
        • Scott's New Trick
        • Studious Student II
      • Final Round
        • Alien Game
        • Party Time
        • Safest Place
  • EaglePB2's Special
    • Hong Kong Identity card
    • Cycle Prefix Averages
    • Word Squares
Powered by GitBook
On this page
  • Question
  • Input Format
  • Constraints
  • Output Format
  • Sample Inputs:
  1. CodeNection
  2. 2023
  3. Final Round

Codey and CodeNection 2

https://www.hackerrank.com/contests/codenection-2023-final-round-closed-category/challenges/cn-c10

Question

Codey worked really hard and its perseverance has landed it in the CodeNection Finals! Codey wishes to express its love for CodeNection, but this time, it wants you to put a clever twist. Reverse the phrase I LOVE CODENECTION n times, and print the final string.

Input Format

The first line contains an integer n, which represents the number of times Codey wants to reverse the string I LOVE CODENECTION.

Constraints

0≤∣n∣≤10180 \le |n| \le 10^{18}0≤∣n∣≤1018

Output Format

Output the string I LOVE CODENECTION reversed n times.

Sample Inputs:

Input

3

Output

NOITCENEDOC EVOL I

Explanation

I LOVE CODENECTION is reversed 3 times.

NOITCENEDOC EVOL I -> I LOVE CODENECTION -> NOITCENEDOC EVOL I


Solution - Binary Modular

Given that number 1, 3, 5, ... gives NOITCENEDOC EVOL I.

Given that number 2, 4, 6, ... gives I LOVE CODENECTION.

so, by using % 2, the answer will be either 0 or 1.

for the case number is 1, that means I LOVE CODENECTION will be reversed; otherwise, keep the same value.

Therefore, the solution is:

string = "I LOVE CODENECTION"

t = int(input())

if t % 2 == 1:
    print(string[::-1])
else:
    print(string)
PreviousFinal RoundNextCodey and Connection

Last updated 2 months ago

🇲🇾