読者です 読者をやめる 読者になる 読者になる

Details(CODEEVAL)

問題の意味がとても分かりにくいのですが、matrixを作成し左側をx、右側をyが陣取り、 yがいくつ左に動くとxと衝突するかというのを求める問題のようです。 問題が悪い気がします。 CHALLENGE DESCRIPTION: There are two details on a M*N checkered field.…

Knight Moves(CODEEVAL)

チェスのナイトの移動位置を求める問題。 横がa-h、縦が1-8。これらの変換をしつつ、以下の数式を満たすパターンを求める。 # 現在位置を(x, y)、次の移動候補を(a,b)とした場合 |a| + |b| = 3 1 <= x + a <= 8 1 <= y + b <= 8 CHALLENGE DESCRIPTION: In c…

Matrix Rotation (CODEEVAL)

行列回転の問題。今回は面白かったです。 CHALLENGE DESCRIPTION: You are given a 2D N×N matrix. Each element of the matrix is a letter: from ‘a’ to ‘z’. Your task is to rotate the matrix 90° clockwise: a b c g d a d e f => h e b g h i i f c I…

Prefix Expressions(CODEEVAL)

ポーランド記法の問題。 何度かtryしましたが、scoreが100にならないです(85-95)。なんかケース漏れがありそうだけど、どういうケースでNGになっているのかcodeeval上ではわからないのが残念。 些細なミスのような気がしますが、一旦諦めました。 CHALLENGE …

SLANG FLAVOR(CODEEVAL)

句読点を変換する問題。 1個飛ばしで変換させるのが面倒。 CHALLENGE DESCRIPTION: Long serious texts are boring. Write a program that will make texts more informal: replace every other end punctuation mark (period ‘.’, exclamation mark ‘!’, or…

STRING PERMUTATIONS(CODEEVAL)

文字列の組み合わせをアルファベト順で並び替える問題。 今回も組み込みメソッドで対応。 instance method Array#permutation (Ruby 2.4.0) Codeevalとかやると、かゆいところに手が届くrubyは非常に良いと実感できます。 (本来的にはこれを素で実装しろと…

WITHOUT REPETITIONS(CODEEVAL)

すごく久しぶりにcodeevalやって見た。 繰り返し文字列を削除する問題。 愚直にできなくはないのですが、なんか便利メソッドないかと調べて見たら そのものズバリの instance method String#squeeze (Ruby 2.4.0) というものがありました。 CHALLENGE DESCRI…

BIG DIGITS(CodeEval)

hatenaでは見にくいか。 CHALLENGE DESCRIPTION: In this challenge you're presented with a situation in which you need to output big symbols on devices which only support ASCII characters and single, fixed-width fonts. To do this you're going…

DELTA TIME(CodeEval)

CHALLENGE DESCRIPTION: You are given the pairs of time values. The values are in the HH:MM:SS format with leading zeros. Your task is to find out the time difference between the pairs. INPUT SAMPLE: 14:01:57 12:47:11 13:09:42 22:16:15 08:0…

Roller Coaster(CodeEval)

CHALLENGE DESCRIPTION: You are given a text. Your job is to write a program to set the case of text characters based on the following: First letter of the line should be upper case. Next letter should be lower case. Next letter should be u…

READ MORE(CodeEval)

すごい久しぶりにcodeeval。 CHALLENGE DESCRIPTION: You are given a text. Write a program which outputs its lines according to the following rules: 1. If line length is ≤ 55 characters, print it without any changes. 2. If the line length is …

RACING CHARS(CodeEval)

CHALLENGE DESCRIPTION: In this challenge you will be given a file where each line is a section of a race track with obstructions, gates and checkpoints. The goal is to find a way of passing this track, using the following rules: Each secti…

THE MAJOR ELEMENT(CodeEval)

CHALLENGE DESCRIPTION: The major element in a sequence with the length of L is the element which appears in a sequence more than L/2 times. The challenge is to find that element in a sequence. INPUT SAMPLE: Your program should accept as it…

SPLIT THE NUMBER(CodeEval)

CHALLENGE DESCRIPTION: You are given a number N and a pattern. The pattern consists of lowercase latin letters and one operation "+" or "-". The challenge is to split the number and evaluate it according to this pattern e.g. 1232 ab+cd -> …

COMPRESSED SEQUENCE(CodeEval)

美しくない。 CHALLENGE DESCRIPTION: Assume that someone dictates you a sequence of numbers and you need to write it down. For brevity, he dictates it as follows: first says the number of consecutive identical numbers and then says the numb…

ROAD TRIP(CodeEval)

CHALLENGE DESCRIPTION: You've decided to make a road trip across the country in a straight line. You have chosen the direction you'd like to travel and made a list of cities in that direction that have gas stations to stop at and fill up y…

HIDDEN DIGITS(CodeEval)

CHALLENGE DESCRIPTION: In this challenge you're given a random string containing hidden and visible digits. The digits are hidden behind lower case latin letters as follows: 0 is behind 'a', 1 is behind ' b ' etc., 9 is behind 'j'. Any oth…

MORSE CODE(CodeEval)

CHALLENGE DESCRIPTION: You have received a text encoded with Morse code and want to decode it. INPUT SAMPLE: Your program should accept as its first argument a path to a filename. Input example is the following: .- ...- ..--- .-- .... .. .…

MIXED CONTENT(CodeEval)

CHALLENGE DESCRIPTION: You have a string of words and digits divided by comma. Write a program which separates words with digits. You shouldn't change the order elements. INPUT SAMPLE: Your program should accept as its first argument a pat…

MULTIPLY LISTS(CodeEval)

CHALLENGE DESCRIPTION: You have 2 lists of positive integers. Write a program which multiplies corresponding elements in these lists. INPUT SAMPLE: Your program should accept as its first argument a path to a filename. Input example is the…

SWAP ELEMENTS(CodeEval)

CHALLENGE DESCRIPTION: You are given a list of numbers which is supplemented with positions that have to be swapped. INPUT SAMPLE: Your program should accept as its first argument a path to a filename. Input example is the following 1 2 3 …

LONGEST WORD(CodeEval)

CHALLENGE DESCRIPTION: In this challenge you need to find the longest word in a sentence. If the sentence has more than one word of the same length you should pick the first one. INPUT SAMPLE: Your program should accept as its first argume…

SHORTEST REPETITION(CodeEval)

CHALLENGE DESCRIPTION: Write a program to determine the shortest repetition in a string. A string is said to have period p if it can be formed by concatenating one or more repetitions of another string of length p. For example, the string …

ROMAN NUMERALS(CodeEval)

CHALLENGE DESCRIPTION: Many persons are familiar with the Roman numerals for relatively small numbers. The symbols I (capital i), V, X, L, C, D, and M represent the decimal values 1, 5, 10, 50, 100, 500 and 1000 respectively. To represent …

WORD TO DIGIT(CodeEval)

CHALLENGE DESCRIPTION: Having a string representation of a set of numbers you need to print this numbers. All numbers are separated by semicolon. There are up to 20 numbers in one line. The numbers are "zero" to "nine" INPUT SAMPLE: Your p…

LOWEST UNIQUE NUMBER(CodeEval)

CHALLENGE DESCRIPTION: here is a game where each player picks a number from 1 to 9, writes it on a paper and gives to a guide. A player wins if his number is the lowest unique. We may have 10-20 players in our game. INPUT SAMPLE: Your prog…

JSON MENU IDS(CodeEval)

CHALLENGE DESCRIPTION: You have JSON string which describes a menu. Calculate the SUM of IDs of all "items" in the case a "label" exists for an item. INPUT SAMPLE: Your program should accept as its first argument a path to a filename. Inpu…

EVEN NUMBERS(CodeEval)

CHALLENGE DESCRIPTION: Write a program which checks input numbers and determines whether a number is even or not. INPUT SAMPLE: Your program should accept as its first argument a path to a filename. Input example is the following 701 4123 …

CALCULATE DISTANCE(CodeEval)

CHALLENGE DESCRIPTION: You have coordinates of 2 points and need to find the distance between them. INPUT SAMPLE: Your program should accept as its first argument a path to a filename. Input example is the following (25, 4) (1, -6) (47, 43…

FIND A WRITER(CodeEval)

西村京太郎先生は海外でも有名なんですね。 CHALLENGE DESCRIPTION: You have a set of rows with names of famous writers encoded inside. Each row is divided into 2 parts by pipe char (|). The first part has a writer's name. The second part is a…

SWAP CASE(CodeEval)

CHALLENGE DESCRIPTION: Write a program which swaps letters' case in a sentence. All non-letter characters should remain the same. INPUT SAMPLE: Your program should accept as its first argument a path to a filename. Input example is the fol…

CAPITALIZE WORDS(CodeEval)

CHALLENGE DESCRIPTION: Write a program which capitalizes the first letter of each word in a sentence. INPUT SAMPLE: Your program should accept as its first argument a path to a filename. Input example is the following Hello world javaScrip…

PENULTIMATE WORD(CodeEval)

CHALLENGE DESCRIPTION: Write a program which finds the next-to-last word in a string. INPUT SAMPLE: Your program should accept as its first argument a path to a filename. Input example is the following some line with text another line Each…

SIMPLE SORTING(CodeEval)

20141118 追記 floatの結果を下3桁で表示するというを見落としていた。。。 ソートのアルゴリズムを問う問題じゃなかった。すごい勘違いしてた。 simple sortなので挿入ソートか選択ソートのことだと思うのですが、 codeevalで採点するとスコアが低いです。…

QUERY BOARD(CodeEval)

CHALLENGE DESCRIPTION: There is a board (matrix). Every cell of the board contains one integer, which is 0 initially. The next operations can be applied to the Query Board: SetRow i x: it means that all values in the cells on row "i" have …

BEAUTIFUL STRINGS(CodeEval)

ちょっと難しくなりました。 CHALLENGE DESCRIPTION: Credits: This problem appeared in the Facebook Hacker Cup 2013 Hackathon. When John was a little kid he didn't have much to do. There was no internet, no Facebook, and no programs to hack o…

HEX TO DECIMAL(CodeEval)

CHALLENGE DESCRIPTION: You will be given a hexadecimal (base 16) number. Convert it into decimal (base 10). INPUT SAMPLE: Your program should accept as its first argument a path to a filename. Each line in this file contains a hex number. …

N MOD M(CodeEval)

CHALLENGE DESCRIPTION: Given two integers N and M, calculate N Mod M (without using any inbuilt modulus operator). INPUT SAMPLE: Your program should accept as its first argument a path to a filename. Each line in this file contains two com…

ARMSTRONG NUMBERS(CodeEval)

こういう数値のことをArmstrong Numbersっていうんですね。 CHALLENGE DESCRIPTION: An Armstrong number is an n-digit number that is equal to the sum of the n'th powers of its digits. Determine if the input numbers are Armstrong numbers. INPUT …

WORKING EXPERIENCE(CodeEval)

CodeEval 少し手こずりました。 CHALLENGE DESCRIPTION: You're building a new social platform and you want to store user's working experience. You've decided to calculate the total experience in years for each user based on the time periods e…

DATA RECOVERY(CodeEval)

CHALLENGE DESCRIPTION Your friends decided to make a fun of you. They've installed a script to your computer which shuffled all of the words within a text. It was a joke, so they've left hints for each sentence which allow you to easily re…

LETTERCASE PERCENTAGE RATIO(CodeEval)

Your goal is to find the percentage ratio of lowercase and uppercase letters in line below. INPUT SAMPLE Your program should accept as its first argument a path to a filename. Each line of input contains a string with uppercase and lowerca…

JUGGLING WITH ZEROS(CodeEval)

CHALLENGE DESCRIPTION In this challenge you will be dealing with zero based numbers. A zero based number is set in the following form: "flag" "sequence of zeroes" "flag" "sequence of zeroes" etc. Separated by a single space. 00 0 0 00 00 0…

AGE DESTRIBUTION(codeeval)

久しぶりにCodeEval のぞいたら、問題が増えていたのでやってみました。 CHALLENGE DESCRIPTION: In this challenge, we are analyzing the ages of people to determine their status. If the age is from 0 to 2 the child should be with parents at home…

Array Absurdity

配列の重複を見つける。 正答率58% ((552.0/(552 +398))*100).round 設問 Imagine we have an immutable array of size N which we know to be filled with integers ranging from 0 to N-2, inclusive. Suppose we know that the array contains exactly on…

Email Validation

メールのvalidation。 正答率82% ((561.0/(561+125))*100).round 設問 You are given several strings that may/may not be valid emails. You should write a regular expression that determines if the email id is a valid email id or not. You may ass…

Number Pairs

配列と数字が与えられたとき、その配列のうち2つの和がその数字となる 組み合わせを求める。 正答率86% ((296.0/(296+48))*100).round 設問 You are given a sorted array of positive integers and a number 'X'. Print out all pairs of numbers whose sum…

Double Squares

Facebook Hacker Cup 2011の問題らしい。 そんなのあるんだ。 入力値が、2つの数値をそれぞれ2乗した値の和になる組み合わせを求める。 入力値が10の場合は、10 = 3^2 + 1^2 なので1通り。 1行目は、ケースの数です。(これに気づかず嵌ってしまった) 正…

Trailing String

カンマで区切られた前半の文字列が、 後半の文字列で終わるなら1、そうでなければ0を表示。正答率87% ((306.0/(306+45))*100).round 設問 You are given two strings 'A' and 'B'. Print out a 1 if string 'B' occurs at the end of string 'A'. Else a zer…

Decimal To Binary

2進数に変換。これは簡単。 正答率82% ((316.0/(316+68))*100).round 設問 Given a decimal (base 10) number, print out its binary representation.Input sample:File containing positive whole decimal numbers, one per line. e.g. 2 10 67Output sampl…