WRITE A PROGRAM THAT REVERSES THE DIGITS OF A 15 DIGIT LONG NUMBER WITHOUT ANY STRING CONVERSION AND ANY LIBRARIES OTHER THAN YOUR STANDARD LIBRARY OR ELSE THE BIRB IS GOING TO STAB YOU
int reverese(int k) { int res = 0; while(k != 0) { res = k[strlen[k]-1]; } return res; }
this is supposed to be hard? n00bz nabs
Camden King
>> WITHOUT ANY STRING CONVERSION AND ANY LIBRARIES OTHER THAN YOUR STANDARD LIBRARY
get stabbed retard
Gavin Taylor
NICE OVERFLOWS FAGGGGGGOTTTTS
Connor Bell
>,[>,]+[
Cooper Bell
li $a1, 123456789012345 xor $a2, $a2, $a2 li $t1, 10 beqz $a1, end loop: divu $a1, $t1 mflo $a1 mfhi $t2 mul $a2, $a2, $t1 addu $a2, $a2, $t2 bgtz $a1, loop end: j end
Nathan Diaz
BIRDMIN NO
Eli Cox
int f(int i) { int r = 0;
do r = (r * 10) + i % 10; while (i /= 10);
return r; }
Christian Clark
>homework thread
Aaron Hernandez
>implying This is just the most straightforward algorithm.
Yeah, I know int is not appropriate here.
Lucas Peterson
don't listen to the haters cutie. just crossdress and drop by /agdg/
Nicholas King
number = 15digitlong number2 = 15digitlong_reverse print number if(user pres 1){ number = number2 } print number1 again.
be smart.
Asher Rodriguez
...
Kayden Williams
why are you yelling at me not OP, he's the one asking the question in the first place
Thomas Martin
neat
Julian Price
import std.stdio; import std.math;
void reverseNumber(ulong n) { for (ulong i = 0; i < 15; i++) (n / pow(10, i) % 10).write; writeln; }
void main() { 123456789012345.reverseNumber; }
Samuel Gomez
>no other libraries than stdlib
Anthony Myers
If you can't write your own power function you should kill yourself.
John Fisher
Go ahead, do it then
Nicholas Wright
Why would he?
Also math is a part of the standard library.
Michael Allen
fun Int.reverse(): Int = generateSequence(Pair(this, 0), { (n, _) -> Pair(n / 10, n % 10) }) .drop(1) .takeWhile { (n, d) -> n > 0 || d > 0 } .map { (_, d) -> d } .toList() .asReversed() .mapIndexed { i, d -> d * Math.pow(10.toDouble(), i.toDouble()) } .sum() .toInt()
println(12045.reverse()) // 54021
Jacob Hughes
I bet you work well with others
Austin Sanchez
Who would ever do their programming homework in Rust?
Lucas Cooper
>t. buttblasted retard
Alexander Gray
...
Elijah Martin
I bet you don't work with others at all.
Jayden Hughes
opishere
Jayden Martinez
>u128 Is this 128 bit integers? how much slower they are comparing to 64?
Isaac Richardson
wut is this
Easton Campbell
code link, plz?
Jayden Cooper
Not the poster, but it looks like a genetic algorithm with a fitness function that looks for sassy language.
FYI, GAs operate using Darwin's Theory of Evolution. Individuals are inserted into the population, they have sex and produce offspring, and the children with more desirable traits are the ones that are more likely to pass on their genetic material.
This shit is used for all sorts of optimization problems.
Ryan Mitchell
Sorry, looks for the input string, which happens to be sassy language.
Elijah Cooper
>No recursion Thank you for your interest in our company, user, but we need someone with a bit more experience. However, we'll keep your resume on file.