Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

This challenge is to test the logical ability and does not have any resemblance with real time problem. The task is to generate the palindrome primes from 10 to 1000 and count the number of occurrences of each digit in them

TSQL Beginners Challenge 7 - Count the occurrence of numbers in the Palindrome Primes

TSQL Beginners Challenge 7 - Count the occurrence of numbers in the Palindrome Primes

May 10 2010 3:06AM by Niladri Biswas   

Introduction

This challenge is to test the logical ability and does not have any resemblance with real time problem. The task is to generate the palindrome primes from 10 to 1000 and count the number of occurrences of each digit in them

A number that reads the same from left to right and vice versa is a palindrome number, for example 121 or 65456. Primes numbers are those that are divisible only by 1 and the number itself, for example 2 or 5.

Sample Data

Expected Results

PalindromPrimes	0	1	2	3	4	5	6	7	8	9
--------------- --	--	--	--	--	--	--	--	--	--
11              -	2	-	-	-	-	-	-	-	-
101             1	2	-	-	-	-	-	-	-	-
131             -	2	-	1	-	-	-	-	-	-
151             -	2	-	-	-	1	-	-	-	-
181             -	2	-	-	-	-	-	-	1	-
191             -	2	-	-	-	-	-	-	-	1
313             -	1	-	2	-	-	-	-	-	-
353             -	-	-	2	-	1	-	-	-	-
373             -	-	-	2	-	-	-	1	-	-
383             -	-	-	2	-	-	-	-	1	-
727             -	-	1	-	-	-	-	2	-	-
757             -	-	-	-	-	1	-	2	-	-
787             -	-	-	-	-	-	-	2	1	-
797             -	-	-	-	-	-	-	2	-	1
919             -	1	-	-	-	-	-	-	-	2
929             -	-	1	-	-	-	-	-	-	2

11 is a palindrome prime number and hence it is listed in the output. 11 has the number "1" twice and therefore the column "1" shows 2. Another palindrome prime, "101" has one zero and two ones. That is why the column "0" shows 1 and the column "1" shows 2.

Rules

  1. The code should run in SQL SERVER 2005 and later versions.
  2. The code should generate the palindrome prime numbers. It should not read from a static table/cte/view.
  3. Output should be sorted by the first column(Palindrome Primes) in ascending order.

Sample Script

Restrictions

  1. The solution should be a single query that starts with a "SELECT" or “;WITH”.

Notes

Tags:Puzzles, TSQL Beginners Challenge, TC, TSQL Beginners Challenge 7

Niladri Biswas
7 · 21% · 6720
TSQL Beginners Challenge 7 - Count the occurrence of numbers in the Palindrome Primes , 5.0 out of 5 based on 0 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]