Skip to content

Instantly share code, notes, and snippets.

@toastkidjp
Last active February 20, 2017 09:14
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 toastkidjp/30d0c66c890e2ac9644beae66ecca778 to your computer and use it in GitHub Desktop.
Save toastkidjp/30d0c66c890e2ac9644beae66ecca778 to your computer and use it in GitHub Desktop.
Googleの入社試験(非公式)にGroovyでチャレンジしてみる ref: http://qiita.com/y_q1m/items/9b8b20cdd9cfea4cc078
int count = 0
(1..1000000).forEach{it ->
String str = Integer.toString(it)
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i)
if (c == '1') {
count++
}
}
if (it == count) {
println it
return
}
}
println count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment