[RAILS] Dharma doll drop of characters (ruby edition)

[Ruby Edition] Character Daruma Drop

problem

The Daruma Dropper consists of five tiers of wood, each with one lowercase letter. Since the character string before the piece of wood was skipped and the number of stages of wood that was skipped are given, create a program that calculates the character string after the piece of wood is skipped.

Value to be entered

The input is given in the following format.

S N -The first line is given an S that represents the character string before dropping the piece of wood. -The second line is given the integer N, which indicates the number of rows of wood to drop. -The total input is 2 lines, and one line break is inserted at the end.

Expected output

Please output the character string that is created after dropping the piece of wood.

Insert a newline at the end and do not include extra characters or blank lines.

Input example 1

apple 2

Output example 1

aple

Input example 2

water 5

Output example 2

wate

My answer

python


a = gets.chomp
b = gets.to_i
str = a.slice!(b - 1)
print a

This time's point

Calling a string on the first line

Call the number on the second line

Called by specifying a character string with b -1 using the slice method on the 3rd line

If str is set on the 4th line, only the character string a is output, so the character string excluding the character string sliced by print a is output.

that's all!

Recommended Posts

Dharma doll drop of characters (ruby edition)
Basics of Ruby
Pedometer (Ruby edition)
Implementation of Ruby on Rails login function (devise edition)
Safe numbers (ruby edition)
Fizz Buzz (Ruby edition)
definition of ruby method
Minimum value (ruby edition)
Q. Elevator (Ruby edition)
ruby memorandum (basic edition)
The nth and n + 1st characters of a Ruby string