challenge

iterate array to create hibernate criteria statement

let say my array has 3 integer object value= 3,4,5 i would need to create hibernate criteria that look like below criteria.add(Restrictions.and(Restrictions.not(Restrictions.eq( "stepId", new Integer(3))), Restrictions.and(Restrictions .not(Restrictions.eq("stepId", new Integer(4))), Restrictions .not(Restriction...

sql optimize search many-many

usertable ---- id, username grouptable ---- id, groupname group_user -------- uid, gid books ---- id, groupname Input parameters: groupname, username output: list of books Is it possible to use 1 sql statement to get list of books when username is inside groupname Question 2: any good book to recommand to master complex sql st...

Is there a Python-Challenge for beginner?

The known Python-Challenge is quite difficult. Is there a much easier alternative for training my programming skills? ...

How to compute the absolute minimum amount of changes to convert one sortorder into another?

Goal How to encode the data that describes how to re-order a static list from a one order to another order using the minimum amount of bytes possible? Original Motivation Originally this problem arose while working on a problem relaying sensor data using expensive satellite communication. A device had a list of about 1,000 sensors th...

Euler Project No. 2 with Python

Can somebody tell me why this should be wrong? #Each new term in the Fibonacci sequence is generated #by adding the previous two terms. By starting with 1 and 2, #the first 10 terms will be: #1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... #Find the sum of all the even-valued terms in the sequence #which do not exceed four million. sum=2 list...

Simple Python Challenge: Fastest Bitwise XOR on Data Buffers

Challenge: Perform a bitwise XOR on two equal sized buffers. The buffers will be required to be the python str type since this is traditionally the type for data buffers in python. Return the resultant value as a str. Do this as fast as possible. The inputs are two 1 megabyte (2**20 byte) strings. The challenge is to substantially bea...

C puzzle: Output of printf should be '5' always

Hi, I found this puzzle in a C aptitude paper. void change() { //write something in this function so that output of printf in main function //should always give 5.you can't change the main function } int main() { int i = 5; change(); i = 10; printf("%d", i); return 0; } Any solutions.? ...

Find SmallestInt : Smallest integer greater than or equal to n that contains exactly k distinct digits(given values of n and k)

Hi guys, I found this on the internet. It looks good an interview question. I guess I got the working correct but programatically I haven't tried it. SmallestInt You are given an integer n. Return the smallest integer greater than or equal to n that contains exactly k distinct digits in decimal notation. Definition ...

PHP templating challenge (optimizing front-end templates)

Hey all, I'm trying to do some templating optimizations and I'm wondering if it is possible to do something like this: function table_with_lowercase($data) { $out = '<table>'; for ($i=0; $i < 3; $i++) { $out .= '<tr><td>'; $out .= strtolower($data); $out .= '</td></tr>'; } $out .= "</table>"; ...

Graph coloring Algorithm

From wiki http://en.wikipedia.org/wiki/Graph_coloring In its simplest form, it is a way of coloring the vertices of a graph such that no two adjacent vertices share the same color; this is called a vertex coloring. Similarly, an edge coloring assigns a color to each edge so that no two adjacent edges share the same col...

How to get some randomized concats based on 2 columns from 1 table?

Hey folks, i have a large user Database (13k+), and for some reason i need to create random names. The users table has "first_name" and "last_name". Now i want to have 10 concats of full_name and last_name of two completely random rows. Is that even possible with SQL? My other idea was just to create a full_names and last_names table …...

tomcat isolate webapps

multiple webapp running on same tomcat using same jvm. sometime, one webapp that have memory leak will cause entire jvm to crash and affect other webapps. any recommendation how to isolated that without need to use multiple jvm and tomcat ...

PHP RegEx: How to Stripe Whitespace Between Two Strings

I have been trying to write a regex that will remove whitespace following a semicolon (';') when it is between both an open and close curly brace ('{','}'). I've gotten somewhere but haven't been able to pull it off. Here what I've got: <?php $output = '@import url("/home/style/nav.css"); body{color:#777; background:#222 url("/home/st...

Fastest algorithm to check if a number is pandigital?

Pandigital number is a number that contains the digits 1..number length. For example 123, 4312 and 967412385. I have solved many Project Euler problems, but the Pandigital problems always exceed the one minute rule. This is my pandigital function: private boolean isPandigital(int n){ Set<Character> set= new TreeSet<Character>();...

Faster or more memory-efficient solution in Python for this Codejam problem.

I tried my hand at this Google Codejam Africa problem (the contest is already finished, I just did it to improve my programming skills). The Problem: You are hosting a party with G guests and notice that there is an odd number of guests! When planning the party you deliberately invited only couples and gave each couple a...

.Net Architecture challenge: The Change-prone Frankestein Model

Good Morning SO! We've been scratching our heads with with this interesting scenario at the office, and we're anxious to hear your ideas and approaches: We have a database, whose schema is prone to changes -lets call it Prony-. (is used to store configuration parameters for embedded devices. so if the embedded devices guy need a new t...

Challenge: Neater way of currying or partially applying C#4's string.Join

Background I recently read that .NET 4's System.String class has a new overload of the Join method. This new overload takes a separator, and an IEnumerable<T> which allows arbitrary collections to be joined into a single string without the need to convert to an intermediate string array. Cool! That means I can now do this: var evenNum...

Strlen of MAX 16 chars string using bitwise operators

The challenge is to find the fastest way to determine in C/C++ the length of a c-string using bitwise operations in C. char thestring[16]; The c-string has a max size of 16 chars and is inside a buffer If the string is equal to 16 chars doesn't have the null byte at the end. I am sure can be done but didn't got it right yet. I am wo...

What is my error in a map in Java?

I am trying to solve this problem: http://www.cstutoringcenter.com/problems/problems.php?id=4, but I cant figure out why my code doesnt solve this, I mean in the "for" how can I can multiply the letters? What is my error? It just tell always 7, but I want to multiple all the letters. I hope you can help me. public class ejercicio3 { ...

Best way to Sort-n-Concatenate 5 columns

!!! WARNING !!! Dearest SQL expert, please keep reading before to start to scream. this uber-denormalized table structure is obtained after apply some combinatories-sugar upon a nicely normalized set of data : ). I'm avoiding to renormalize this resultset because I want to keep simple the complete process (also this...