Author Topic: Gaaaah! Stupid question.  (Read 312 times)

RobR

  • New improved. Now with added something...
  • Jackass In Charge
  • Posts: 6575
  • Karma: +86/-149
Gaaaah! Stupid question.
« on: June 13, 2019, 10:59:03 AM »
Sorry to post such a stoopid question here, but I need some help. I'm getting bogged down on a calculation and I can't wrap my head around it.

Basically I need to do the following mapping.

14 -> 69
15 -> 69
16 -> 69
17 -> 69
18 -> 73
19 -> 73
20 -> 73
21 -> 73
22 -> 77
23 -> 77
24 -> 77
25 -> 77
26 -> 81
27 -> 81
28 -> 81
29 -> 81

etc etc.

I know there must be a function where fn(x) = y, and it's probably really simple, but I just can't see it.

Currently I have a switch case which is ugly as fuck.

HELP!

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 5083
  • Karma: +64/-22
    • http://jeff.bagu.org
Re: Gaaaah! Stupid question.
« Reply #1 on: June 13, 2019, 11:05:25 AM »
Code: [Select]
> python
Python 2.7.10 (default, Feb 22 2019, 21:55:15)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> for i in range(14,29):
...     print 69 + (4*((i-14)/4))
...
69
69
69
69
73
73
73
73
77
77
77
77
81
81
81

RobR

  • New improved. Now with added something...
  • Jackass In Charge
  • Posts: 6575
  • Karma: +86/-149
Re: Gaaaah! Stupid question.
« Reply #2 on: June 13, 2019, 11:08:17 AM »
See, I knew it was simple. Thanks Perspective. Have a virtual beer.

Props++

Just out of interest, what was your approach, or was it obvious?

charlie

  • Jackass In Charge
  • Posts: 8488
  • Karma: +83/-52
Re: Gaaaah! Stupid question.
« Reply #3 on: June 13, 2019, 11:08:32 AM »
Six minutes, twenty two seconds is pretty impressive.


Mostly for being on esink and seeing the question that quickly. ;)

Mike

  • Ass Wipe
  • Posts: 12098
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: Gaaaah! Stupid question.
« Reply #4 on: June 13, 2019, 11:39:06 AM »
See, I knew it was simple. Thanks Perspective. Have a virtual beer.

Props++

Just out of interest, what was your approach, or was it obvious?

The output increments in groups of 4.  So, 4 inputs go to the same output.  So for me that indicates a modulus operation.  With some math to get the initial values lined up.

RobR

  • New improved. Now with added something...
  • Jackass In Charge
  • Posts: 6575
  • Karma: +86/-149
Re: Gaaaah! Stupid question.
« Reply #5 on: June 13, 2019, 12:03:33 PM »
My maths sucks since I got old :(

(That's a lie - It's always sucked) :rofl:

Jake

  • Jackass In Charge
  • Posts: 8408
  • Karma: +83/-17
Re: Gaaaah! Stupid question.
« Reply #6 on: June 13, 2019, 12:52:28 PM »
Impressive, Perspective! See, Rob, you should stop by more often
Do not follow where the path may lead. Go instead where there is no path and leave a trail.

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 5083
  • Karma: +64/-22
    • http://jeff.bagu.org
Re: Gaaaah! Stupid question.
« Reply #7 on: June 13, 2019, 04:35:31 PM »
See, I knew it was simple. Thanks Perspective. Have a virtual beer.

Props++

Just out of interest, what was your approach, or was it obvious?

Well, ignoring the shift in the input to output (from 14 to 69 etc..), you basically just want to output a number 4 times, then increase that number by 4. So integer division (by 4) gives you the "epoch" you're at (how many times have I incremented by 4). Multiply that by 4 and you get the factor you should add. Then you add the two shifts, input starting at 14 and output starting at 69.

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 5083
  • Karma: +64/-22
    • http://jeff.bagu.org
Re: Gaaaah! Stupid question.
« Reply #8 on: June 13, 2019, 04:36:52 PM »
Six minutes, twenty two seconds is pretty impressive.


Mostly for being on esink and seeing the question that quickly. ;)

Yeah, the timing was pretty good. I just happened to have stopped by for my (second) morning coffee. And since Micah's update was light I had some extra time on my hands :D

micah

  • A real person, on the Internet.
  • Jackass In Charge
  • Posts: 7206
  • Karma: +57/-55
  • Truth cannot contradict truth.
    • micahj.com
Re: Gaaaah! Stupid question.
« Reply #9 on: June 13, 2019, 07:59:39 PM »
Glad I could free up some time for you.
« Last Edit: June 14, 2019, 08:41:45 AM by micah »
"I possess a device, in my pocket, that is capable of accessing the entirety of information known to man.  I use it to look at pictures of cats and get in arguments with strangers."

RobR

  • New improved. Now with added something...
  • Jackass In Charge
  • Posts: 6575
  • Karma: +86/-149
Re: Gaaaah! Stupid question.
« Reply #10 on: June 14, 2019, 04:39:51 AM »
Impressive, Perspective! See, Rob, you should stop by more often

:D

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14413
  • Karma: +72/-789
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: Gaaaah! Stupid question.
« Reply #11 on: June 14, 2019, 08:51:57 AM »
Six minutes, twenty two seconds is pretty impressive.


Mostly for being on esink and seeing the question that quickly. ;)

Yeah, the timing was pretty good. I just happened to have stopped by for my (second) morning coffee. And since Micah's update was light I had some extra time on my hands :D
LOL - Micah's updates are largely the determining factor in my morning routine as well.  :D