Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Interview Cake - String Permutation Palindrome

def permutation_palindrome(string)
    hash = {}
    (0..string.size - 1).each do |index|
        hash.key?(string[index]) ? hash[string[index]] += 1 : hash[string[index]] = 1
    end
    result = true
    odd_char_count = 0
    hash.each do |key, value|
        if (value % 2) == 1
            odd_char_count += 1
        end
        return false if odd_char_count == 2
    end
    result
end

puts permutation_palindrome('racecar') #true
puts permutation_palindrome('racerac') #true
puts permutation_palindrome('abc') #false
puts permutation_palindrome('anna') #true
puts permutation_palindrome('kayak') #true
puts permutation_palindrome('kaaky') #true

ruby

# Hello World Program in Ruby
puts "Hello World!";

rbls

# Hello World Program in Ruby
a = 1000
b = 3000
c = 900
if c > a and c < b
    puts("Event found")
    puts(c)
else puts("event not found")
end

asel

# Hello World Program in Ruby
puts "Hello World!";

Sub vs Sub!

# Hello World Program in Ruby
def output(out)
    puts out;
end

thing = "https://www.google.com"

output("Thing: #{thing}")
output("Sub!:" + thing.sub("https://", "https://").to_s)
output("Thing: #{thing}")
output("Sub!:" + thing.sub("https://", "https://").to_s)
output("Thing: #{thing}")
output("Sub!:" + thing.sub!("https://", "https://").to_s)
output("Thing: #{thing}")
output("Sub!:" + thing.sub!("https://", "https://").to_s)
output("Thing: #{thing}")

Class examples in Ruby

# Class examples
class Circle 
    def initialize(radius)
        # @ means local field
        @radius = radius 
    end
    
    def get_radius()
        @radius # This will return the local field 
    end
    
    def get_area()
        3.14 * @radius * @radius    
    end
end

# Testing the methods
x = Circle.new(3)
y = Circle.new 10 # There no need for ( )

# Below we have an example of two different ways we can call the radius on both x and y
puts "x radius is: " + x.get_radius().to_s()
puts "y radius is: " + y.get_radius.to_s




as.braulder

#!/usr/bin/ruby -w
# This is a single line comment.

puts "Hello, Ruby!"

#!/usr/bin/ruby

def test
   puts "You have scored"
   yield
   puts "Your bonus is music added"
   yield
end
test {puts "Feel free Void"}

Codeforces Round 536 (Div 2) A

Unable to open file!