EppsNet Archive: Programming

Activities That No One Does Anymore

I got an email today from a company wanting to introduce me to their faxing API (Application Programming Interface). Faxing!? Will they also help me do other activities that no one does anymore, like playing the zither or baking my own bread? Read more →

Hour of Code

View this post on Instagram Two of the most important takeaways from the #HourOfCode: “Today I felt good about myself. Today I learned: you can have fun even if it is hard.” – Nicole (2nd grade). Thank you Mrs. Nerkizian for sharing A post shared by Code.org (@codeorg) on Dec 8, 2018 at 11:50am PST Read more →

Making it Easier for Women to Do Things They Don’t Want to Do

Apple launching tech camps for women in bid to diversify industry Like other major tech companies, Apple has been trying to lessen its dependence on men in high-paying programming jobs. I don’t think “dependence” is the right word there. Is that dependence like alcohol dependence, or like dependence on foreign oil? It’s an oblique way of saying “we’re trying to employ fewer men,” but explicitly singling out members of a certain group for unwelcome attention sounds discriminatory and possibly illegal. Women filled just 23 percent of Apple’s technology jobs in 2017, according to the company’s latest breakdown. “Just” — why do we assume that working at Apple is a goal that a lot of women have? Maybe women found better jobs? Or something else they’d rather be doing? Industry critics have accused the technology companies of discriminating against women through a male-dominated hierarchy that has ruled the industry for decades.… Read more →

Competitive Programming: SPOJ – Glass Beads

Link to problem Once upon a time there was a famous actress. As you may expect, she played mostly Antique Comedies most of all. All the people loved her. But she was not interested in the crowds. Her big hobby were beads of any kind. Many bead makers were working for her and they manufactured new necklaces and bracelets every day. One day she called her main Inspector of Bead Makers (IBM) and told him she wanted a very long and special necklace. The necklace should be made of glass beads of different sizes connected to each other but without any thread running through the beads, so that means the beads can be disconnected at any point. The actress chose the succession of beads she wants to have and the IBM promised to make the necklace. But then he realized a problem. The joint between two neighbouring beads is not… Read more →

Competitive Programming: SPOJ – String Problem

Link to problem Substring of some string A is defined as one or more (not necessary succeeding) elements of the string with maintaining the sequence. There are given two strings, string VOKI and string TOKI. Write the program that will calculate the length of any shortest substring of string VOKI such as it is not substring of string TOKI. Input In first line of input file there is string VOKI and in second one is string TOKI. The only characters that will occur are lowercase characters of English alphabet (‘a’- ‘z’). String lengths will be less or equal to 1000. Note: input data will be such so there will always be a solution. Output In the first line of file you should print the length of wanted substring. Sample input banana anbnaanbaan Sample output 5 (eg. banna) Sample input babab babba Sample output 3 (eg. aab) Solution below . .… Read more →

Competitive Programming: SPOJ – Palindromes

A palindrome is a word, phrase, number or other sequence of units that has the property of reading the same in either direction, e.g. ‘racecar’, ‘solos’. Task You are given a number k (2 <= k <= 30000) and a non-empty string S whose length does not exceed 30000 lowercase letters. We say two palindromes are different when they start from different positions. How many different palindromes of the length k does S contains? Input The first line contains K. The second line contains S. K does not exceed the length of S. Output The first and only line should consist of a single number – the number of palindromes found. Example Input: 5 ababab Output: 2 Time limit: 0.100s Link to problem Solution below . . . Read more →

Competitive Programming: SPOJ – Distinct Substrings

Given a string, we need to find the total number of its distinct substrings. Input T- number of test cases. T<=20; Each test case consists of one string, whose length is <= 1000 Output For each test case output one number saying the number of distinct substrings. Example Sample Input: 2 CCCCC ABABA Sample Output: 5 9 Explanation for the testcase with string ABABA: len=1 : A,B len=2 : AB,BA len=3 : ABA,BAB len=4 : ABAB,BABA len=5 : ABABA Thus, total number of distinct substrings is 9. Link to problem Solution below . . . Read more →

Competitive Programming: SPOJ – The Bulk!

ACM uses a new special technology of building its transceiver stations. This technology is called Modular Cuboid Architecture (MCA) and is covered by a patent of Lego company. All parts of the transceiver are shipped in unit blocks that have the form of cubes of exactly the same size. The cubes can be then connected to each other. The MCA is modular architecture, that means we can select preferred transceiver configuration and buy only those components we need . The cubes must be always connected “face-to-face”, i.e. the whole side of one cube is connected to the whole side of another cube. One cube can be thus connected to at most six other units. The resulting equipment, consisting of unit cubes is called The Bulk in the communication technology slang. Sometimes, an old and unneeded bulk is condemned, put into a storage place, and replaced with a new one. It… Read more →

Competitive Programming: SPOJ – Build the Fence

At the beginning of spring all the sheep move to the higher pastures in the mountains. If there are thousands of them, it is well worthwhile gathering them together in one place. But sheep don’t like to leave their grass-lands. Help the shepherd and build him a fence which would surround all the sheep. The fence should have the smallest possible length! Assume that sheep are negligibly small and that they are not moving. Sometimes a few sheep are standing in the same place. If there is only one sheep, it is probably dying, so no fence is needed at all … Input t [the number of tests <= 100] [empty line] n [the number of sheep <= 100000] x1 y1 [coordinates of the first sheep] … xn yn [integer coordinates from -10000 to 10000] [empty line] [other lists of sheep] Text grouped in [ ] does not appear in the input file.… Read more →

Competitive Programming: POJ 2185 – Milking Grid

Description Every morning when they are milked, the Farmer John’s cows form a rectangular grid that is R (1 <= R <= 10,000) rows by C (1 <= C <= 75) columns. As we all know, Farmer John is quite the expert on cow behavior, and is currently writing a book about feeding behavior in cows. He notices that if each cow is labeled with an uppercase letter indicating its breed, the two-dimensional pattern formed by his cows during milking sometimes seems to be made from smaller repeating rectangular patterns. Help FJ find the rectangular unit of smallest area that can be repetitively tiled to make up the entire milking grid. Note that the dimensions of the small rectangular unit do not necessarily need to divide evenly the dimensions of the entire milking grid, as indicated in the sample input below. Input Line 1: Two space-separated integers: R and C… Read more →

Competitive Programming: POJ 1147 – Binary Codes

Description Consider a binary string (b1…bN) with N binary digits. Given such a string, the matrix of Figure 1 is formed from the rotated versions of the string. b1 b2 … bN-1 bN b2 b3 … bN b1 … bN-1 bN … bN-3 bN-2 bN b1 … bN-2 bN-1 Figure 1. The rotated matrix Then rows of the matrix are sorted in alphabetical order, where ‘0’ is before ‘1’. You are to write a program which, given the last column of the sorted matrix, finds the first row of the sorted matrix. As an example, consider the string (00110). The sorted matrix is 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 0 0 0 1 1 1 0 0 0 and the corresponding last column is (1 0 0 1 0). Given this last column your program should determine the first row, which is… Read more →

Competitive Programming: POJ 1961 – Period

Description For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That is, for each i (2 <= i <= N) we want to know the largest K > 1 (if there is one) such that the prefix of S with length i can be written as AK, that is A concatenated K times, for some string A. Of course, we also want to know the period K. Input The input consists of several test cases. Each test case consists of two lines. The first one contains N (2 <= N <= 1,000,000) – the size of the string S. The second line contains the string S. The input file ends with a line, having the number zero on it. Output For each test case, output “Test… Read more →

Competitive Programming: POJ 2074 – Line of Sight

Description An architect is very proud of his new home and wants to be sure it can be seen by people passing by his property line along the street. The property contains various trees, shrubs, hedges, and other obstructions that may block the view. For the purpose of this problem, model the house, property line, and obstructions as straight lines parallel to the x axis: Input Because each object is a line, it is represented in the input file with a left and right x coordinate followed by a single y coordinate: <x1> <x2> <y> where x1, x2, and y are non-negative real numbers, x1 < x2 . An input file can describe the architecture and landscape of multiple houses. For each house, the first line will have the coordinates of the house. The second line will contain the coordinates of the property line. The third line will have a… Read more →

Competitive Programming: POJ 2318 – TOYS

Description Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad have a problem – their child John never puts his toys away when he is finished playing with them. They gave John a rectangular box to put his toys in, but John is rebellious and obeys his parents by simply throwing his toys into the box. All the toys get mixed up, and it is impossible for John to find his favorite toys. John’s parents came up with the following idea. They put cardboard partitions into the box. Even if John keeps throwing his toys into the box, at least toys that get thrown into different bins stay separated. The following diagram shows a top view of an example toy box. For this problem, you are asked to determine how many toys fall into each partition as John throws them into… Read more →

Competitive Programming: POJ 1905 – Expanding Rods

Description When a thin rod of length L is heated n degrees, it expands to a new length L’=(1+n*C)*L, where C is the coefficient of heat expansion. When a thin rod is mounted on two solid walls and then heated, it expands and takes the shape of a circular segment, the original rod being the chord of the segment. Your task is to compute the distance by which the center of the rod is displaced. Input The input contains multiple lines. Each line of input contains three non-negative numbers: the initial lenth of the rod in millimeters, the temperature change in degrees and the coefficient of heat expansion of the material. Input data guarantee that no rod expands by more than one half of its original length. The last line of input contains three negative numbers and it should not be processed. Output For each line of input, output one… Read more →

Competitive Programming: CodeSignal – footballGroupStatictics (A World Cup SQL Challenge)

Description You are creating a website that will help you and your friends keep track of the results of soccer games from all around the world. You store all results of one group in a table, results. You want to sort the teams in a complex way – first by points, then by total goal differences, and then by total goals. If all of these parameters are equal, sort the teams alphabetically. The results table contains the following columns: first_team – the name of the first team; second_team – the name of the second team; first_team_score – the number of goals scored by the first team; second_team_score – the number of goals scored by the second team. Here the primary key is the pair (first_team, second_team). Return the list of team names sorted in the way described above. Note: see three points for a win to understand how points are… Read more →

11,000 New Computer Science Teachers Considered Harmful?

Here’s the start of an email I got from Code.org: We’re kicking off our summer workshops to prepare 11,000 new CS teachers. Last month we welcomed over 600 teachers, facilitators, and Regional Partners to Atlanta, GA for our largest TeacherCon ever. On top of TeacherCon, we also have 350 K-5 workshops and 167 workshops for middle and high school teachers planned this summer, where we expect an additional 10,000 teachers who plan to begin teaching computer science for the first time this fall! This is heralded with an exclamation point, like it’s exciting news, but as a computer science person, I can’t get excited about it. Why do we want kids to be taught computer science by 11,000 teachers who know little or nothing about computer science? How can someone teach something that they themselves don’t do? See if you can get excited about any of the following possibilities: 11,000… Read more →

Competitive Programming: CodeSignal – canScore (A World Cup Challenge)

Description Your friend is a soccer fan and you were watching some World Cup matches with him. You liked this game, but the rules are very complicated for you, so you decided just to try to guess whether the given attack will end with a goal or not. In the beginning, the ball is in the attacking team’s goalkeeper’s hands. On the attacking team, there’s a very talented goalscorer, who is waiting for his chance at the other end of the field. His teammates want to give him the ball so he can score. They can move the ball by passing it one to another along a straight line, but the defender can steal the pass if he is closer than d to the ball at any point throughout the pass. Now you want to know if the attacking team can score or not. Formally, you are given the coordinates… Read more →

Competitive Programming: POJ 3281- Dining

Description Cows are such finicky eaters. Each cow has a preference for certain foods and drinks, and she will consume no others. Farmer John has cooked fabulous meals for his cows, but he forgot to check his menu against their preferences. Although he might not be able to stuff everybody, he wants to give a complete meal of both food and drink to as many cows as possible. Farmer John has cooked F (1 <= F <= 100) types of foods and prepared D (1 <= D <= 100) types of drinks. Each of his N (1 <= N <= 100) cows has decided whether she is willing to eat a particular food or drink a particular drink. Farmer John must assign a food type and a drink type to each cow to maximize the number of cows who get both. Each dish or drink can only be consumed by… Read more →

Competitive Programming: POJ 2455 – Secret Milking Machine

Description Farmer John is constructing a new milking machine and wishes to keep it secret as long as possible. He has hidden in it deep within his farm and needs to be able to get to the machine without being detected. He must make a total of T (1 <= T <= 200) trips to the machine during its construction. He has a secret tunnel that he uses only for the return trips. The farm comprises N (2 <= N <= 200) landmarks (numbered 1..N) connected by P (1 <= P <= 40,000) bidirectional trails (numbered 1..P) and with a positive length that does not exceed 1,000,000. Multiple trails might join a pair of landmarks. To minimize his chances of detection, FJ knows he cannot use any trail on the farm more than once and that he should try to use the shortest trails. Help FJ get from the barn… Read more →

Next Page »