6 kyu

The BIG Pronic challenge

72 of 142LesRamer

Description:

A pronic number is a composite integer that is the product of two consecutive integers -- in other words, every pronic number can be calculated as either n(n+1) or n(n-1) where n is any integer. A related kata Figurate Numbers #2 - Pronic Number was fun and for the 32-bit integer problem space, a simple search-loop made solving that kata possible and a clever formula eliminated the need for a loop altogether.

This challenge will be different - this challenge is to write code that determines whether big -- REALLY BIG -- numbers are pronic. A naive loop through a billion or so numbers isn't going to work here. Provided is a non-loop based starter solution that generally works in the linked kata, but fails for the bigger data passed here.

Detail

  • The tests you see are all you need to pass. There are no surprise tests to pass after the original tests are passing.
  • These tests run your algorithm through over 300,000 numbers -- some pronic and some non-pronic. If your algorithm is reasonable, it should take considerably less than 6 seconds to complete.
  • While authoring this kata, a couple large valued test-cases produced calculated pronics that appeared to be either much smaller than they should have or in some cases they even resulted in negative values. This was due to overflow and unchecked math, so checked block safeguards have been added to the tests to prevent accidental overflow for new and existing test-cases.
Algorithms
Fundamentals

Stats:

CreatedSep 10, 2015
PublishedSep 12, 2015
Warriors Trained563
Total Skips99
Total Code Submissions493
Total Times Completed142
C# Completions72
Java Completions72
Fortran Completions9
Total Stars11
% of votes with a positive feedback rating86% of 48
Total "Very Satisfied" Votes37
Total "Somewhat Satisfied" Votes9
Total "Not Satisfied" Votes2
Total Rank Assessments10
Average Assessed Rank
6 kyu
Highest Assessed Rank
3 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • LesRamer Avatar
  • smile67 Avatar
  • donaldsebleung Avatar
  • kazk Avatar
  • Hullaballoo Avatar
  • hobovsky Avatar
Ad