This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@rules = [ | |
{"<TYPE>": "TYPE"}, | |
{"<NUMBER>": "FATURO_NO"}, | |
{"<DATE>": "FATURA_TARIHI"}, | |
{"<ARP_CODE>": "MUSTERI_KODU"}, | |
{"<DATE_CREATED>": "SIPARIS_TARIHI"}, | |
{"<SALESMAN_CODE>": "NOTLAR"}, | |
{"<DATE>": "SEVK_TARIHI"}, | |
{"<TYPE>": "TYPE"}, | |
{"<MASTER_CODE>": "VARYANT_STOK_KODU"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doc = File.open("/home/yasin/İndirilenler/Satıs_Faturaları.XML") | |
count = 0 | |
# doc.each do |line| | |
# count += 1 if line.include?("<INVOICE DBOP=\"INS\" >") | |
# break if count == 5001 | |
# File.open("1.xml", "a") { |f| f.write(line.to_s) } | |
# end | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
one: | |
name: MyString | |
email: MyString | |
two: | |
name: MyString | |
email: MyString | |
valid: | |
name: ysn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pattern1(num) | |
(1..num).each do |x| | |
puts (x.to_s) * x | |
end | |
end | |
def pattern2(num) | |
n = 0 | |
while n < num | |
n += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def word_freq_counter(text, word) | |
counter = 0 | |
text = text.downcase.split(/\W+/) | |
text.each {|w| counter += 1 if w == word} | |
counter | |
end | |
text = gets.chomp | |
word = gets.chomp.downcase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_deficient(num) | |
sum = 0 | |
(1..num).each {|i| sum += i if num % i == 0} | |
if sum < (2 * num) | |
"#{num} is deficient number" | |
else | |
"#{num} is not deficient number" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_armstrong(num) | |
num = num.to_s | |
sum = 0 | |
num.each_char do |i| | |
i = i.to_i | |
sum += (i ** 3) | |
end | |
num = num.to_i | |
if sum == num | |
puts "#{num} is armstrong number" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_spaces(str) | |
result = "" | |
str.each_char {|letter| result << letter if letter != " "} | |
result | |
end | |
#Alternative | |
def remove_spaces_v2(str) | |
str.delete! ' ' | |
str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
num = int(input("enter a number:")) | |
lst = [i for i in range(1, num) if num % i == 0 and i % 2 != 0] | |
print(lst) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lst1 = list(map(lambda x: x*2, (i for i in range(1, 100)))) | |
lst2 = [i for i in lst1 if i % 3 == 0 and i % 5 == 0] | |
print(lst2) |
NewerOlder