Which set cannot be the image of $(0,1]$ under a continuous function and why . 
Let  $f :\mathbb R \rightarrow\mathbb R$ be  continuous  function . Then  which  cannot  be  the  image  of $(0,1]$ ?
A. $\{0\}$
B. $(0,1)$
C. $[0,1)$
D. $[0,1]$

Now  A.  is  the  constant  map. C. is  the  map  $f(x)=1-x$.
Little  confusion  about  B.  and D. If  it  is  that  $(0,1)$  is  embedded  in  $(0,1]$ so  B. cannot  be  the  answer  then  similarly   $(0,1]$  is  embedded  in  $[0,1]$  so  D.  is  also  not  the  answer . All  answers  wrong   is  not  a  possibility.  What  did  I  miss  here?
 A: Option $A$ $\rightarrow $ $\mathcal constant  \ \ function$
Option $C$ $\rightarrow$  $f(x)=1-x$
Option $D$ $\rightarrow$  $f(x)=|2x-1|$
The impossible  one  is  option $B$.  Here  are  two  different  explanations :
$1)$If possible , let us assume that $f((0,1])=(0,1).$ So, In $(0,1)$ we can find two sequences(Since this is not compact) that do  not converge in $(0,1)$. Say $$w_n\rightarrow 0$$  and  $$z_n\rightarrow 1$$.
Since , $(0,1)$ is the image of $(0,1]$ under $f$ , we can write $$w_n=f(x_n)$$ and $$z_n=f(y_n).$$ For  two  sequences  $x_n$  and  $y_n$ in  $(0,1].$ If both  $x_n$ and $y_n$   have  convergent subsequences  in  $(0,1]$  then  by continuity  of  $f$ , $f(x_n)=w_n$ and $f(y_n)=z_n$ both have convergent  subsequences  and  eventually  converge  in  $f((0,1]=(0,1)$ , which is not the case. But in $(0,1]$ , the only chance of a sequence not having a convergent sub sequence is that , it converges to $0$ .   This  is  how  we  ensure  that : 
By Bolzano-Weierstrass  Theorem , we know that Every bounded sequence has a convergent sub sequence(In the completion of the sub space of $\mathbb R$  in  consideration). So every sequence in $(0,1)$ has a convergent sub sequence  in $\bar{(0,1]}=[0,1].$ The only limit point of $(0,1)$ that is not in $(0,1]$  is $0$ . Thus , both  $x_n$ and $y_n$ must have $0$ as their limit  in order not to converge in $(0,1].$  
But  then $$\lim_n x_n=0=\lim_n y_n\\i.e.\ \ \lim_n f(x_n)=f(0)=\lim_n f(y_n)\\ i.e.\ \ 0=f(0)=1$$  which  is  totally  absurd . So, $$f((0,1])\neq (0,1)$$.
 Proved.
$2)$  We can write $$[0,1]=\{0\}\cup (0,1].$$  NOw for  compactness , $$f([0,1])=C$$ for some connected,compact set $C$. Now , $$C=f([0,1])=f(\{0\})\cup f((0,1]).$$ Dependeng  on whether $f$ is injective or not , $$f((0,1])=C\backslash \{y\}\\or,\ \ f((0,1])=C.$$ So, for $B)$ to be true , we need $$(0,1)=C\backslash \{y\} \ or\ C$$  but $(0,1)$ is not of that form . So , we have arrived at a contradiction again. So $B)$  is  not  true. Proved.
A: The easiest way to see that B is impossible is that if $f:R\to R$ is continuous then $f$ restricted to the domain $[0,1]$ is continuous.  The continuous image of a compact space is compact. Case B would require that $S=\{f(0)\}\cup f (0,1]=\{f(0)\}\cup (0,1)$ is compact. But $S\in\{(0,1),[0,1),(0,1]\}$ so $S$ is not compact.
A: B. $(1+\cos^2 (1/x))/(2+x)$ will do this. (Oops, this is wrong because $f$ was to be continuous on $\mathbb R ;$ see below.)
D. $4(1-x^2)$ will do it.

It was pointed out to me that these functions need to continuous on $\mathbb R.$ Then B. is impossible: We have $f([0,1]) = f(\{0\})\cup (0,1).$ But $f([0,1])$ is compact, and $f(\{0\})\cup (0,1)$ is either $(0,1),[0,1),$ or $(0,1]$ - none of which is compact.
