Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ABC192 #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ABC192/A-Star.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
x = gets.to_i

puts 100 - x % 100
13 changes: 13 additions & 0 deletions ABC192/B-uNrEaDaBlE sTrInG.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
s = gets.chomp.split('')

s.each_with_index do |x, i|
if i.even?
if x == x.upcase
puts 'No'
return
end
elsif x == x.downcase
puts 'No'
return
end
end
14 changes: 14 additions & 0 deletions ABC192/C-Kaprekar_Number.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
n, k = gets.chomp.split.map(&:to_i)
a = [n]

def func(x)
min = x.to_s.split('').sort.join.to_i
max = x.to_s.split('').sort.reverse.join.to_i
max - min
end

k.times do |i|
a[i + 1] = func(a[i])
end

puts a[k]