Skip to content

Instantly share code, notes, and snippets.

@roblogic
Last active December 2, 2020 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roblogic/127a92168e7c130cd1ac86e7262f6411 to your computer and use it in GitHub Desktop.
Save roblogic/127a92168e7c130cd1ac86e7262f6411 to your computer and use it in GitHub Desktop.
Fortran, 147 bytes solution to https://codegolf.stackexchange.com/a/215896/15940

Per wikibooks, "It should be remembered that Fortran is designed for scientific computing and is probably not a good choice for writing a new word processor.". Fortran doesn't have a regex concept either. This just makes string challenges more interesting!

In this solution, we trim the string S, then iterate over it. Print each character unless it's a space followed by another space. Try it Online!

character(99)S;read(*,'(A)')S
S='"'//trim(adjustl(S))//'"'
do i=1,len(S);if(S(i:i+1).ne.'  ')then
write(*,'(A)',advance="no")S(i:i)
endif;enddo;end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment