Judgment of fractions in Ruby

Judgment of the number of times the entered numerical value (the numerical value that becomes the same even if the numerical values ​​are arranged in reverse)

#Returns true if it is a palindromic number
def checkPalindromicNumber(number)
  number = number.to_s
  size = number.length / 2 - 1
  return ( number[0..size] == number.reverse[0..size] )

↓ Modified version

def palindromic_number?(number)
  number.to_s == number.to_s.reverse

Recommended Posts

Judgment of fractions in Ruby
Basics of sending Gmail in Ruby
Implementation of ls command in Ruby
Acquisition of article information in ruby ​​scraping
Directory information of DEFAULT_CERT_FILE in Mac ruby 2.0.0
Class in Ruby
Basics of Ruby
Summary of hashes and symbols in Ruby
Heavy in Ruby! ??
[Ruby] Classification and usage of loops in Ruby
[Ruby] Behavior of evaluation of conditional expression in while
Recommendation of Service class in Ruby on Rails
Enumerate subsets of arrays given in Ruby (+ α)
Create a native extension of Ruby in Rust
About eval in Ruby
Judgment of the calendar
definition of ruby method
Output triangle in Ruby
Variable type in ruby
Output in multiples of 3
Fast popcount in Ruby
Count the number of occurrences of a string in Ruby
[Ruby] The role of subscripts in learning elements in arrays
Get the URL of the HTTP redirect destination in Ruby
Handling of date and time in Ruby. Use Date and Time properly.
Basic methods of Ruby hashes
Validate JWT token in Ruby
Implemented XPath 1.0 parser in Ruby
Basic methods of Ruby arrays
[Ruby] Leap year judgment program
Read design patterns in Ruby
Write class inheritance in Ruby
[Ruby] Various types of each
Determine that the value is a multiple of 〇 in Ruby
Leap year judgment with Ruby
Update Ruby in Unicorn environment
Integer unified into Integer in Ruby 2.4
[Ruby] Exception handling in functions
Use ruby variables in javascript.
Judgment of JSONArray and JSONObject
Multiplication in a Ruby array
About regular expressions in Ruby
Birthday attack calculation in Ruby
Mazume judgment processing in fishing
Implementation of gzip in java
Find Roman numerals in Ruby
Try using gRPC in Ruby
Microbenchmark for integer power of floating point numbers in Ruby
[Ruby] Find numbers in arrays
Implementation of tri-tree in Java
Pitfalls of WebTarget.queryParam () in JAX-RS
Handling of line beginning and line ending in regular expressions in Ruby
Implementation of HashMap in kotlin
NCk mod p in Ruby
Chinese Remainder Theorem in Ruby
Review of Ruby basic grammar
Want to know what Ruby n is the power of 2? (Power judgment of 2)
Erase N + 1 in acts_as_tree of tree structure Gem of Ruby on Rails
I want to change the value of Attribute in Selenium of Ruby
About the behavior of ruby Hash # ==
Order of route evaluation in Spark