19
Tangentially inspired by the opening to the What-If book.
The input is a rectangle of spaces as a string, list of string, etc., with objects made of #
's inside:
########
# #
########
### ####
### ####
###
The objects will always be non-intersecting, non-touching, rectangles. A soft object is defined as an object that isn't filled up with #
's in the middle and is only a border, a hard object is one that is filled up. An object with width or height <=2
is considered hard. All objects are either hard or soft.
If there are more hard objects in the input, output "Hard"
, if more soft, output "Soft"
, if they are equal, output "Equal"
.
This is code-golf, so shortest code in bytes wins!
Test Cases
These cases aren't full inputs, but rather what each object should be characterized as. The actual input will be like the ascii-art at the top of the question.
Hard
#
####
##
##
##########
##########
##########
Soft
###
# #
###
###################
# #
# #
# #
###################
####
# #
# #
# #
# #
# #
# #
# #
####
Actual Test Cases
########
# #
########
### ####
### ####
###
Hard
###
###
###
###################
# #
# #
# #
###################
Equal
######
# #
######
###
## # # #
###
########
# #
########
Soft
2Are the outputs strict, or can any 3 unambiguous outputs be used (such as H/S/E or -1/0/1)? – trichoplax – 2016-04-18T21:04:39.390
@trichoplax they are strict – Maltysen – 2016-04-18T21:05:29.457
3Meta answer on cumbersome I/O formats (not to say you can't do what you choose, but just to give a place for people to express a more fine grained opinion if they wish). – trichoplax – 2016-04-18T21:09:08.427
@DLosc sure that's fine, adding. – Maltysen – 2016-04-18T21:17:38.253
@LuisMendo no, adding. – Maltysen – 2016-04-18T21:37:43.877
I assume that by "more hard objects" you mean the number (count) of hard objects, not (for example) the area of hard objects... – agtoever – 2016-04-18T21:53:01.127
Perhaps add a couple of actual test cases? – Luis Mendo – 2016-04-18T22:22:02.667
Are all objects guaranteed to be either hard or soft? – user2357112 supports Monica – 2016-04-18T23:24:27.793
@Maltysen I've added two examples in my answer. Feel free to use include them as test cases – Luis Mendo – 2016-04-18T23:38:00.800
Do we have to take the input as a single strings or can we take it as an array of rows? – Dennis – 2016-04-19T07:24:28.257
@user2357112 yes, clarifying. – Maltysen – 2016-04-19T11:52:58.883
@Dennis either is fine: "string, list of string" – Maltysen – 2016-04-19T11:53:39.807