4
Since no one has posted a "good quality question" recently, i feel it is my duty to...
Task:
You work at an electronics company in the design department. The designers that work with you have asked you to make a program that will calculate the optimum configuration of pins on a microchip they are designing. With your ninja golfing skills, you are confident you can handle it.
Your company also has these requirements for each chip:
- The chips your company makes are known as TQFP, they have pins on each edge, but none in the middle.
- Each chip must be square, and have the same number of pins on each side.
- If the chip doesn't have enough pins to be square, pins will be added.
- Extra pins are either a ground or voltage supply pin.
- Half are ground, half are voltage supply.
- If there is an odd number of extra pins, the odd one out is ground
Your program will take input as a single integer, which is the minimum number of pins the manufacturing needs. You will then output 4 integers:
- The number of pins (total)
- The number of pins per side
- The number of ground pins added
- The number of voltage supply pins added
Rules:
- You can use any language
- This is code-golf, to the shortest answer in bytes wins
- Bonus: -50 for printing an ASCII chip:
Something like this:
+++++
+ +
+ +
+ +
+++++
(For example with an input of 20)
By odd one out do you mean that if we need to add an odd number of pins that
#ground = #voltagesupply + 1
or vice-versa? – Kaya – 2014-03-16T01:25:01.207@Kaya no, you have to add enough to make it divisible by 4 – TheDoctor – 2014-03-16T01:56:25.533
2You may want to add clarification for a point that confused me at first: the pins are at the perimeter of the square, not throughout the square area. – grovesNL – 2014-03-16T02:00:21.010
@TheDoctor you misunderstand my query. Let me rephrase: upon input
3
should the program output4,1,1,0
or4,1,0,1
? – Kaya – 2014-03-16T05:44:16.6801mmm ...
chip
is an ASCII chip – Dr. belisarius – 2014-03-16T06:30:44.543@belisarius, http://meta.codegolf.stackexchange.com/a/1070/194
– Peter Taylor – 2014-03-16T08:12:48.667@PeterTaylor Yep, I know. But "draw a chip" is a little vague. – Dr. belisarius – 2014-03-16T09:13:58.860
Everyone - I was rushed. – TheDoctor – 2014-03-16T14:40:05.083
@kaya
4,1,1,0
– TheDoctor – 2014-03-16T14:41:18.5636One does have to grin at the sheer bravado of posting a question in a rush and then making bold claims that 'no one has posted a "good quality question" recently'. :D – Jonathan Van Matre – 2014-03-16T15:12:07.423
@JonathanVanMatre I just have seen too many downvoted/closed questions recently. I was getting a little bored. – TheDoctor – 2014-03-16T15:20:42.563
@JonathanVanMatre, I'm not sure whether to feel insulted. I'm also not sure whether to vote to close this as little more than a duplicate of Find next multiple of 32.
– Peter Taylor – 2014-03-16T17:25:19.507@TheDoctor, if you're bored by seeing downvoted questions, you could visit the sandbox and try to implement one of the better looking ones there. That way you'll see whether the spec is missing corner cases, and you can help to improve it before it gets posted on the main site. – Peter Taylor – 2014-03-16T17:28:02.457
1Why does your example ASCII chip for
n=20
pins have16
pins? If we are supposed to draw a chip withn-4
pins instead ofn
then what do we draw in the case wheren<=4
? – Kaya – 2014-03-17T04:14:57.830@Kaya, it looks to me like it only has 12 pins, because the question clearly states that the pins are on the sides, so the
+
characters at the corners shouldn't count. – Peter Taylor – 2014-03-17T14:13:42.567All fine and dandy barring that it doesn't address the awkward edge case when
n<=4
. – Kaya – 2014-03-17T14:56:03.523It would have been wise to make the example ASCII chip have ground and voltage supply pins, and display them differently. As far as I can tell, none of the other implementations draws them differently from the standard pins. – Jonathan Van Matre – 2014-03-17T16:31:29.120
@Kaya for the ASCII chip, each corner has 2 pins – TheDoctor – 2014-03-17T22:30:32.270