0

So I'm trying to solve a pattern on a coding game here's my code any help? For the hidden pattern

pattern is input output 1 1 -2 2 0 0 it's solved all three right now cuz this code is running with it if input ==0 { |input +0 ; | } else { | input +0 ; | } if input < -1 { | input +4 ; | } else { | input +0 ; | } there's a hidden pattern that can be solved to its says I'm 71 % the way to having it done but I can't figure out the hidden pattern each rewritten one ether doesn't work or make other patterns fail please help?

23rd Feb 2017, 6:44 PM
Neil Fontaine
Neil Fontaine - avatar
4 Answers
+ 2
It looks to me that your code takes a numerical value and it should return the absolute value of that value. What do I mean by absolute value? Basically, the value's distance from 0. In other words, if the given value is positive (or zero), return that value. If it's negative, get the positive equivalent of that value and return that. EDIT: Since you haven't given us any information how the input/output should occur in this task, I'm just going to assume that input holds the input value and you use a return statement to return that value. if (input >= 0) { return input; } else { return 0 - input; } If I got the pattern right, something like this should work in all cases.
24th Feb 2017, 7:48 AM
Lari Liuhamo
Lari Liuhamo - avatar
+ 1
tried but the -2 if input+2 go's to zero and games patter goal is 2 on that one so I had to input +4 to work ? so I'll lost sorry very new don't no nothing much bout coding but bare basics
25th Feb 2017, 4:14 AM
Neil Fontaine
Neil Fontaine - avatar
0
I've updated my answer to include an example code snippet.
25th Feb 2017, 7:49 AM
Lari Liuhamo
Lari Liuhamo - avatar
0
thx I'll try it's just a game it pulls a pattern gives u a input on three tabs and a goal for output on the three u have to make a script to get pattern right witch I did but there a 4th hidden input that u have to solve for with out knowing but it requires real c++ work so I'm doing thees lessons
25th Feb 2017, 8:08 AM
Neil Fontaine
Neil Fontaine - avatar