Challenge 46 – Convert me to base X?
This Challenge involved creating a function that takes in a decimal (Base 10) number and converts it to a number with a base between 2 and 36.
Create a function that takes in a decimal (Base 10) number and converts it to a number with a base between 2 and 36.
The prototype for the function follows:
ConvertNumberToBase(31, 32) = V
ConvertNumberToBase(31, 16) = 1F
ConvertNumberToBase(31, 15) = 21
ConvertNumberToBase(31, 10) = 31
ConvertNumberToBase(31, 8) = 37
ConvertNumberToBase(31, 3) = 1011
ConvertNumberToBase(31, 2) = 11111
- Write a function that will take a decimal (Base 10) number and convert it to a base between 2 and 36.
Winners (out of approximately 20 respondents)
Thanks to everybody for your responses to SCS Coding Challenge #46!!!
|Name||Prize Winner||Good Answer|
Congratulations to Mathew Kent for his fine efforts to come up with a workable solution.
Monthly Programming Tips
Deferred Execution While Writing LINQ Queries
When a LINQ query is written in .NET, it can only perform the query when the LINQ result is approached. The occurrence of LINQ is known as deferred execution. Developers should understand that in every result set approach, the query gets executed over and over. In order to prevent a repetition of the execution, change the LINQ result to List after execution. In this case add a ToList().
Below is an example:
public void MyComponentLegacyMethod(List masterCollection)
Coding Challenge #47
Please stay tuned, SCS Coding Challenge #47 will be published this week. Details will follow. The winner will be awarded based upon the best approach.