Add Number Series | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2012-11-06 |
SummaryAdd a series of numbers from 1 through n | ||
DescriptionWrite a program that, given an integer, sums all the numbers from 1 through that integer (both inclusive). Do not include in your sum any of the intermediate numbers (1 and n inclusive) that are divisible by 5 or 7. | ||
InputYour program should read lines from standard input. Each line contains a positive integer. | ||
OutputFor each line of input, print to standard output the sum of the numbers from 1 through n, disregarding those divisible by 5 and 7. Print out each result on a new line. | ||
Add Number Series II | ||
| Difficulty: Easy | Test Cases: 8 | Published: 2019-05-31 |
SummaryAdd a series of numbers from 1 through n with a rule | ||
DescriptionWrite a program that, given an integer N, sums all the whole numbers from 1 through N (both inclusive). Do not include in your sum any of the intermediate values (1 and N inclusive) that are divisible by 3 or 7. | ||
InputYour program should read lines from standard input. Each line contains a positive integer. | ||
OutputFor each line of input, print to standard output the sum of the integers from 1 through N, ignoring those divisible by 3 or 7. Print out each result on a new line. | ||
Adjacency List | ||
| Difficulty: Easy | Test Cases: 8 | Published: 2019-07-15 |
SummaryBuild an adjacency list representation of the graph | ||
DescriptionWrite a program that builds an adjacency list representation of a simple undirected graph. | ||
InputAn undirected graph represented as an adjacency matrix, that is a square n x n matrix containing only zeros and ones. Each line of input contains the space-separated set of elements of the corresponding row of the adjacency matrix. For example: 0 1 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 1 0 1 0 0 The first row means that the vertex with index 0 is adjacent to (i.e., shares an edge with) the vertices 1, 2, 3, and 4. The second row means that vertex 1 is adjacent to vertices 0 and 3, and so on. Vertex indices are continuous integer numbers from 0 to (n - 1) , where n is a count of vertices in the graph. See the attachments tab for an image representation of this graph. | ||
OutputAn adjacency list of the given graph. Each line of the output contains one element of the list, which is a space-separated set of numbers. The first number is a vertex index, and all others are the vertices that the current vertex is adjacent to. For example: 0 1 2 3 4 1 0 3 2 0 3 4 3 0 1 2 4 0 2
| ||
Attachments | ||
Adjacency Matrix | ||
| Difficulty: Easy | Test Cases: 8 | Published: 2019-06-24 |
SummaryBuild an adjacency matrix of the graph | ||
DescriptionWrite a program that builds an adjacency matrix representation of a simple undirected graph. | ||
InputAn undirected graph represented as an adjacency list. Each line of input contains one element of the list, which is a space-separated set of numbers. The first number is a vertex index, and all others are the vertices that the current vertex is adjacent to. Vertex indices are continuous integer numbers from 0 to (n - 1), where n is a count of vertices in the graph. So for example: 0 1 2 3 4 1 0 3 2 0 3 4 3 0 1 2 4 0 2 The first row means that the vertex with index 0 is adjacent to (i.e., shares an edge with) the vertices 1, 2, 3, and 4. The second row means that vertex 1 is adjacent to vertices 0 and 3, and so on. See the attachments tab for an image representation of this graph. | ||
OutputAn adjacency matrix of the given graph that is a square n x n matrix containing only zeros and ones. The element in the cross of the i row and the j column is equal to 1 if and only if there is an edge between vertices i and j in the graph. Each row of the output contains space-separated elements of the corresponding row of the adjacency matrix. For example: 0 1 1 1 1 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 1 0 1 0 0
| ||
Attachments | ||
Alter Case | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2012-11-02 |
SummaryCamel case a given sentence | ||
DescriptionWrite a program that, given an input sentence, alternates the case of every alphabetic character, starting with uppercase. Spaces and non-alphabetical characters should be added to the final output as is, i.e. they should not be taken into account when alternating between upper/lowercase. | ||
InputYour program should read lines from standard input. Each line contains a sentence. Assume all characters are ASCII. | ||
OutputFor each sentence from standard input, print to standard output the sentence such that the first character is uppercase, the next character is lowercase and so on. | ||
Armstrong Numbers | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-20 |
SummaryDetermine if a number is an armstrong number. | ||
DescriptionAn Armstrong number is an n-digit number that is equal to the sum of the nth powers of its digits. Determine if the input numbers are Armstrong numbers. | ||
InputYour program should read lines from standard input. Each line has a positive integer. | ||
OutputPrint out True if the number is an Armstrong number, or False if not. | ||
Asteroid Mining | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2019-08-07 |
SummaryCompute the minimum number of days required to mine a certain amount of mineral | ||
DescriptionYou are starting an asteroid mining mission with a single harvester robot. That robot is capable of mining one gram of mineral per day. It also has the ability to clone itself by constructing another harvester robot. That new robot becomes available for use the next day and can be involved in the mining process or can be used to construct yet another robot. Each day you will decide what you want each robot in your fleet to do. They can either mine one gram of mineral or spend the day constructing another robot. Write a program to compute a minimum number of days required to mine n grams of mineral. Note that you can mine more mineral than required. Just ensure that you spent the minimum possible number of days to have the necessary amount of mineral mined. | ||
InputA single integer number n, which is the number of grams of mineral to be mined. The value of n will be between 1 and 1000000 (inclusive). For example: 9
| ||
OutputA single integer, the minimum number of days required to mine n grams of mineral. For example: 5
| ||
Avocado Prices | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2020-03-06 |
SummaryCalculate summary statistics for a variable in a dataset | ||
DescriptionConsider a dataset containing the distribution of avocado prices across various regions over a specific time period. Given that dataset, calculate the following summary statistics:
| ||
InputA dataset in CSV format with the avocado prices to summarize. The dataset has the following columns:
For example: date,price,region 2015-07-19,1.08,Louisville 2015-08-16,1.05,RichmondNorfolk 2015-04-05,1.1,Orlando 2015-07-26,1.12,GrandRapids 2015-05-31,1.1,Atlanta
| ||
OutputPrint the summary statistics as four real numbers. Print each value on a separate line in the following order:
Each real value must be rounded to the required number of digits after the decimal point:
Keep all trailing zeros in the result. Rounding should be done to the nearest value using round half to even rule: if the number falls midway, it is rounded to the nearest value with an even least significant digit. For example, rounding to 3 digits after the decimal point 1.0135 becomes 1.014, as does 1.0145. This is the default behavior of the round function in Python, R, etc. For example: 1.05 1.12 1.090 0.0265
| ||
Beautiful Strings | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-20 |
SummaryFacebook Hacker Cup 2013 problem: Determine the beauty of strings. | ||
DescriptionWhen John was a little kid he didn't have much to do. There was no internet, no Facebook, and no programs to hack on. So he did the only thing he could... he evaluated the beauty of strings in a quest to discover the most beautiful string in the world. | ||
InputYour program should read lines from standard input. Each line is a string. | ||
OutputPrint out the maximum beauty for the string. | ||
Binary Addition | ||
| Difficulty: Easy | Test Cases: 5 | Published: 2012-11-01 |
SummaryBinary numbers addition | ||
DescriptionWrite a program that, given two binary numbers represented as strings, prints their sum in binary. The binary strings are comma separated, two per line. The final answer should not have any leading zeroes. In case the answer is zero, just print one zero i.e. 0 | ||
InputYour program should read lines from standard input. Each line contains two binary strings, separated by a comma and no spaces. | ||
OutputFor each pair of binary numbers print to standard output their binary sum, one per line. | ||
Binary Coded Decimal - Encoding | ||
| Difficulty: Easy | Test Cases: 7 | Published: 2019-07-15 |
SummaryConvert an integer number to the binary coded decimal (BCD) code | ||
DescriptionImagine that you are prototyping an electronic device based on the Arduino platform and you are using a seven-segment display to show numeric values. To reduce the number of used digital outputs of the microcontroller, the display board is connected to the main board through the integrated circuit of the decoder, which converts binary coded decimal (BCD) values to signals for the seven-segment display. So, to show any number on the display you need to set the required BCD code on the microcontroller's outputs. Write a program to convert an integer number represented as a string to a BCD code required for the display. In the BCD code, every decimal digit is encoded with its four-bit binary value. Encoding all digits of the decimal number and concatenating the resulting codes into one string you will get a resulting BCD code. A space is used to separate digits in the BCD code and make it more readable. For example, a number 173 will be encoded to BCD as 0001 0111 0011. | ||
InputEach line has a string representing a non-negative integer number. For example: 5 17
| ||
OutputEach line contains a BCD code of the number at the corresponding line of the input. Codes of the decimal digits are separated from each other with a space. For example: 0101 0001 0111
| ||
Bit Positions | ||
| Difficulty: Easy | Test Cases: 5 | Published: 2012-10-08 |
SummaryBits in position x, y are same or different. | ||
DescriptionGiven integers n, p1, and p2, determine if the bits of n in position p1 and p2 are the same. Positions p1, p2 are 1 based with 1 being the least significant bit. | ||
InputYour program should read lines of text from standard input. Each line will contain the integers n, p1, and p2, separated by commas. | ||
OutputFor each line of input, print "true" to standard output if the bits are the same, or "false" otherwise, one per line. | ||
Cached Out | ||
| Difficulty: Easy | Test Cases: 5 | Published: 2019-04-02 |
SummaryImplement a simple Cache that enforces Uniqueness | ||
DescriptionBuild an in-memory string cache that guarantees each entry is unique. This cache requires the following functions:
Try to implement this cache in a way that will have high read performance across a potentially large set. | ||
InputEach line of input will have two parts separated with a pipe character:
For example: Add|Dog Get|Dog Remove|Dog Has|Dog The Reset function is an exception. It will only have the Function Name as input. | ||
OutputOne line of output based on the function called by each line of input. For example: True Dog True False
| ||
Calculate Distance | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-28 |
SummaryCalculate a distance between two points | ||
DescriptionYou have (x, y) coordinates for 2 points and need to find the distance between them. | ||
InputYour program should read lines from standard input. Each line contains two space-delimited coordinate pairs. All x and y values are integers between -100 and 100. | ||
OutputPrint the distance between the two points. You do not need to round the results you receive. | ||
Camel Case Machine | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2019-04-02 |
SummaryString formatting test to fit the Camel Case standard | ||
DescriptionReformat a series of strings into Camel Case by returning the fragments from input as a single "sentence". For example, consider the following input: Camel Case
LOOKS like ThIs Would result in: camelCase looksLikeThis
| ||
InputA series of strings with one fragment on each line of input. All characters will be from the ASCII character set. | ||
OutputA single line with the inputs assembled in Camel Case | ||
Capitalize Words 2 | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2022-06-30 |
SummaryCapitalize words in a sentence | ||
DescriptionWrite a program which, given a sentence, puts the first letter of each word into upper case. | ||
InputYour program should read lines from standard input. Each line has a space-delimited sequence of words. Each word contains English letters, digits, and underscores. For example: Hello world
| ||
OutputPrint the capitalized words. For example: Hello World
| ||
Character Counting | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2012-11-07 |
SummaryCount the frequency of characters in a string | ||
DescriptionWrite a program that, given a string, outputs a new string that contains each character in the original string exactly one time, followed by the frequency of occurrences of that character in the original string, and in alphabetical order. | ||
InputYour program should read lines from standard input. Each line contains a string. The string will consist of ASCII characters and no spaces. Ignore case when considering a character. e.g. 'a' and 'A' are to be interpreted to be the same. When printing out the character, it should always be in lowercase and the characters should be alphabetically sorted. | ||
OutputPrint to standard output the new string comprised of each character followed by its frequency. Print out each result on a new line. | ||
Checker Movement | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2019-12-03 |
SummaryCheck if the position on the checkerboard is reachable | ||
DescriptionGiven the start and finish positions on a checkerboard, write a program to check whether a piece can reach the finish position from the start with a series of valid moves. In the game of checkers, an uncrowned piece may only move one step diagonally forward, where forward is in the direction of the opponent's starting row. Assume that there is only one piece on an 8 x 8 checkerboard. The light pieces start at the bottom and the dark pieces start at the top. Columns are designated by characters a, b, c, d, e, f, g, h from left to right. Rows are designated by numbers 1, 2, 3, 4, 5, 6, 7, 8 from bottom to top. HINT: Only the dark squares of the checkered board are used. See the attachments tab for an image of the checkerboard and possible movements of a light piece. | ||
InputA string containing three space-delimited, alpha-numeric values:
The color of the piece is designated by the one character: L for light, or D for dark. The position on the checkerboard is a concatenation of a character and integer, addressing the column and the row respectively. For example: L e3 g7 ...is a Light colored piece starting in position e3 and trying to get to g7. | ||
OutputTrue if the checker can reach the finish position, otherwise False. | ||
Attachments | ||
Checkerboard Colors | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2019-11-15 |
SummaryDetermine a cell's color on the checkerboard | ||
DescriptionGiven a square's location on a checkerboard, write a program to determine the color of the square. Each square can be one of two colors: Black or White. The square in the bottom left is always Black and the size of the checkerboard is 8x8. For any given square, all its adjacent squares have a different color. In other words, any two squares have different colors if they share an edge between them. Columns are designated by characters a, b, c, d, e, f, g, h from left to right. Rows are designated by numbers 1, 2, 3, 4, 5, 6, 7, 8 from bottom to top. The address of a single square is a concatenation of the character and integer values. See the attachments tab for an image of the checkerboard. | ||
InputA string with the alpha-numeric address of the square. For example: f7
| ||
OutputPrint the color of the square: Black or White. Print Error if the address is invalid. | ||
Attachments | ||
Common Suffix | ||
| Difficulty: Easy | Test Cases: 8 | Published: 2012-10-08 |
SummaryCommon Suffix of two strings | ||
DescriptionWrite a program that finds the longest common suffix between two strings. If there is no common suffix, print the string NULL. Assume that the strings only contain ASCII characters. | ||
InputYour program should read lines from standard input. Each line contains two strings separated by a comma. Assume that each line will have exactly one comma. | ||
OutputFor each pair of input strings, print to standard output the longest common suffix between them. | ||
Compare Numbers | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2013-12-23 |
SummaryGiven two integers A and B, print out the symbol that accurately compares A to B (either >, <, or =). | ||
DescriptionLittle Tommy is in kindergarten on the first day of class. His teacher has taught him about inequalities today, and he is learning how to draw crocodiles to represent them. When there are two numbers, A and B, there are three options: | ||
InputThe input consists of two integers A and B on a line, separated by a space. |A,B| < 2^63. | ||
OutputPrint a line containing the appropriate symbol that describes the relationship between the numbers. | ||
Compare Points | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2013-12-23 |
SummaryGiven two (x, y) points A and B, determine which cardinal direction B is from A. | ||
DescriptionBob's hiking club is lost in the mountains on the way to a scenic overlook. Fortunately, Bob has a GPS device, so that he can see the coordinates where the group is currently at. The GPS gives the current X/Y coordinates as O, P, and the scenic overlook is located at Q, R. Bob now just needs to tell the group which way to go so they can get to the overlook in time for s'mores. | ||
InputThe input consists of four integers O, P, Q, R on a line, separated by spaces. |O,P,Q,R| < 10000. | ||
OutputPrint a line containing one of the following: | ||
Compressed Sequence | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-28 |
SummaryCompress a sequence using a simple algorithm | ||
DescriptionAssume 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 number itself. E.g. The sequence 1 1 3 3 3 2 2 2 2 14 14 14 11 11 11 2 will be dictated as "Two ones, three threes, four twos, three fourteens, three elevens, one two", so you will write down the sequence 2 1 3 3 4 2 3 14 3 11 1 2. The challenge is to write the program which compresses the given sequence using this approach. | ||
InputYour program should read lines from standard input. Each line is a sequence of L integers, where each integer is N, separated by a whitespace. N is in range [0, 99]. L is in range [1, 400]. | ||
OutputFor each test case, produce a single line of output containing a compressed sequence of numbers separated by a single space char. | ||
Corporate Ladder | ||
| Difficulty: Easy | Test Cases: 7 | Published: 2019-04-02 |
SummaryAssemble individual pairs in a hierarchy | ||
DescriptionA company wants to track change in their organization by knowing how many levels exist between any two employees. This number will help them know who is being promoted and who is not. For example: Write a program that will count how many levels exist between any two names in a hierarchy of employees. The program must read a list of name pairs that represent an employee and their manager. HINT: The two names to compare may be in different parts of the organizational tree and not have a direct managerial line. | ||
InputThe first line of input will be a pair of names to compare. All subsequent lines will be employee/manager pairs. The company's complete hierarchy will be included so no incomplete trees will exist. For example: Susan/Amy Susan/John John/Amy
| ||
OutputThe number of levels between the pair requested, including the top manager's level. In the example above, the Output should be: 2 | ||
Credit Card Validator | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2019-04-02 |
SummaryValidate a credit card number using standard Luhn Algorithm | ||
DescriptionCredit card numbers can be validated using an industry-standard algorithm called the Luhn Checksum:
The sum of all the digits in the third row is 67+x. If x = 3, then the modulo of 10 = 0, which means the credit card number is valid. Write a program that will validate credit card numbers using this algorithm and indicate the result. | ||
InputA single line of input containing a potential credit card number | ||
OutputTrue if the credit card number is valid | ||
Attachments | ||
Custom Merge | ||
| Difficulty: Easy | Test Cases: 4 | Published: 2019-04-18 |
SummaryMerge two sorted arrays with a special requirement | ||
DescriptionWrite a program that, given two sorted arrays of integers, will produce a sorted array containing all elements of both. There's a special requirement: Note that the size of array can be large. Try to find an efficient solution with linear running time. | ||
InputTwo comma-separated arrays of integers. For example: | ||
OutputThe merged and sorted array formatted as a comma-separated series of values. The sorting must treat all even numbers as greater than odd numbers. For example: | ||
Dash Insert | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2012-11-05 |
SummaryInserting characters between digits | ||
DescriptionWrite a program that, given an integer, inserts a '*' between adjacent digits that are both even and a '-' between adjacent digits that are both odd. Zero should not be considered even or odd. | ||
InputYour program should read lines from standard input. Each line contains a positive integer. | ||
OutputFor each line from standard input, print to standard output the input string with '*' and '-' properly inserted as described above, one string per line. | ||
Data Converter - CSV to JSON | ||
| Difficulty: Easy | Test Cases: 4 | Published: 2019-04-02 |
SummaryExport a Tabular Data Set to JSON | ||
DescriptionRead a tabular data set from input and write it out in JSON. For example: Purchase Date,Item Name,Amount,Currency 2019-01-07,Pizza,18.00,USD 2019-01-07,Ice Cream,6.00,USD 2019-01-08,Dozen Eggs,4.00,USD
| ||
InputA CSV-formatted series of records with one record on each line of input. The first line of input will have the column names for the data set. No escape characters or special handling for values containing commas or quotes will be used. | ||
OutputA standard JSON-formatted response in the RFC 7159 format with two spaces per indent. The first item will be the field headers from the CSV. | ||
Decimal To Negabinary | ||
| Difficulty: Easy | Test Cases: 7 | Published: 2019-10-04 |
SummaryPrint the negabinary representation of a decimal number | ||
DescriptionGiven a decimal (base 10) integer, print out its negabinary representation (base -2). Conversion of the integer value can be done through repeated division by -2. At each division operation, a non-negative and minimal remainder must be chosen. For example: - 3 / -2 = 2 remainder 1 -3 / -2 = 1 remainder - 1
Both results above are valid, but the first of them must be selected for the conversion since it is the least, non-negative remainder. | ||
InputEach line of the input contains a single integer value (base 10). | ||
OutputFor each integer, print its negabinary representation. Print one per line, with no leading zeros. | ||
Delta Compression - Decoding | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2020-02-08 |
SummaryDecode data compressed with delta encoding | ||
DescriptionIn data transmission, delta compression is used to encode data as a difference between successive values (e.g. bytes), rather than using the values themselves. Let's look at an example of how to encode the byte sequence 28 30 33 30 28 29 31 66 65 65 65 64 using delta compression. The first value is simply copied from the original data to the delta encoded output stream. Each subsequent value in the output stream is equal to the difference (i.e. delta) between the corresponding value in the input stream and the prior value in the input stream. The image in the attachments tab illustrates the encoding process. Decoding reverses the compression process by consecutively summing (i.e. accumulating) the differences starting from the first value. Write a program to decode a delta encoded stream. | ||
InputA delta encoded stream expressed as a space-delimited list of integers. For example: 28 2 3 -3 -2 1 2 35 -1 0 0 -1
| ||
OutputPrint a decoded (source) data stream as a space-delimited list of integers. For example, the input above should result in: 28 30 33 30 28 29 31 66 65 65 65 64
| ||
Attachments | ||
Delta Compression - Encoding | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2020-02-08 |
SummaryEncode data using delta compression algorithm | ||
DescriptionIn data transmission, delta compression is used to encode data as a difference between successive values (e.g. bytes), rather than using the values themselves. Let's look at an example of how to encode the byte sequence 28 30 33 30 28 29 31 66 65 65 65 64 using delta compression. The first value is simply copied from the original data to the delta encoded output stream. Each subsequent value in the output stream is equal to the difference (i.e. delta) between the corresponding value in the input stream and the prior value in the input stream. The image in the attachments tab illustrates the encoding process. Write a program that, given a sequence of integer values, encodes it using the delta compression algorithm. | ||
InputA source data stream expressed as a space-delimited list of integers. For example: 28 30 33 30 28 29 31 66 65 65 65 64
| ||
OutputPrint a delta encoded output stream as a space-delimited list of integers. For example, the input above should result in: 28 2 3 -3 -2 1 2 35 -1 0 0 -1
| ||
Attachments | ||
Download Time | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2020-03-06 |
SummaryCalculate the estimated time to download a file over a network | ||
DescriptionGiven a file size in mebibytes (MiB) and a network connection speed in Megabits per second (Mb/s), write a program to calculate the estimated time to transfer the file over that network. Assume that all network capacity is used for file data transfer, there is no overhead, loss, congestion, or contention. | ||
InputTwo space-delimited positive integers:
For example: 400 10
| ||
OutputPrint an integer representing the number of seconds required to transfer the file over the network. Round the calculated value up to the smallest integer that is not less than the result. For the example above, the output would be: 336
| ||
Error Logger | ||
| Difficulty: Easy | Test Cases: 7 | Published: 2019-04-02 |
SummaryWrite a generic error logging function | ||
DescriptionWrite a function that accepts some generic error information and writes out a formatted log entry based on a lookup value. The format of the log entry is: The Severity and Error Code are based on the Exception Type. In order to provide the correct values, your solution should use the Exception Type to lookup the correct Severity and Error Code values as shown below: Exception Type Error Code Severity IOException 100 High MemoryException 110 High ThreadAbortException 200 Medium ResponseTimeoutException 300 Low ParameterException 301 Low | ||
InputA single line of input that will have the Exception Type and Message separated by a Pipe "|" character. For example: | ||
OutputThe complete Log Entry with elements separated by a pipe character. For example: | ||
Even Numbers | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-28 |
SummaryDetermine if a number is even or not | ||
DescriptionWrite a program that determines whether a number is even or not. | ||
InputYour program should read lines from standard input. Each line consists of one integer between 0 and 5000. | ||
OutputPrint 1 if the number is even or 0 if the number is odd. | ||
Fee Saver | ||
| Difficulty: Easy | Test Cases: 7 | Published: 2019-04-18 |
SummaryOptimize a buffer using some inspection and rules | ||
DescriptionA bank wants to change the way they apply transactions to accounts in order to minimize fees for their customers. Each day, the transactions for a given account come in. They can be applied to the account in any order but when an overdraft occurs, a flat fee is charged for each transaction that results in a balance below zero. Write a program that accepts an account's starting balance plus a list of transactions for the day. Re-order the transactions in any way you like to minimize the number of overdraft fees. Report the number of overdraft fees resulting from your optimization. | ||
InputThe first line of input will be a numeric value representing the starting balance of the account. All subsequent lines will be transaction amounts for the day to be applied against the starting balance. Amounts may be negative (debits) or positive (credits). | ||
OutputAn integer indicating the fewest number of overdraft fees possible considering the daily transactions. | ||
Fibonacci Series | ||
| Difficulty: Easy | Test Cases: 5 | Published: 2012-10-08 |
SummaryPrint out the nth fibonacci number | ||
DescriptionThe Fibonacci series is defined as F(0) = 0; F(1) = 1; F(n) = F(n-1) + F(n-2) where n>1. Given a positive integer n, print the value of F(n). | ||
InputYour program should read lines of text from standard input. Each line will contain a single positive integer, n. | ||
OutputFor each input n, print to standard output the fibonacci number, F(n), one per line. | ||
Find a Writer | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-20 |
SummaryFind a famous writer in a string | ||
DescriptionYou have a set of rows with names of famous writers encoded inside. Each row is divided into 2 parts by a pipe char (|). The first part has a writer's name. The second part is a "key" to generate a name. | ||
InputYour program should read lines from standard input. Each line contains a string of characters, followed by a pipe char (|), followed by a string of space-delimited numbers. | ||
OutputPrint the decoded name/birth year of the writer. | ||
Fizz Buzz | ||
| Difficulty: Easy | Test Cases: 5 | Published: 2012-08-17 |
SummaryA simple game involving divisibility tests. | ||
DescriptionGiven positive integers A, B, and N, write a program that prints integers from 1 to N. But for integers that are multiples of A, print 'F', and for multiples of B, print 'B'. For integers which are multiples of both A and B, print 'FB'. | ||
InputYour program should read lines of text from standard input. Each line will contain A, B, and N as space-delimited positive integers. | ||
OutputFor each line of input, print to standard output a line of space-delimited integers 1 through N, replacing integers as described above. | ||
Frowny Smileys | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2019-11-15 |
SummaryCount the number of frowning smileys in a string | ||
DescriptionWrite a program to count the total number of frowny smileys in a string. Here are the rules for how to find smileys and determine whether they are happy or frowny:
Each smiley starts with eyebrows or eyes and ends with the mouth. Use regular expression(s) for the search. | ||
InputA string with text containing some number of smileys. For example: I want to buy a onesie… :o) but know >;-( it won’t suit me :'{
| ||
OutputPrint out the number of frowny smileys found in the string. For example: 2
| ||
Graph Degree | ||
| Difficulty: Easy | Test Cases: 8 | Published: 2019-06-24 |
SummaryFind a minimum and a maximum degree of the simple undirected graph | ||
DescriptionWrite a program that finds the minimum and the maximum degree of a simple undirected graph. In other words, the minimum and the maximum degrees of the graph's vertices. A degree of the vertex is the number of edges that are incident to it. | ||
InputA simple undirected graph represented as an adjacency matrix that is a square n x n matrix containing only zeros and ones. The element in position i row and j column is equal to 1 if and only if there is an edge between vertices i and j in the graph. Each row of input contains a space-separated series of elements for that corresponding row of the adjacency matrix. For example: 0 1 1 1 1 1 0 0 0 0 1 0 0 1 1 1 0 1 0 0 1 0 1 0 0 The first row means that the first vertex is adjacent to (i.e., shares an edge with) the vertices 2, 3, 4, and 5. So the degree of the first vertex is 4 because 4 edges are incident to it. The second row means that vertex 2 is adjacent only to vertex 1, and its degree is equal to 1. | ||
OutputA space-separated minimum and maximum degree of the given graph. 1 4
| ||
Greatest Common Divisor | ||
| Difficulty: Easy | Test Cases: 5 | Published: 2012-10-08 |
SummaryGreatest common divisor of two numbers | ||
DescriptionWrite a program that finds the greatest common divisor of two positive integers. | ||
InputYour program should read lines from standard input. Each line contains two positive integers separated by a comma. | ||
OutputFor each pair of input integers, print to standard output their GCD, one GCD per line. | ||
Hailstone Sequence | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2020-03-06 |
SummaryPrint a hailstone sequence of numbers | ||
DescriptionThe Collatz Conjecture defines a sequence of numbers starting from any positive integer n and obtaining each term of the sequence from the previous term in the following way:
This sequence is called a hailstone sequence and can be described mathematically as: The Collatz conjecture states that such a sequence will always reach a final value of 1. Write a program to generate the hailstone sequence starting from n and ending with 1. | ||
InputAn integer 1 < n < 10000, that is the first number in the sequence. | ||
OutputPrint a space-delimited list of integers in the hailstone sequence as described. For example, if the first number n = 5, the output would be: 5 16 8 4 2 1
| ||
Happy Numbers | ||
| Difficulty: Easy | Test Cases: 7 | Published: 2012-10-08 |
SummaryDetermine if a number is a happy number or not | ||
DescriptionA happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers. | ||
InputYour program should read lines of text from standard input. Each line contains a single positive integer, N. | ||
OutputIf the number is a happy number, print 1 to standard output. Otherwise, print 0. | ||
Hello World | ||
| Difficulty: Easy | Test Cases: 5 | Published: 2018-09-11 |
SummaryImplement the classic code sample in multiple languages | ||
DescriptionPrint the text "HELLO WORLD" to standard output in the language requested. Languages that need to be supported are English, French and Spanish. | ||
InputAn ISO standard culture code. For example, "en-US". This should be case insensitive. | ||
Output"HELLO WORLD" stated in the requested language. All output should be in UPPER CASE. | ||
Hex to Decimal | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-20 |
SummaryConvert a hex number to its decimal equivalent. | ||
DescriptionYou will be given a hexadecimal (base 16) number. Convert it into decimal (base 10). | ||
InputYour program should read lines from standard input. Each line contains a hex number. You may assume that the hex number does not have the leading '0x'. Also, all alpha characters (a through f) in the input will be in lowercase. | ||
OutputPrint out the equivalent decimal number. | ||
Hidden Digits | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-28 |
SummaryTry to look behind the scenes | ||
DescriptionIn 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 other symbol in the string means nothing and has to be ignored. So the challenge is to find all visible and hidden digits in the string and print them out in order of their appearance. | ||
InputYour program should read lines from standard input. Each line contains a string. You may assume that there will be no whitespace inside the string. | ||
OutputFor each test case, print out all visible and hidden digits in order of their appearance. Print out NONE if there are no digits in the string. | ||
Hit Board | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2019-05-31 |
SummaryDerive a value matrix and track results | ||
DescriptionConsider a grid of size X by Y where the column index x ranges from 0 to X - 1 inclusive and the row index y ranges from 0 to Y - 1. The value of any given cell is the polynomial x + y2. Given a value V, count the number of times V appears in the grid. For example: Given X = 4, Y = 4, and V = 3 The value 3 occurs 2 times in the 4 x 4 grid. See the attachments tab for an illustration of this example. | ||
InputA comma-separated list of:
| ||
OutputThe number of times V occurs in the matrix | ||
Attachments | ||
JSON Menu IDs | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-28 |
SummaryCalculate IDs in JSON menu | ||
DescriptionYou have a JSON string which describes a menu. Calculate the SUM of all "id" fields in the menu for items that also have a "label" field. | ||
InputYour program should read lines from standard input. Each line contains a JSON object that represents a menu. Each ID in the menu is between 0 and 100. Each menu has a maximum of 10 items. | ||
OutputPrint the sum of the id's of menu items that also have a label. | ||
Kennel Counting | ||
| Difficulty: Easy | Test Cases: 4 | Published: 2019-04-02 |
SummaryPerform basic JSON handling | ||
DescriptionA pet adoption agency needs to keep track of their inventory. Given a set of data describing the monthly intake of pets, count and group the pets by Type and Breed. | ||
InputA list of pets to inventory expressed in JSON format. For example: { "Pets":[ { "Breed":"Dingo", "IsFixed":false, "Name":"Fido", "Source":"Australia Kennel Network", "Type":"Dog" }, { "Breed":"Siamese", "IsFixed":true, "Name":"Fluffy", "Source":"Lost and Found", "Type":"Cat" } ] }
| ||
OutputA list that includes each Type, Breed, and Count in a line-by-line report that is sorted alphabetically. For example: Cat Siamese 1 Dog Dingo 1
| ||
Kitchen View | ||
| Difficulty: Easy | Test Cases: 4 | Published: 2019-04-02 |
SummaryPivot a set of data into a summary of counts | ||
DescriptionA restaurant ordering system accepts food orders one item at a time. Each item entered is for a specific person sitting at a particular table. The kitchen is not concerned with which person ordered which item. They just need to know what menu items have been ordered for each table. Write a program that will read a list of individual orders and "pivot" that set into a display of food items for each table in the diner. The total number of each item per table will be displayed on a column for that food item. For example, the orders: Sarah,7,Green Salad Sarah,7,Cappuccino Michael,2,Club Sandwich Marcus,5,Sparkling Water Would be displayed for the kitchen as: Table,Cappuccino,Club Sandwich,Green Salad,Sparkling Water 2,0,1,0,0 5,0,0,0,1 7,1,0,1,0 Note that the menu items are listed in alphabetical order across the overall list. | ||
InputA comma-delimited list of names, table numbers, and menu items. | ||
OutputA comma-delimited list of table numbers and item counts with a header row as the first line. The first column name is "Table". | ||
Largest Difference | ||
| Difficulty: Easy | Test Cases: 7 | Published: 2012-10-08 |
SummaryFind the largest difference between integers in a list | ||
DescriptionWrite a program that finds the greatest difference between integers in a list. The list can contain positive and negative integers. | ||
InputYour program should read lines from standard input. Each line contains a comma-separated list of integers. | ||
OutputFor each input list, print to standard output the greatest difference between any two integers in the list. Print each difference on its own line. | ||
Least Common Multiple | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2012-10-08 |
SummaryLeast common multiple of two numbers | ||
DescriptionWrite a program that finds the least common multiple of two positive integers. | ||
InputYour program should read lines from standard input. Each line contains two positive integers separated by a comma. | ||
OutputFor each pair of input integers, print to standard output their LCM, one LCM per line. | ||
Letter Transformation | ||
| Difficulty: Easy | Test Cases: 7 | Published: 2012-10-08 |
SummaryTransform letters in a string | ||
DescriptionWrite a program that transforms strings of lowercase alphabet characters by replacing each letter with the subsequent character in the english alphabet. For example, replace 'a' with 'b', 'p' with 'q', and 'z' with 'a'. | ||
InputYour program should read lines from standard input. Each line will contain lowercase english letters. | ||
OutputFor each input string, print the transformed string to standard output, one string per line. | ||
Longest Word | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-28 |
SummaryGet the longest word in a sentence | ||
DescriptionIn 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 one that appears first. | ||
InputYour program should read lines from standard input. Each line has one or more words. Each word is separated by a space char. | ||
OutputPrint the longest word in the sentence. | ||
Lowercase | ||
| Difficulty: Easy | Test Cases: 4 | Published: 2012-10-08 |
SummaryLowercase text | ||
DescriptionGiven a string, write a program to convert it into lowercase. | ||
InputYour program should read lines of text from standard input. Each line will be a sentence containing characters from the English alphabet. | ||
OutputFor each input sentence, print to standard output the lowercase version of the sentence, one sentence per line. | ||
Lowest Unique Number | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-28 |
SummaryFind the lowest unique number in a set | ||
DescriptionYou are playing a game with several friends. Each of your friends chooses a number between 1 and 9 (inclusive) and writes it down on a piece of paper. You, as the judge, collect all the papers and must determine the winner. The winner of the game is the player who submitted the lowest unique number. | ||
InputYour program should read lines from standard input. You are the judge, and you're given a set of space-delimited numbers from players for each round of game. | ||
OutputPrint the winner's position in the input list, or 0 if there is no winner (there are no unique numbers). In the first sample test case, the lowest unique number is 6. So player 5 wins. | ||
Major Element | ||
| Difficulty: Easy | Test Cases: 8 | Published: 2014-02-28 |
SummaryFind the major element in a sequence | ||
DescriptionThe major element in a sequence with length L is the element which appears in a sequence more than L/2 times. The challenge is to find that element in a sequence. L is in range [100, 2000]. | ||
InputYour program should read lines from standard input. Each line of the file contains a sequence of integers separated by commas. Each integer is in range [0, 100]. | ||
OutputFor each sequence, print out the major element or print "None" if there is no such element. | ||
Manchester Decoding | ||
| Difficulty: Easy | Test Cases: 9 | Published: 2019-04-18 |
SummaryDecode binary number from a Manchester code | ||
DescriptionIn telecommunications, Manchester code is a form of digital encoding in which data bits are represented by transitions from one logical state to another. It is used in Ethernet's physical layer, Radio-frequency identification (RFID) and Near-field communication (NFC). According to the IEEE 802.3 convention, each zero-valued bit is encoded by a transition from one to zero: 10. Conversely, a one-valued bit is expressed by a zero-to-one transition: 01 Write a program to decode positive binary numbers from Manchester encoding. | ||
InputA Manchester-encoded binary form of an integer. For example: | ||
OutputWrite the decoded positive integer in binary form. For example: If the input value is invalid and cannot be decoded, write "ERROR". | ||
Manchester Encoding | ||
| Difficulty: Easy | Test Cases: 8 | Published: 2019-04-18 |
SummaryEncode binary number with a Manchester code | ||
DescriptionIn telecommunications, Manchester code is a form of digital encoding in which data bits are represented by transitions from one logical state to another. It is used in Ethernet's physical layer, Radio-frequency identification (RFID) and Near-field communication (NFC). According to the IEEE 802.3 convention, each zero-valued bit is encoded by a transition from one to zero: 10 Conversely, a one-valued bit is expressed by a transition from zero to one: 01 Write a program to encode positive binary numbers using Manchester encoding. | ||
InputA positive integer in binary form. For example: | ||
OutputManchester code of the number. For example: | ||
Matrix Transpose | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2019-12-03 |
SummaryPrint out a transposed rendering of a number matrix | ||
DescriptionWrite a program that will transpose an m * n matrix of integers. To transpose a matrix, turn all the rows into columns by flipping it over the main diagonal. See the attachments tab for a visual. | ||
Inputm rows of a matrix with n space-separated integers in every row. For example: 1 2 3 4 5 6
| ||
OutputTranspose of a given matrix as n rows. Each row contains m space-separated integer elements of the matrix. For example: 1 4 2 5 3 6
| ||
Attachments | ||
Max Range Sum | ||
| Difficulty: Easy | Test Cases: 5 | Published: 2013-12-20 |
SummaryGiven a list of positive and negative integers, find the largest possible sum of any number of consecutive integers. | ||
DescriptionBob is developing a new strategy to get rich in the stock market. He wishes to invest his portfolio for 1 or more days, then sell it at the right time to maximize his earnings. Bob has painstakingly tracked how much his portfolio would have gained or lost for each of the last N days. Now he has hired you to figure out what would have been the largest total gain his portfolio could have achieved. | ||
InputThe input consists of integers on a line separated by spaces. The input contains N, the number of days (0 < N < 10000), followed by N integers D (-10000 < D < 10000) indicating the gain or loss on that day. | ||
OutputFor each test case, print a line containing the maximum possible gain over the period. If no gain is possible, print 0. | ||
Median Filter | ||
| Difficulty: Easy | Test Cases: 7 | Published: 2019-07-15 |
SummaryApply a standard median filter to a series of data | ||
DescriptionFinally, you get the latest measurements in your scientific experiment. It was not easy to collect that data. A lot of noise is present in the space around your secret laboratory. But you know that it's not hard to improve the quality of the measured signal, applying a median filter to the raw data from analog-to-digital converters. Write a program that filters out the noise from the raw data, using the standard median filter. An output of the filter at some point is the median value of N samples around that point. Another way to describe that is a window of size N elements slides over the input signal, element by element. On every step, the median of the elements in the window is written to the output. The median of the set of integers is the middle element in the sorted list of these numbers. For simplicity, assume that the size of the filter window is always odd. Do not process the boundaries of the input signal, where it's not enough elements to compose a window of the necessary size. In other words, just crop the signal. If the filter's window size is 5 you will lose 2 first and 2 last elements. For example, let's filter signal 17 18 19 37 21 22 23 85 25 26 using a window of size 3. For the first 3 elements 17 18 19 the median is 18. Shifting filter's window to the next 3 elements 18 19 37 gives 19 as an output. 19 37 21 outputs 21, and so on. +------+----------+--------+ | step | elements | median | +------+----------+--------+ | 1 | 17 18 19 | 18 | +------+----------+--------+ | 2 | 18 19 37 | 19 | +------+----------+--------+ | 3 | 19 37 21 | 21 | +------+----------+--------+ | 4 | 37 21 22 | 22 | +------+----------+--------+ | 5 | 21 22 23 | 22 | +------+----------+--------+ | 6 | 22 23 85 | 23 | +------+----------+--------+ | 7 | 23 85 25 | 25 | +------+----------+--------+ | 8 | 85 25 26 | 26 | +------+----------+--------+ Processing all integers from the set will result in 18 19 21 22 22 23 25 26. As you can see, there are no spikes and outlying elements in the output data set. | ||
InputThe first line contains an odd integer, the size of the filter's window. Each next line of the input has a comma-separated series of positive integers. That is raw data of the measured signal. For example: 3 5,5,5,15,5,5,5 1,2,3,25,5,6,52,7,8
| ||
OutputPrint out a comma-separated series of integers, that is a result of applying the standard median filter to the raw input data. For example: 5,5,5,5,5 2,3,5,6,6,7,8
| ||
Merge Step | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2019-04-18 |
SummaryMerge and sort two sets using a specific algorithm | ||
DescriptionYour colleague has 15 years of log files full of performance data. The data needs to be sorted, but the file sizes are so big that it's impossible to load them all into memory at once. Your colleague decided to use a merge sort to divide the data into smaller chunks, sort them recursively, then merge results to produce the final sorted file with all data. Your task is to write the core Merge Step function for the process. This function needs to combine two sorted subarrays into a single, sorted subarray Your program should:
| ||
InputTwo comma-separated, sorted arrays of alphanumeric characters (UTF-8). The pair of arrays are separated by a semicolon. For example: | ||
OutputWrite the merged and sorted result as comma-separated elements on the first line. Write each pair that was compared during merge process on the second line. Elements in each pair must be sorted and comma separated then enclosed in parenthesis. For example: | ||
Minimum Distance | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2013-12-20 |
SummaryGiven a list of points on a number line, find a new point with the smallest sum of distances to every given point. | ||
DescriptionAlice is looking for a sorority to join for her first year at Acme University. There is a street consisting entirely of sorority houses near the university, and some of her high school friends have already joined sorority houses on the street. (More than one of her friends may live at the same sorority house.) | ||
InputThe input consists of several integers on a line, separated by spaces. The first integer F contains the number of friends (0 < F < 100). Then F street addresses A follow (0 < A < 10000). | ||
OutputPrint a line containing the minimal sum of distances for an optimal sorority location. | ||
Mixed Content | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-28 |
SummarySeparate words from digits | ||
DescriptionYou have a string of words and digits separated by commas. Write a program which separates the words in the string from digits. You shouldn't change the order of the elements. | ||
InputYour program should read lines from standard input. Each line contains a comma-delimited list of numbers and strings. | ||
OutputPrint out the two new lists separated by a pipe char (|). If one of the lists is empty, omit the pipe char. Be sure to print elements in the same order they appeared in the original list. | ||
Morse Code | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-28 |
SummaryDecode Morse code | ||
DescriptionYou have received a text encoded with Morse code and want to decode it. | ||
InputYour program should read lines from standard input. Each line contains a Morse code message. Each letter in the code is separated by a space char, each word is separated by 2 space chars. The input will contain encoded letters and numbers only. | ||
OutputPrint out the decoded words. | ||
Multiples of a Number | ||
| Difficulty: Easy | Test Cases: 4 | Published: 2012-10-08 |
SummaryMultiples of a number greater than another number. | ||
DescriptionGiven numbers x and n, where n is a power of 2, print the smallest multiple of n which is greater than or equal to x. Do not use the division or modulo operator. | ||
InputYour program should read lines of text from standard input. Each line will contain the integers x and n, separated by a comma. | ||
OutputFor each line of input, print to standard output the smallest multiple of n which is greater than or equal to x, one per line. | ||
Multiply Lists | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-28 |
SummaryMultiply elements in 2 lists | ||
DescriptionYou have 2 lists of positive integers. Write a program which multiplies corresponding elements in these lists. | ||
InputYour program should read lines from standard input. Each line contains two space-delimited lists. The lists are separated with a pipe char (|). Both lists have the same length, in range [1, 10]. Each element in the lists is a number in range [0, 99]. | ||
OutputPrint the multiplied list. | ||
N mod M | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-20 |
SummaryDetermine the modulus (without the modulus operator). | ||
DescriptionGiven two integers N and M, calculate N mod M (without using any built-in modulus operator). | ||
InputYour program should read lines from standard input. Each line contains two comma-delimited integers, N,M. You may assume M will never be zero. | ||
OutputPrint out the value of N mod M. | ||
Network Bandwidth | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2020-03-06 |
SummaryCalculate network bandwidth | ||
DescriptionGiven a measured file transfer time in seconds and file size in mebibytes (MiB), write a program to calculate the network's bandwidth in Megabits per second (Mb/s). Assume that all network capacity is used for the file data transfer, there is no overhead, loss, congestion, or contention. | ||
InputTwo space-delimited positive integers:
For example: 400 336
| ||
OutputPrint an integer number that is the network's bandwidth in Mb/s. Round the calculated real value up to the smallest integer that is not less than the result. For the example above, the output would be: 10
| ||
Number Trick | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2012-11-01 |
SummaryNumber Trick | ||
DescriptionWrite a program that computes an integer's checksum. To compute the checksum, break the integer into its constituent digits and, working from right to left, doubling every second digit. If the product results in a number with two digits, treat those two digits independently. Then, sum all the digits for the final checksum. For example, 1496 has a checksum of 21. We compute this by first breaking 1496 into constituents and doubling the ever second digit => 6, 18, 4, 2. Then, the individual digits are summed as 6 + (1 + 8) + 4 + 2 = 21. | ||
InputYour program should read lines from standard input. Each line contains one integer. | ||
OutputFor each line of input, print to standard output the integer's checksum, one checksum per line. | ||
One's Complement | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2012-11-06 |
SummaryFind the one's complement of a binary number | ||
DescriptionWrite a program to find the one’s complement of a binary number. The one’s complement of a binary number is obtained by ‘flipping’ every 0 bit to 1 and every 1 bit to 0. | ||
InputYour program should read lines from standard input. Each line contains a positive integer in binary form. | ||
OutputFor each line of input, print to standard output the one's complement of the binary number, also as a binary number. Print out each result on a new line. | ||
Order Statistic | ||
| Difficulty: Easy | Test Cases: 7 | Published: 2019-05-31 |
SummaryFind k order statistic of the array | ||
DescriptionWrite a program that, given an array of n distinct integers and number k, will determine the k order statistic of the array. kis an integer between 1 and n : 1 ≤ k ≤ n. The k order statistic is the k smallest entry in the array. So the n order statistic is simply the maximum value in the set. The median, in other words, the middle element, | ||
InputThe first line of input will contain the order of statistic k to determine. The second line of input will contain a space-separated array of integers to use for the statistical set. For example: 3 5 2 9 7
| ||
OutputThe integer that is determined to be the k order statistic of the given array. For example: | ||
Pairwise Divisible Subset | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2020-03-06 |
SummaryFind the largest pairwise divisible subset of integers | ||
DescriptionGiven a set of distinct integers, find the largest subset such that in every pair of elements, the larger element is evenly divisible by the smaller. So if the pair of elements is (a, b) and a < b then b is divisible by a. If a > b then a is divisible by b. HINT: If every integer in the set A is divisible by x, and x is divisible by y then every integer in the set A is divisible by y. | ||
InputA space-delimited set of integers. For example: 3 5 12 4 7 24 6 10
| ||
OutputThe largest space-delimited subset of pairwise divisible integers in ascending order. For example: 3 6 12 24
| ||
Penultimate Word | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-20 |
SummaryFind the next-to-last word | ||
DescriptionAlice has invented a new card game to play with Bob. Alice made a deck of cards with random values between 1 and 52. Bob picks 5 cards. Then, he has to rearrange the cards so that by utilizing the operations plus, minus, or times, the value of the cards reach Alice's favorite number, 42. More precisely, find operations such that ((((val1 op1 val2) op2 val3) op3 val4) op4 val5) = 42. | ||
InputYour program should read lines from standard input. Each line is a string of space-delimited words (with no punctuation). Each line has at least two words. | ||
OutputPrint the next-to-last word. | ||
Pirate Loot | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2020-01-11 |
SummaryObtain a distribution of values using a set of rules | ||
DescriptionIn the Caribbean Sea, pirates robbed a merchant ship and plundered a chest full of gold coins. The pirates used simple rules on how to distribute the treasure:
Assume that all pirates are greedy and always take the biggest pile of gold they can. For example, if the values of three piles are 1 3 2, the pirate will choose the rightmost pile which has the value of 2. If piles of gold are equal on both sides, for consistency, the rightmost pile must be taken. Write a program to calculate the total value of gold that each pirate will obtain, given the number of pirates N in the crew and an array of values for each pile. | ||
InputThe first line of input contains a positive integer N, which is the count of pirates in the crew. The second line of input contains a space-delimited array of positive integers, representing the total value of gold coins in each pile. For example: 3 5 3 2 4 3
| ||
OutputPrint a space-delimited array of N integers, where each integer is a total value of gold received by each pirate in the crew, from the first to the last. The table below shows the turns taken by pirates and the amount of gold obtained by each of them. +--------+--------+-------------+-------+ | | | Values left | Value | | Turn | Pirate | in a line | of | | Number | Number | before | gold | | | | the turn | taken | +--------+--------+-------------+-------+ | 1 | 1 | 5 3 2 4 3 | 5 | +--------+--------+-------------+-------+ | 2 | 2 | 3 2 4 3 | 3 | +--------+--------+-------------+-------+ | 3 | 3 | 3 2 4 | 4 | +--------+--------+-------------+-------+ | 4 | 1 | 3 2 | 3 | +--------+--------+-------------+-------+ | 5 | 2 | 2 | 2 | +--------+--------+-------------+-------+ After summing up the values taken by each pirate in our example, the final result will be: 8 5 4
| ||
Power of two | ||
| Difficulty: Easy | Test Cases: 8 | Published: 2012-11-06 |
SummaryDetermine if a number is a power of two | ||
DescriptionWrite a program, given a positive integer, determines if the number is an exact power of two. | ||
InputYour program should read lines from standard input. Each line contains a positive integer. | ||
OutputFor each line of input, print to standard output 'true' if the number is an exact power of two and 'false' if not. Print out each result on a new line. | ||
Query Board | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-20 |
SummarySet and get values from a matrix using tiny DSL. | ||
DescriptionThere is a board (matrix). Every cell of the board contains one integer, which is 0 initially. | ||
InputYour program should read lines from standard input. Each line contains one of the above operations. | ||
OutputFor each query, output the result of the query. | ||
Queue Implementation | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2020-01-11 |
SummaryImplement a queue data structure | ||
DescriptionWrite a program implementing a queue, a First-In-First-Out (FIFO) data structure. The queue should have enqueue and dequeue methods:
The queue must have a certain capacity which is the maximum number of elements in the data structure. The enqueue method must do nothing if the queue is full. And similarly, the dequeue method must do nothing if the queue is empty. You will be asked to perform a sequence of operations with integers and then print out the state of the queue. | ||
InputThe first line of input contains a positive integer defining the capacity of the queue. Each additional line of input contains a string naming the operation to be performed: enqueue or dequeue. The enqueue string will be followed by an integer that must be inserted into the queue. For example: 5 enqueue 5 enqueue 6 enqueue 1 dequeue enqueue 2 dequeue enqueue 3
| ||
OutputPrint a space-delimited list of the integers that the queue will contain after all operations have been performed. The order of the elements must be from the front to the back of the queue. For example, using the input shown above, the queue would contain: 1 2 3 Print Empty if the queue will be empty after all operations. | ||
Removing Vowels | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2012-11-05 |
SummaryRemove all vowels from a sentence | ||
DescriptionWrite a program that, given a sentence, strips out all the vowels (‘a’, ‘e’, ‘i’, ‘o’, ‘u’). The string can contain a mix of upper/lowercase and both uppercase and lowercase vowels need to be removed. | ||
InputYour program should read lines from standard input. Each line contains a sentence. | ||
OutputFor each line of input, print to standard output the sentence obtained by removing all uppercase/lowercase vowels, one per line. | ||
Reverse words | ||
| Difficulty: Easy | Test Cases: 5 | Published: 2012-10-08 |
SummaryReversing an input sequence of words. | ||
DescriptionWrite a program to reverse the words of a sentence. | ||
InputYour program should read lines of text from standard input. Each line contains a sentence. | ||
OutputPrint to standard output each sentence with its words reversed, one sentence per line. Empty lines in the input should be ignored. Ensure that your output contains no trailing spaces. | ||
Rightmost Char | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2012-10-08 |
SummaryPrint the position of the rightmost occurrence of a char. | ||
DescriptionGiven a string S and a character t, print the position (zero based) of the rightmost occurrence of t (case matters) in S or -1 if t does not exist in S. | ||
InputYour program should read lines of text from standard input. Each line will contain a string S and a character t, separated by a comma. Ignore all empty lines. | ||
OutputFor each line of input, print to standard output the zero based position of the character t in string S, one position per line. | ||
Road Trip | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2014-02-28 |
SummaryDo not be left without gasoline | ||
DescriptionYou'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 your tank. To make sure that this route is viable, you need to know the distances between the adjacent cities in order to be able to travel this distance on a single tank of gasoline, (No one likes running out of gas.) but you only know distances to each city from your starting point. | ||
InputYour program should read lines from standard input. Each line contains the list of cities and distances to them, comma delimited, from the starting point of your trip. You start your trip at point 0. The cities with their distances are separated by semicolons. | ||
OutputPrint out the distance from the starting point to the nearest city, and the distances between two nearest cities separated by comma, in order they appear on the route. | ||
Robotic Vacuum Cleaner | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2020-02-08 |
SummaryCheck if the robotic vacuum cleaner returns to its base station | ||
DescriptionA robotic vacuum cleans a room by starting from a base station and making a series of moves. The sequence is represented by a string containing one of the following characters for each move:
Given a string with the sequence of moves, check whether or not the robotic vacuum returns to its base station. Assume that each individual move covers the same distance in the given direction. | ||
InputA string containing the characters U, D, R, L describing the robot's sequence of moves. For example: ULLRURDD
| ||
OutputPrint True if the robotic vacuum cleaner returns to the base station. Otherwise, print False. | ||
Roman Numerals | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-20 |
SummaryConvert a cardinal number to a Roman numeral | ||
DescriptionMany people 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 other values, these symbols, and multiples where necessary, are concatenated, with the smaller-valued symbols written further to the right. For example, the number 3 is represented as III, and the value 73 is represented as LXXIII. The exceptions to this rule occur for numbers having units values of 4 or 9, and for tens values of 40 or 90. For these cases, the Roman numeral representations are IV (4), IX (9), XL (40), and XC (90). So the Roman numeral representations for 24, 39, 44, 49, and 94 are XXIV, XXXIX, XLIV, XLIX, and XCIV, respectively. More details can be found here: Roman numerals | ||
InputYour program should read lines from standard input. Each line contains a cardinal number N (1 <= N <= 3999). | ||
OutputPrint out the value of N in Roman numerals. | ||
Rosetta Stone | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2019-04-02 |
SummaryDecode a message using a keyed structure | ||
DescriptionThe Rosetta stone is an ancient decree written into stone that was used by archeologists to translate between Greek and Ancient Egyptian languages. Write a program to decode messages using a Rosetta for translation. The "Rosetta" will be a series of character sets paired with English words or characters. If you translate the encrypted message correctly, you will find the hidden message. HINT: Spaces that are not part of a fragment must be preserved | ||
InputMultiple lines of input will be given. The first line of input will be the message to translate to English. All other lines of input will be the Rosetta needed to translate. The fragments of each pair will be separated by a pipe character, one pair per line of input. For example: Hola Mundo Mundo|World Lunes|Monday Hola|Hello Translates: into: | ||
OutputThe translated text, which will be a real English phrase | ||
Rotated List Search | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2019-04-02 |
SummaryCorrect and search a list that has been rotated | ||
DescriptionWrite a program to search a list of integers for a set of values. The list of integers is sorted in ascending order, but also rotated a random number of positions, making it unclear where the list begins. For example, consider this list of integers to search: 62 78 99 1 5 7 11 13 17 27 It is sorted from 1 to 99 but "rotated" three positions such that the starting point of the list is no longer correct. Given this rotated list, find a way to search for a supplied list of values that may or may not be present in the list. | ||
InputTwo lines of input as follows:
For example, 1 11 17 62 78 99 1 5 7 11 13 17 27
| ||
OutputFor each value to locate, print out the zero-based index of the item in the un-rotated input list. If a value does not exist, print out -1 for that item. Given the example input, the correct output would be: 0 3 5
| ||
Run Kitty, Run | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2019-11-15 |
SummaryCalculate if it possible for the cat to escape from dogs | ||
DescriptionA cat is in a large field with a single big tree growing on it. Unfortunately, the cat has been surrounded by wild dogs which are trying to catch it. All dogs can run faster than the cat, so there is no chance for the cat to run away from the field. The only hope for the cat is to escape up the tree. The cat runs to the tree in a straight line at a fixed speed. The dogs understand the cat's escape plan and run to the tree, also in a direct line, with a higher speed trying to intercept the cat. Given the initial positions and velocities of the animals and the position of the tree, calculate if the cat will escape. To escape successfully, the cat has to reach the tree before than any of the dogs. | ||
InputThe first line of input contains three real numbers separated by a space:
The second line contains two real numbers:
The third line has a positive integer, N, the number of dogs where 1 ≤ N ≤ 100. Each additional N lines contain three real numbers each: x and y coordinates of the initial position and the velocity of each dog. For example: 0.0 0.0 1.0 3.0 4.0 2 12.0 12.0 2.0 -10.0 -10.0 3.0 All coordinates are in meters and velocities are in meters per second. All real numbers have exactly one digit after the decimal point. | ||
OutputA single line with Escaped or Captured, depending on whether the cat can beat all the dogs to the tree or not. | ||
Sea Turtle Tracking | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2020-03-06 |
SummaryCount a number of emersions recorded by a tracker | ||
DescriptionResearchers investigating the behavior of sea turtles use trackers to collect data about their movement in the water. Each tracker records their changes in depth below sea level. When a change in depth of 1 meter is detected, a log entry containing one character is recorded to indicate the change:
Given a string with the depth change sequence that was logged, write a program to count the number of times the turtle emerged on the surface. The logging for each turtle starts and finishes at sea level. For an emersion to be counted, the turtle must come up from under water to the surface. Consider three examples below. +----------+-------------+-----------+ | logged | turtle's | number of | | string | trajectory | emersions | +----------+-------------+-----------+ | UD | _/\_ | 0 | +----------+-------------+-----------+ | DUUUDUDD | /\/\ | 1 | | | _ ./ \_ | | | | \/ | | +----------+-------------+-----------+ | DUDU | _ . ._ | 2 | | | \/ \/ | | +----------+-------------+-----------+
| ||
InputA string containing the characters U, D and describing the turtle's sequence of moves. For example: DUUDDDUUUD See the attachments tab for a graphical representation of the turtle's movement described by the string above. The image shows that two emersions were logged by the tracker in this example. | ||
OutputPrint an integer number indicating how many emersions from the sea were logged by the tracker. | ||
Attachments | ||
Self Describing Numbers | ||
| Difficulty: Easy | Test Cases: 7 | Published: 2012-10-08 |
SummaryDetermine if a number is a self-describing number or not | ||
DescriptionA number is a self-describing number when (assuming digit positions are labeled 0 to N-1), the digit in each position is equal to the number of times that that digit appears in the number. | ||
InputYour program should read lines of text from standard input. Each line contains a single positive integer, N. | ||
OutputFor each input N, print 1 to standard output if N is a self-describing number. Otherwise, print 0. | ||
Set Differences | ||
| Difficulty: Easy | Test Cases: 8 | Published: 2019-04-02 |
SummaryCompare two sets to identify unique values | ||
DescriptionWrite a program that accepts two sets of alphanumeric characters and compares them. Your code should identify the elements that are in the first set but not the second set and output the results. | ||
InputTwo lines of input, where each line is a space-delimited series of uppercase alphanumeric values that represents the set. For example: Z 3 X 2 Y 1 A Z B Y 2 1 | ||
OutputThe set of values that are unique in the first set sorted alphanumerically, by digits and then characters. For example: 3 X If no unique values exist, output NULL | ||
Set Intersection | ||
| Difficulty: Easy | Test Cases: 4 | Published: 2012-10-08 |
SummaryPrint the intersection of two sets of numbers. | ||
DescriptionFind the intersection of two sorted lists of integers. | ||
InputYour program should read lines of text from standard input. Each line will contain two comma separated lists of integers in ascending order, one pair of lists per line. The lists are separated by a semicolon. | ||
OutputFor each pair of input lists, print to standard output their sorted intersection in ascending order, comma separated, one intersection per line. | ||
Shortest Repetition | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-28 |
SummaryFind the shortest repetition in a string | ||
DescriptionWrite 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 "xyzxyzxyzxyz" has period 3, since it is formed by 4 repetitions of the string "xyz". It also has periods 6 (two repetitions of "xyzxyz") and 12 (one repetition of "xyzxyzxyzxyz"). | ||
InputYour program should read lines from standard input. Each line contains a string of up to 80 non-blank characters. | ||
OutputPrint out the smallest period of the input string. | ||
Simple Sorting | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-20 |
SummarySort several numbers | ||
DescriptionWrite a program which sorts numbers. | ||
InputYour program should read lines from standard input. Each line contains space-separated decimal numbers. | ||
OutputPrint the numbers exactly as they appear in the input, in sorted order. | ||
Snail - a Wall Climber | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2019-12-03 |
SummaryWrite a program to calculate how many days are required for a snail to climb up a wall | ||
DescriptionA snail climbs on a wall, it starts at the bottom and climbs up n meters a day. Regretfully, every night it slides m meters down. Given the height of the wall H, write a program to calculate how many days required for the snail to reach the top of the wall. | ||
InputThree non-negative integers n , m , and H separated by a space. For example: 3 2 11
| ||
OutputA single integer number, which is the number of days required for the snail to reach the top of the wall. For example: 9 If the snail will never be able to reach the top of the wall print Fail | ||
Split the Number | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-28 |
SummaryEvaluate the number according to the pattern | ||
DescriptionYou 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. | ||
InputYour program should read lines from standard input. Each line contains the number and the pattern separated by a single whitespace. The number will be in range [100, 1000000000]. All test cases contain valid expressions (no leading zeros). | ||
OutputPrint out the result of the pattern evaluation. | ||
Stock Trader - Simple Bearish Cross | ||
| Difficulty: Easy | Test Cases: 5 | Published: 2019-04-18 |
SummaryCheck a series of stock prices for a trading signal without calculating stats | ||
DescriptionA classic stock trading pattern happens when a 9-Day Moving Average (9-DMA) crosses the 50-Day Moving Average (50-DMA). This can be indicative of a bullish or a bearish setup, depending on the direction. When the 9-DMA crosses below the 50-DMA from above, it is bearish. When the 9-DMA cross above the 50-DMA from below, it is bullish. Write a program that reads in a series of dates and stats, inspects the 9-DMA and 50-DMA, then returns the dates of any bearish signals that occurred. | ||
InputA series of price statistics in the following format: Date|Price|9DMA|50DMA For example: 2016-01-01|22.05|22.19|21.93 2016-01-02|22.45|22.01|21.99 2016-01-03|23.57|21.78|22.07
| ||
OutputA date in ISO 8601 format where a bearish signal occurred. If no bearish signal happened, return the string NULL For example: | ||
Stock Trader - Simple Bullish Cross | ||
| Difficulty: Easy | Test Cases: 5 | Published: 2019-04-19 |
SummaryCheck a series of stock prices for a trading signal without calculating stats | ||
DescriptionA classic stock trading pattern happens when a 9-Day Moving Average (9-DMA) crosses the 50-Day Moving Average (50-DMA). This can be indicative of a bullish or a bearish setup, depending on the direction. When the 9-DMA crosses below the 50-DMA from above, it is bearish. When the 9-DMA cross above the 50-DMA from below, it is bullish. Write a program that reads in a series of dates and stats, inspects the 9-DMA and 50-DMA, then returns the dates of any bullish signals that occurred. | ||
InputA series of price statistics in the following format: Date|Price|9DMA|50DMA For example: 2016-01-01|22.05|21.78|21.93 2016-01-02|22.45|22.01|21.99 2016-01-03|23.57|22.19|22.07
| ||
OutputA date in ISO 8601 format where a bullish signal occurred. If no bullish signal happened, return the string NULL For example: | ||
Sum Numbers | ||
| Difficulty: Easy | Test Cases: 8 | Published: 2012-11-05 |
SummarySum two numbers to arrive at the third | ||
DescriptionWrite a program that, given a list of three numbers, determines if it is possible to add two of the numbers to arrive at the third. | ||
InputYour program should read lines from standard input. Each line contains a comma separated list of three integers. | ||
OutputFor each line from standard input, print 'true' or 'false' to standard output if any of the two input numbers can be added to arrive at the third, one per line. | ||
Sum of Digits | ||
| Difficulty: Easy | Test Cases: 5 | Published: 2012-10-08 |
SummarySum of digits comprising a number | ||
DescriptionGiven a positive integer, find the sum of its constituent digits. | ||
InputYour program should read lines of text from standard input. Each line will contain a single positive integer. | ||
OutputFor each input integer, print to standard output the sum of the digits that comprise it, one sum per line. | ||
Sum of Integers from File | ||
| Difficulty: Easy | Test Cases: 2 | Published: 2012-10-08 |
SummaryPrint the sum of integers read from a file. | ||
DescriptionPrint out the sum of integers read from a file. | ||
InputYour program should read lines of text from standard input. Each line will contain a single positive integer. | ||
OutputPrint to standard output the sum of all the integers. | ||
Swap Case | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2012-11-05 |
SummarySwapping the case of letters in a sentence | ||
DescriptionWrite a program that, given a sentence, swaps the case of each character in the sentence. Assume all characters are from the ASCII character set. Punctuation symbols should be left as is. | ||
InputYour program should read lines from standard input. Each line contains a sentence. | ||
OutputFor each line of input, print to standard output the sentence obtained by swapping the case of each character, one per line. | ||
Swap Elements | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-28 |
SummarySwap elements in a list | ||
DescriptionYou are given a list of numbers which is supplemented with positions that have to be swapped. | ||
InputYour program should read lines from standard input. Each line contains a list of space-delimited numbers, followed by a colon, followed by the indexes to be swapped. The first position in the list is at index 0. If there is more than one pair of indexes to be swapped, process each pair in the order they appear in the input, left to right. | ||
OutputPrint the new list. | ||
Swap Numbers | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2012-11-05 |
SummarySwapping numbers surrounding a word | ||
DescriptionWrite a program that, given a sentence where each word has a single digit positive integer as a prefix and suffix, swaps the numbers while retaining the word in between. Words in the sentence are delimited from each other by a space. | ||
InputYour program should read lines from standard input. Each line contains a sentence. Each word in the sentence begins and ends with a single digit positive integer i.e. 0 through 9. Assume all characters are ASCII. | ||
OutputFor each line of input, print to standard output the sentence obtained by swapping the numbers surrounding each word, one per line. | ||
Time Difference | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2012-11-07 |
SummaryCalculate the time difference between two clock times | ||
DescriptionWrite a program that, given two clock times, prints out the absolute number of minutes between them. | ||
InputYour program should read lines from standard input. Each line contains two wall clock times separated by a hyphen. Wall clock time is defined as hh:mm followed by AM' or 'PM', e.g. '09:05 AM' | ||
OutputPrint to standard output the number of minutes between the two times from standard input. Print out each result on a new line. | ||
URL Parsing | ||
| Difficulty: Easy | Test Cases: 6 | Published: 2012-11-02 |
SummaryParsing out components of a URL | ||
DescriptionWrite a program that, given a URL, parses out and displays its constituent components. For the purpose of this challenge, a URL is of the form <protocol>://<domain>/path?<query string>. Print out the protocol, domain, and query string, separated by commas. | ||
InputYour program should read lines from standard input. Each line contains a URL. There is one URL per line. | ||
OutputFor each line of input, extract and print a line to standard output. The output should be a comma-separated list of the protocol, domain, and query string of the URL (in that order). In case any of the components are missing, leave them blank in the output. | ||
Unique Elements | ||
| Difficulty: Easy | Test Cases: 4 | Published: 2012-10-08 |
SummaryExtract unique list from a sorted list of numbers. | ||
DescriptionWrite a program to remove duplicates from lists. | ||
InputYour program should read lines of text from standard input. Each line will contain a comma separated list of sorted integers. | ||
OutputFor each input list, print the list to standard output with duplicates removed, one list per line. | ||
Word Flip | ||
| Difficulty: Easy | Test Cases: 5 | Published: 2019-04-02 |
SummaryManipulate strings and words | ||
DescriptionWrite a program to break down a complex string into words and transpose them. The manipulation must reverse each individual word so it's backwards and also write them out to individual lines in the order of the original sentence. For example: Would be "flipped" to: | ||
InputAny single-line string that may or may not resemble a sentence. Spaces will separate each "word". | ||
OutputIndividual words from the input string printed one word per line. The letters of each word must be in reversed order. Whitespace should be excluded from output. | ||
Word Search | ||
| Difficulty: Easy | Test Cases: 12 | Published: 2019-11-15 |
SummaryFind all words satisfying given criteria | ||
DescriptionWrite a program to find all words in a string that satisfy the following conditions:
Any character that does not fit the first condition can be used to separate distinct words. Use regular expression(s) to search. | ||
InputA string in which to search. For example: Theory Lab_99 society Imagi4nation
| ||
OutputPrint out the list of found words in order of their appearance in the input string. Print each word on a separate line. For example: Lab_99 Imagi4nation Print NONE if there are no words in the string, matching necessary rules. | ||
Word to Digit | ||
| Difficulty: Easy | Test Cases: 10 | Published: 2014-02-28 |
SummarySubstitute words to digits | ||
DescriptionGiven a string representation of a set of numbers, print the digit representation of the numbers. | ||
InputYour program should read lines from standard input. Each line contains a list of word representations of numbers separated by a semicolon. There are up to 20 numbers in one line. The numbers are "zero" through "nine". | ||
OutputPrint the sequence of digits. | ||