Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Generate me a QFP chip!

Generate me a QFP chip!

From the sandbox!

QFP is a type of form factor for an electrical component where pins come out the sides of a chip. Here are is a picture of a typical QFP component:
enter image description here

you can see that the general formula is to have 4 sides of equal numbers of pins.

Your challenge is to create a program that takes in an integer, thich represents the number of pins on one side, and creates an ASCII QFP component with numbered pins.

Input:

a single integer which represents the number of pins on one side

Output:

An ASCII QFP chip with an apropriate pinout.

Example:

input:1

 4
 ┌┴┐
1┤ ├3
 └┬┘
 2

input:2

 87
 ┌┴┴┐
1┤ ├6
2┤ ├5
 └┬┬┘
 34

input:12

 444444444333
 876543210987
 ┌┴┴┴┴┴┴┴┴┴┴┴┴┐
 1┤ ├36
 2┤ ├35
 3┤ ├34
 4┤ ├33
 5┤ ├32
 6┤ ├31
 7┤ ├30
 8┤ ├29
 9┤ ├28
10┤ ├27
11┤ ├26
12┤ ├25
 └┬┬┬┬┬┬┬┬┬┬┬┬┘
 111111122222
 345678901234

Rules:

  • all QFP chips must be enclosed and sealed as well as ascii provides. spacing is of utmost importance. Dust inside a microprocessor is bad stuff!
  • pin numbering must be done as in the examples (Read left to right, top to bottom, numbered counter clockwise)
  • You may start numbering at 0, but this must not affect the chip (an input of 12 still needs 12 pins per side)
  • The only valid characers in your output are 1,2,3,4,5,6,7,8,9,0,┌,┴,┐,├,┘,┬,└,┤, spaces, and newlines.
  • all encodings for languages are allowed, but your output MUST be consistent with the rules above.

This is a codegolf, and as such, The code with the least number of bytes wins! Good Luck!

Answer*

Draft saved
Draft discarded
Cancel
3
  • \$\begingroup\$ Sure, let me include a full program. \$\endgroup\$ Commented Dec 8, 2016 at 3:02
  • 1
    \$\begingroup\$ @tuskiomi You should be able to use the ungolfed version in its entirety now. \$\endgroup\$ Commented Dec 8, 2016 at 3:08
  • \$\begingroup\$ An excellent solution! \$\endgroup\$ Commented Dec 8, 2016 at 15:34

AltStyle によって変換されたページ (->オリジナル) /