You are viewing a single comment's thread. Return to all comments →
ruby:
require 'set' map, weights, counter = ('a'..'z').zip(1..26).to_h, Set.new, 1 s = gets.strip.chars.map{|c| map[c]} for i in 0...s.length counter = (i > 0 and s[i] == s[i-1]) ? counter + 1 : 1 weights.add counter * s[i] end gets.strip.to_i.times do puts weights.include?(gets.strip.to_i) ? "Yes" : "No" end
Seems like cookies are disabled on this browser, please enable them to open this website
Weighted Uniform Strings
You are viewing a single comment's thread. Return to all comments →
ruby: