Tag Archives: Hash

Python anagram solver

Anagram solver in python Two strings are anagrams if they contain the same set of characters regardless of the order of individual characters such as “earth” and “heart”. Write python code to detect if two strings are anagrams. Python anagram …

Read more »

Find repeated characters in python

Python repeated character in string Given a string of characters. Write python code to print the repeated characters Solution This is a typical dictionary based problem. Here is how to do that in Python. # Input string str = “Computers …

Read more »

LZW Compression Method

LZW Algorithm: Introduction It is beyond our imagination to specify a ceiling for the amount of information that an individual or a group of people potentially need to store and/or exchange. Using computer systems, almost all kinds of information can …

Read more »

Perl Struct Example

Problem Provide example code in Perl to implement an array of C like structs Solution Use a hash table. The hash key is recommended to be a unique identifier and the hash value is a reference to an array. The …

Read more »

Perl Script to Parse Log File

Problem You have a log file on UNIX operating system. Each line in the log file contains an IP address in the 10th column where columns (or fields) are separated by a space. Write a Perl program to parse the …

Read more »

Array Missing Number

Problem Given an array of n-1 unique integers. Each element in the array is an integer between 1 and n. Write a program to print the missing number in the array Solution To clarify this problem let us take a …

Read more »

Perl Sort Hash by Value

Problem Given a log file similar to Linux syslog format as in the following example: Jan 4 03:15:01 pla kernel:pla: Some error message Write a Perl script to print the top 5 most repeated error messages. Solution Read the file …

Read more »

Page 1 of 212